20 m2 = MatrixType::Random(rows, cols);
22 Scalar s1 = internal::random<Scalar>();
26 m2.diagonal() = 2 * m1.diagonal();
27 m2.diagonal()[0] *= 3;
32 N1 = MatrixType::RowsAtCompileTime>2 ? 2 : 0,
33 N2 = MatrixType::RowsAtCompileTime>1 ? -1 : 0
37 if(MatrixType::SizeAtCompileTime!=
Dynamic)
39 VERIFY(m1.template diagonal<N1>().RowsAtCompileTime == m1.diagonal(N1).size());
40 VERIFY(m1.template diagonal<N2>().RowsAtCompileTime == m1.diagonal(N2).size());
43 m2.template diagonal<N1>() = 2 * m1.template diagonal<N1>();
44 VERIFY_IS_APPROX(
m2.template diagonal<N1>(), static_cast<Scalar>(2) * m1.diagonal(N1));
45 m2.template diagonal<N1>()[0] *= 3;
46 VERIFY_IS_APPROX(
m2.template diagonal<N1>()[0], static_cast<Scalar>(6) * m1.template diagonal<N1>()[0]);
49 m2.template diagonal<N2>() = 2 * m1.template diagonal<N2>();
50 m2.template diagonal<N2>()[0] *= 3;
51 VERIFY_IS_APPROX(
m2.template diagonal<N2>()[0], static_cast<Scalar>(6) * m1.template diagonal<N2>()[0]);
53 m2.diagonal(N1) = 2 * m1.diagonal(N1);
54 VERIFY_IS_APPROX(
m2.template diagonal<N1>(), static_cast<Scalar>(2) * m1.diagonal(N1));
55 m2.diagonal(N1)[0] *= 3;
58 m2.diagonal(N2) = 2 * m1.diagonal(N2);
59 VERIFY_IS_APPROX(
m2.template diagonal<N2>(), static_cast<Scalar>(2) * m1.diagonal(N2));
60 m2.diagonal(N2)[0] *= 3;
63 m2.diagonal(N2).x() = s1;
65 m2.diagonal(N2).coeffRef(0) =
Scalar(2)*s1;
69 VERIFY( m1.diagonal( cols).size()==0 );
70 VERIFY( m1.diagonal(-rows).size()==0 );
79 if (rows>=2 && cols>=2)
void diagonal_assert(const MatrixType &m)
#define VERIFY_RAISES_ASSERT(a)
void diagonal(const MatrixType &m)
#define VERIFY_IS_APPROX(a, b)
#define CALL_SUBTEST_1(FUNC)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
#define EIGEN_TEST_MAX_SIZE
EIGEN_DECLARE_TEST(diagonal)
#define CALL_SUBTEST_2(FUNC)
The matrix class, also used for vectors and row-vectors.