15 enum { Rows = MatrixType::RowsAtCompileTime,
Cols = MatrixType::ColsAtCompileTime };
27 m2 = MatrixType::Random(rows, cols);
28 VectorType
v1 = VectorType::Random(rows),
29 v2 = VectorType::Random(rows);
30 RowVectorType rv1 = RowVectorType::Random(cols),
31 rv2 = RowVectorType::Random(cols);
33 LeftDiagonalMatrix ldm1(v1), ldm2(
v2);
34 RightDiagonalMatrix rdm1(rv1), rdm2(rv2);
36 Scalar s1 = internal::random<Scalar>();
38 SquareMatrixType sq_m1 (v1.asDiagonal());
40 sq_m1 = v1.asDiagonal();
42 SquareMatrixType sq_m2 = v1.asDiagonal();
45 ldm1 = v1.asDiagonal();
46 LeftDiagonalMatrix ldm3(v1);
48 LeftDiagonalMatrix ldm4 = v1.asDiagonal();
51 sq_m1.block(0,0,rows,rows) = ldm1;
53 sq_m1.transpose() = ldm1;
56 Index i = internal::random<Index>(0, rows-1);
57 Index j = internal::random<Index>(0, cols-1);
71 DynMatrixType tmp = m1.topRows(rows/2),
res;
73 VERIFY_IS_APPROX( (
res = v1.head(rows/2).asDiagonal()*m1.topRows(rows/2)), v1.head(rows/2).asDiagonal()*tmp );
77 big.setZero(2*rows, 2*cols);
79 big.block(i,j,rows,cols) =
m1;
80 big.block(i,j,rows,cols) = v1.asDiagonal() * big.block(i,j,rows,cols);
84 big.block(i,j,rows,cols) =
m1;
85 big.block(i,j,rows,cols) = big.block(i,j,rows,cols) * rv1.asDiagonal();
99 VERIFY_IS_APPROX( (sq_m1 += (s1*v1).asDiagonal()), sq_m2 += (s1*v1).asDiagonal().toDenseMatrix() );
100 VERIFY_IS_APPROX( (sq_m1 -= (s1*v1).asDiagonal()), sq_m2 -= (s1*v1).asDiagonal().toDenseMatrix() );
101 VERIFY_IS_APPROX( (sq_m1 = (s1*v1).asDiagonal()), (s1*v1).asDiagonal().toDenseMatrix() );
104 sq_m2 = v1.asDiagonal();
105 sq_m2 = sq_m1 * sq_m2;
109 sq_m1 = v1.asDiagonal();
110 sq_m2 =
v2.asDiagonal();
111 SquareMatrixType sq_m3 = v1.asDiagonal();
114 VERIFY_IS_APPROX( sq_m3 = v1.asDiagonal() - 2*
v2.asDiagonal() + v1.asDiagonal(), sq_m1 - 2*sq_m2 + sq_m1);
128 VectorType
v1 = VectorType::Random(rows);
129 DynVectorType dv1 = DynVectorType::Random(depth);
130 DynRowVectorType drv1 = DynRowVectorType::Random(depth);
131 DynMatrixType dm1 = dv1;
132 DynMatrixType drm1 = drv1;
146 Matrix3Xd points = Matrix3Xd::Random(3, 3);
147 Vector2d
diag = Vector2d::Random();
148 Matrix2Xd tmp1 = points.topRows<2>(), res1, res2;
149 VERIFY_IS_APPROX( res1 = diag.asDiagonal() * points.topRows<2>(), res2 = diag.asDiagonal() * tmp1 );
150 Matrix2d tmp2 = points.topLeftCorner<2,2>();
151 VERIFY_IS_APPROX(( res1 = points.topLeftCorner<2,2>()*diag.asDiagonal()) , res2 = tmp2*diag.asDiagonal() );
#define CALL_SUBTEST_9(FUNC)
#define CALL_SUBTEST_6(FUNC)
#define CALL_SUBTEST_4(FUNC)
Matrix diag(const std::vector< Matrix > &Hs)
#define CALL_SUBTEST_3(FUNC)
#define CALL_SUBTEST_7(FUNC)
void diagonal(const MatrixType &m)
Represents a diagonal matrix with its storage.
void as_scalar_product(const MatrixType &m)
#define CALL_SUBTEST_10(FUNC)
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
void diagonalmatrices(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 CALL_SUBTEST_8(FUNC)
#define CALL_SUBTEST_5(FUNC)
#define EIGEN_TEST_MAX_SIZE
EIGEN_DECLARE_TEST(diagonalmatrices)
#define CALL_SUBTEST_2(FUNC)
The matrix class, also used for vectors and row-vectors.