// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com> // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// a very tricky case where a scale factor has to be automatically conjugated:
VERIFY_IS_APPROX( m1.adjoint() * (s1*m2).conjugate(), (m1.adjoint()).eval() * ((s1*m2).conjugate()).eval());
// test all possible conjugate combinations for the four matrix-vector product cases:
// test the vector-matrix product with non aligned starts
Index i = internal::random<Index>(0,m1.rows()-2);
Index j = internal::random<Index>(0,m1.cols()-2);
Index r = internal::random<Index>(1,m1.rows()-i);
Index c = internal::random<Index>(1,m1.cols()-j);
Index i2 = internal::random<Index>(0,m1.rows()-1);
Index j2 = internal::random<Index>(0,m1.cols()-1);
template<int> void bug_127()
{ // Bug 127 // // a product of the form lhs*rhs with // // lhs: // rows = 1, cols = 4 // RowsAtCompileTime = 1, ColsAtCompileTime = -1 // MaxRowsAtCompileTime = 1, MaxColsAtCompileTime = 5 // // rhs: // rows = 4, cols = 0 // RowsAtCompileTime = -1, ColsAtCompileTime = -1 // MaxRowsAtCompileTime = 5, MaxColsAtCompileTime = 1 // // was failing on a runtime assertion, because it had been mis-compiled as a dot product because Product.h was using the // max-sizes to detect size 1 indicating vectors, and that didn't account for 0-sized object with max-size 1.
template<int> void bug_817()
{
ArrayXXf B = ArrayXXf::Random(10,10), C;
VectorXf x = VectorXf::Random(10);
C = (x.transpose()*B.matrix());
B = (x.transpose()*B.matrix());
VERIFY_IS_APPROX(B,C);
}
template<int> void unaligned_objects()
{ // Regression test for the bug reported here: // http://forum.kde.org/viewtopic.php?f=74&t=107541 // Recall the matrix*vector kernel avoid unaligned loads by loading two packets and then reassemble then. // There was a mistake in the computation of the valid range for fully unaligned objects: in some rare cases, // memory was read outside the allocated matrix memory. Though the values were not used, this might raise segfault. for(int m=450;m<460;++m)
{ for(int n=8;n<12;++n)
{
MatrixXf M(m, n);
VectorXf v1(n), r1(500);
RowVectorXf v2(m), r2(16);
M.setRandom();
v1.setRandom();
v2.setRandom(); for(int o=0; o<4; ++o)
{
r1.segment(o,m).noalias() = M * v1;
VERIFY_IS_APPROX(r1.segment(o,m), M * MatrixXf(v1));
r2.segment(o,n).noalias() = v2 * M;
VERIFY_IS_APPROX(r2.segment(o,n), MatrixXf(v2) * M);
}
}
}
}
template<typename T>
EIGEN_DONT_INLINE
Index test_compute_block_size(Index m, Index n, Index k)
{
Index mc(m), nc(n), kc(k);
internal::computeProductBlockingSizes<T,T>(kc, mc, nc); return kc+mc+nc;
}
template<typename T>
Index compute_block_size()
{
Index ret = 0;
ret += test_compute_block_size<T>(0,1,1);
ret += test_compute_block_size<T>(1,0,1);
ret += test_compute_block_size<T>(1,1,0);
ret += test_compute_block_size<T>(0,0,1);
ret += test_compute_block_size<T>(0,1,0);
ret += test_compute_block_size<T>(1,0,0);
ret += test_compute_block_size<T>(0,0,0); return ret;
}
template<typename> void aliasing_with_resize()
{
Index m = internal::random<Index>(10,50);
Index n = internal::random<Index>(10,50);
MatrixXd A, B, C(m,n), D(m,m);
VectorXd a, b, c(n);
C.setRandom();
D.setRandom();
c.setRandom(); double s = internal::random<double>(1,10);
A = C;
B = A * A.transpose();
A = A * A.transpose();
VERIFY_IS_APPROX(A,B);
A = C;
B = (A * A.transpose())/s;
A = (A * A.transpose())/s;
VERIFY_IS_APPROX(A,B);
A = C;
B = (A * A.transpose()) + D;
A = (A * A.transpose()) + D;
VERIFY_IS_APPROX(A,B);
A = C;
B = D + (A * A.transpose());
A = D + (A * A.transpose());
VERIFY_IS_APPROX(A,B);
A = C;
B = s * (A * A.transpose());
A = s * (A * A.transpose());
VERIFY_IS_APPROX(A,B);
A = C;
a = c;
b = (A * a)/s;
a = (A * a)/s;
VERIFY_IS_APPROX(a,b);
}
template<int> void bug_1308()
{ int n = 10;
MatrixXd r(n,n);
VectorXd v = VectorXd::Random(n);
r = v * RowVectorXd::Ones(n);
VERIFY_IS_APPROX(r, v.rowwise().replicate(n));
r = VectorXd::Ones(n) * v.transpose();
VERIFY_IS_APPROX(r, v.rowwise().replicate(n).transpose());
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.14Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.