mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
*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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user