*add operator()(int) for vectors, synonymous to operator[](int).

I don't see any reason not to allow it, it doesn't add much code, and
 it makes porting from eigen1 easier.
*expand tests/basicstuff to first test coefficient access methods
This commit is contained in:
Benoit Jacob
2008-08-18 12:33:14 +00:00
parent 95a1283bf6
commit baf0cffedd
3 changed files with 48 additions and 0 deletions

View File

@@ -46,9 +46,22 @@ template<typename MatrixType> void basicStuff(const MatrixType& m)
v2 = VectorType::Random(rows),
vzero = VectorType::Zero(rows);
Scalar x = ei_random<Scalar>();
int r = ei_random<int>(0, rows-1),
c = ei_random<int>(0, cols-1);
m1.coeffRef(r,c) = x;
VERIFY_IS_APPROX(x, m1.coeff(r,c));
m1(r,c) = x;
VERIFY_IS_APPROX(x, m1(r,c));
v1.coeffRef(r) = x;
VERIFY_IS_APPROX(x, v1.coeff(r));
v1(r) = x;
VERIFY_IS_APPROX(x, v1(r));
v1[r] = x;
VERIFY_IS_APPROX(x, v1[r]);
VERIFY_IS_APPROX( v1, v1);
VERIFY_IS_NOT_APPROX( v1, 2*v1);
VERIFY_IS_MUCH_SMALLER_THAN( vzero, v1);