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;
115 res.noalias() = square + m1 * m2.transpose();
117 res.noalias() += square + m1 * m2.transpose();
119 res.noalias() -= square + m1 * m2.transpose();
123 res.noalias() = square - m1 * m2.transpose();
125 res.noalias() += square - m1 * m2.transpose();
127 res.noalias() -= square - m1 * m2.transpose();
137 res.row(
i) = m1.row(
i) * m2.transpose();
141 res.col(
i) = m1 * m2.transpose().col(
i);
145 res2.noalias() += m1.transpose() *
m2;
152 VERIFY_IS_APPROX(res.col(r).noalias() = square.adjoint() * square.col(r), (square.adjoint() * square.col(r)).
eval());
153 VERIFY_IS_APPROX(res.col(r).noalias() = square * square.col(r), (square * square.col(r)).
eval());
157 RowSquareMatrixType
ref(square);
158 ColSquareMatrixType ref2(square2);
160 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()));
161 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()));
163 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));
164 ref2 = res2 = square2;
165 VERIFY_IS_APPROX(res2.block(0,0,1,cols).noalias() = m1.row(0) * square2.transpose(), (ref2.row(0) = m1.row(0) * square2.transpose()));
166 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()));
167 VERIFY_IS_APPROX(res2.block(0,0,1,cols).noalias() = m1.row(0) * square2, (ref2.row(0) = m1.row(0) * square2));
168 VERIFY_IS_APPROX(res2.block(0,0,1,cols).noalias() = m1.block(0,0,1,cols) * square2, (ref2.row(0) = m1.row(0) * square2));
173 RowVectorType w1(rows);
176 VERIFY_IS_APPROX(w1.block(0,0,rows,1).noalias() = square * v1.block(0,0,rows,1), square *
v1);
179 VERIFY_IS_APPROX(vc2.block(0,0,cols,1).transpose() * square2, vc2.transpose() * square2);
180 VERIFY_IS_APPROX(w2.noalias() = vc2.block(0,0,cols,1).transpose() * square2, vc2.transpose() * square2);
181 VERIFY_IS_APPROX(w2.block(0,0,1,cols).noalias() = vc2.block(0,0,cols,1).transpose() * square2, vc2.transpose() * square2);
183 vc2 = square2.block(0,0,1,cols).transpose();
184 VERIFY_IS_APPROX(square2.block(0,0,1,cols) * square2, vc2.transpose() * square2);
185 VERIFY_IS_APPROX(w2.noalias() = square2.block(0,0,1,cols) * square2, vc2.transpose() * square2);
186 VERIFY_IS_APPROX(w2.block(0,0,1,cols).noalias() = square2.block(0,0,1,cols) * square2, vc2.transpose() * square2);
188 vc2 = square2.block(0,0,cols,1);
189 VERIFY_IS_APPROX(square2.block(0,0,cols,1).transpose() * square2, vc2.transpose() * square2);
190 VERIFY_IS_APPROX(w2.noalias() = square2.block(0,0,cols,1).transpose() * square2, vc2.transpose() * square2);
191 VERIFY_IS_APPROX(w2.block(0,0,1,cols).noalias() = square2.block(0,0,cols,1).transpose() * square2, vc2.transpose() * square2);
196 Scalar
x = square2.row(
c) * square2.col(
c2);
203 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());
204 VERIFY_IS_APPROX(m1.block(0,
c,rows,1) * m1.row(r), m1.block(0,
c,rows,1) * m1.block(r,0,1,cols));
205 VERIFY_IS_APPROX(m1.col(
c) * m1.block(r,0,1,cols), m1.block(0,
c,rows,1) * m1.block(r,0,1,cols));
206 VERIFY_IS_APPROX(m1.leftCols(1) * m1.row(r), m1.block(0,0,rows,1) * m1.block(r,0,1,cols));
207 VERIFY_IS_APPROX(m1.col(
c) * m1.topRows(1), m1.block(0,
c,rows,1) * m1.block(0,0,1,cols));
212 ColVectorType
x(cols); x.setRandom();
214 ColVectorType
y(cols); y.setZero();
215 ColSquareMatrixType
A(cols,cols); A.setRandom();
225 VERIFY_IS_APPROX(square * (square*square).transpose(), square * square.transpose() * square.transpose());
227 VERIFY_IS_APPROX(square * (s1*(square*square)), s1 * square * square * square);
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)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseAbs2ReturnType cwiseAbs2() const
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Matrix< SCALARA, Dynamic, Dynamic > 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 ConjugateReturnType conjugate() const
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
const mpreal sum(const mpreal tab[], const unsigned long int n, int &status, mp_rnd_t mode=mpreal::get_default_rnd())
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.
EIGEN_DEVICE_FUNC const SquareReturnType square() const
void product(const MatrixType &m)