13 template<
typename Derived1,
typename Derived2>
30 typedef Matrix<
Scalar, MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime,
38 MatrixType m1 = MatrixType::Random(rows, cols),
39 m2 = MatrixType::Random(rows, cols),
42 identity = RowSquareMatrixType::Identity(rows, rows),
43 square = RowSquareMatrixType::Random(rows, rows),
44 res = RowSquareMatrixType::Random(rows, rows);
46 square2 = ColSquareMatrixType::Random(cols, cols),
47 res2 = ColSquareMatrixType::Random(cols, cols);
48 RowVectorType
v1 = RowVectorType::Random(rows);
49 ColVectorType vc2 = ColVectorType::Random(cols), vcres(cols);
50 OtherMajorMatrixType tm1 =
m1;
52 Scalar s1 = internal::random<Scalar>();
54 Index r = internal::random<Index>(0, rows-1),
55 c = internal::random<Index>(0, cols-1),
56 c2 = internal::random<Index>(0, cols-1);
62 m3 *= m1.transpose() *
m2;
92 res.noalias() += m1 * m2.transpose();
99 vcres.noalias() += m1.transpose() *
v1;
104 res.noalias() -= m1 * m2.transpose();
111 vcres.noalias() -= m1.transpose() *
v1;
116 res.noalias() = s1 * m1 * m2.transpose();
119 res.noalias() += s1 * m1 * m2.transpose();
122 res.noalias() -= s1 * m1 * m2.transpose();
126 res.noalias() = square + m1 * m2.transpose();
128 res.noalias() += square + m1 * m2.transpose();
130 res.noalias() -= square + m1 * m2.transpose();
134 res.noalias() = square - m1 * m2.transpose();
136 res.noalias() += square - m1 * m2.transpose();
138 res.noalias() -= square - m1 * m2.transpose();
148 res.row(
i) = m1.row(
i) * m2.transpose();
152 res.col(
i) = m1 * m2.transpose().col(
i);
156 res2.noalias() += m1.transpose() *
m2;
163 VERIFY_IS_APPROX(res.col(r).noalias() = square.adjoint() * square.col(r), (square.adjoint() * square.col(r)).
eval());
164 VERIFY_IS_APPROX(res.col(r).noalias() = square * square.col(r), (square * square.col(r)).
eval());
168 RowSquareMatrixType
ref(square);
169 ColSquareMatrixType ref2(square2);
171 VERIFY_IS_APPROX(res.block(0,0,1,rows).noalias() = m1.col(0).transpose() * square.transpose(), (ref.row(0) = m1.col(0).transpose() * square.transpose()));
172 VERIFY_IS_APPROX(res.block(0,0,1,rows).noalias() = m1.block(0,0,rows,1).transpose() * square.transpose(), (ref.row(0) = m1.col(0).transpose() * square.transpose()));
174 VERIFY_IS_APPROX(res.block(0,0,1,rows).noalias() = m1.block(0,0,rows,1).transpose() *
square, (ref.row(0) = m1.col(0).transpose() *
square));
175 ref2 = res2 = square2;
176 VERIFY_IS_APPROX(res2.block(0,0,1,cols).noalias() = m1.row(0) * square2.transpose(), (ref2.row(0) = m1.row(0) * square2.transpose()));
177 VERIFY_IS_APPROX(res2.block(0,0,1,cols).noalias() = m1.block(0,0,1,cols) * square2.transpose(), (ref2.row(0) = m1.row(0) * square2.transpose()));
178 VERIFY_IS_APPROX(res2.block(0,0,1,cols).noalias() = m1.row(0) * square2, (ref2.row(0) = m1.row(0) * square2));
179 VERIFY_IS_APPROX(res2.block(0,0,1,cols).noalias() = m1.block(0,0,1,cols) * square2, (ref2.row(0) = m1.row(0) * square2));
184 RowVectorType w1(rows);
187 VERIFY_IS_APPROX(w1.block(0,0,rows,1).noalias() = square * v1.block(0,0,rows,1), square *
v1);
190 VERIFY_IS_APPROX(vc2.block(0,0,cols,1).transpose() * square2, vc2.transpose() * square2);
191 VERIFY_IS_APPROX(w2.noalias() = vc2.block(0,0,cols,1).transpose() * square2, vc2.transpose() * square2);
192 VERIFY_IS_APPROX(w2.block(0,0,1,cols).noalias() = vc2.block(0,0,cols,1).transpose() * square2, vc2.transpose() * square2);
194 vc2 = square2.block(0,0,1,cols).transpose();
195 VERIFY_IS_APPROX(square2.block(0,0,1,cols) * square2, vc2.transpose() * square2);
196 VERIFY_IS_APPROX(w2.noalias() = square2.block(0,0,1,cols) * square2, vc2.transpose() * square2);
197 VERIFY_IS_APPROX(w2.block(0,0,1,cols).noalias() = square2.block(0,0,1,cols) * square2, vc2.transpose() * square2);
199 vc2 = square2.block(0,0,cols,1);
200 VERIFY_IS_APPROX(square2.block(0,0,cols,1).transpose() * square2, vc2.transpose() * square2);
201 VERIFY_IS_APPROX(w2.noalias() = square2.block(0,0,cols,1).transpose() * square2, vc2.transpose() * square2);
202 VERIFY_IS_APPROX(w2.block(0,0,1,cols).noalias() = square2.block(0,0,cols,1).transpose() * square2, vc2.transpose() * square2);
207 Scalar
x = square2.row(
c) * square2.col(c2);
208 VERIFY_IS_APPROX(x, square2.row(
c).transpose().cwiseProduct(square2.col(c2)).sum());
214 VERIFY_IS_APPROX(m1.row(r).transpose() * m1.col(
c).transpose(), m1.block(r,0,1,cols).transpose() * m1.block(0,
c,rows,1).transpose());
215 VERIFY_IS_APPROX(m1.block(0,
c,rows,1) * m1.row(r), m1.block(0,
c,rows,1) * m1.block(r,0,1,cols));
216 VERIFY_IS_APPROX(m1.col(
c) * m1.block(r,0,1,cols), m1.block(0,
c,rows,1) * m1.block(r,0,1,cols));
217 VERIFY_IS_APPROX(m1.leftCols(1) * m1.row(r), m1.block(0,0,rows,1) * m1.block(r,0,1,cols));
218 VERIFY_IS_APPROX(m1.col(
c) * m1.topRows(1), m1.block(0,
c,rows,1) * m1.block(0,0,1,cols));
223 ColVectorType
x(cols); x.setRandom();
225 ColVectorType
y(cols); y.setZero();
226 ColSquareMatrixType
A(cols,cols); A.setRandom();
238 VERIFY_IS_APPROX(square * (square*square).transpose(), square * square.transpose() * square.transpose());
240 VERIFY_IS_APPROX(square * (s1*(square*square)), s1 * square * square * square);
246 if(!MatrixType::IsRowMajor)
249 MatrixX
buffer(2*rows,2*rows);
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseAbs2ReturnType cwiseAbs2() const
bool areNotApprox(const MatrixBase< Derived1 > &m1, const MatrixBase< Derived2 > &m2, typename Derived1::RealScalar epsilon=NumTraits< typename Derived1::RealScalar >::dummy_precision())
#define VERIFY_RAISES_ASSERT(a)
A matrix or vector expression mapping an existing array of data.
Holds strides information for Map.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
const unsigned int RowMajorBit
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
#define VERIFY_IS_APPROX(a, b)
EIGEN_DEVICE_FUNC const SquareReturnType square() const
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
EIGEN_DEVICE_FUNC ConjugateReturnType conjugate() const
NumTraits< Scalar >::Real RealScalar
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseAbs2ReturnType cwiseAbs2() const
internal::nested_eval< T, 1 >::type eval(const T &xpr)
The matrix class, also used for vectors and row-vectors.
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Base class for all dense matrices, vectors, and expressions.
void product(const MatrixType &m)