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;
121 VectorType
v1 = VectorType::Random(rows);
122 DynVectorType dv1 = DynVectorType::Random(depth);
123 DynRowVectorType drv1 = DynRowVectorType::Random(depth);
124 DynMatrixType dm1 = dv1;
125 DynMatrixType drm1 = drv1;
139 Matrix3Xd points = Matrix3Xd::Random(3, 3);
140 Vector2d
diag = Vector2d::Random();
141 Matrix2Xd tmp1 = points.topRows<2>(), res1, res2;
142 VERIFY_IS_APPROX( res1 = diag.asDiagonal() * points.topRows<2>(), res2 = diag.asDiagonal() * tmp1 );
143 Matrix2d tmp2 = points.topLeftCorner<2,2>();
144 VERIFY_IS_APPROX(( res1 = points.topLeftCorner<2,2>()*diag.asDiagonal()) , res2 = tmp2*diag.asDiagonal() );
165 CALL_SUBTEST_10( bug987<0>() );
Matrix diag(const std::vector< Matrix > &Hs)
void diagonal(const MatrixType &m)
Represents a diagonal matrix with its storage.
void as_scalar_product(const MatrixType &m)
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)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
#define EIGEN_TEST_MAX_SIZE
void test_diagonalmatrices()
The matrix class, also used for vectors and row-vectors.