mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-20 08:39:37 +08:00
Bug fix for matrix1 * matrix2 * scalar1 * scalar2.
See report on http://forum.kde.org/viewtopic.php?f=74&t=96947 .
This commit is contained in:
parent
16b13596a6
commit
2092b45d0d
@ -256,16 +256,16 @@ class ScaledProduct
|
|||||||
: Base(prod.lhs(),prod.rhs()), m_prod(prod), m_alpha(x) {}
|
: Base(prod.lhs(),prod.rhs()), m_prod(prod), m_alpha(x) {}
|
||||||
|
|
||||||
template<typename Dest>
|
template<typename Dest>
|
||||||
inline void evalTo(Dest& dst) const { dst.setZero(); scaleAndAddTo(dst,m_alpha); }
|
inline void evalTo(Dest& dst) const { dst.setZero(); scaleAndAddTo(dst, Scalar(1)); }
|
||||||
|
|
||||||
template<typename Dest>
|
template<typename Dest>
|
||||||
inline void addTo(Dest& dst) const { scaleAndAddTo(dst,m_alpha); }
|
inline void addTo(Dest& dst) const { scaleAndAddTo(dst, Scalar(1)); }
|
||||||
|
|
||||||
template<typename Dest>
|
template<typename Dest>
|
||||||
inline void subTo(Dest& dst) const { scaleAndAddTo(dst,-m_alpha); }
|
inline void subTo(Dest& dst) const { scaleAndAddTo(dst, Scalar(-1)); }
|
||||||
|
|
||||||
template<typename Dest>
|
template<typename Dest>
|
||||||
inline void scaleAndAddTo(Dest& dst,Scalar alpha) const { m_prod.derived().scaleAndAddTo(dst,alpha); }
|
inline void scaleAndAddTo(Dest& dst,Scalar alpha) const { m_prod.derived().scaleAndAddTo(dst,alpha * m_alpha); }
|
||||||
|
|
||||||
const Scalar& alpha() const { return m_alpha; }
|
const Scalar& alpha() const { return m_alpha; }
|
||||||
|
|
||||||
|
@ -116,6 +116,16 @@ template<typename MatrixType> void product_extra(const MatrixType& m)
|
|||||||
VERIFY_IS_APPROX(tmp, m1 * m1.adjoint() * s1);
|
VERIFY_IS_APPROX(tmp, m1 * m1.adjoint() * s1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Regression test for bug reported at http://forum.kde.org/viewtopic.php?f=74&t=96947
|
||||||
|
void mat_mat_scalar_scalar_product()
|
||||||
|
{
|
||||||
|
Eigen::Matrix2Xd dNdxy(2, 3);
|
||||||
|
dNdxy << -0.5, 0.5, 0,
|
||||||
|
-0.3, 0, 0.3;
|
||||||
|
double det = 6.0, wt = 0.5;
|
||||||
|
VERIFY_IS_APPROX(dNdxy.transpose()*dNdxy*det*wt, det*wt*dNdxy.transpose()*dNdxy);
|
||||||
|
}
|
||||||
|
|
||||||
void zero_sized_objects()
|
void zero_sized_objects()
|
||||||
{
|
{
|
||||||
// Bug 127
|
// Bug 127
|
||||||
@ -145,6 +155,7 @@ void test_product_extra()
|
|||||||
for(int i = 0; i < g_repeat; i++) {
|
for(int i = 0; i < g_repeat; i++) {
|
||||||
CALL_SUBTEST_1( product_extra(MatrixXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
CALL_SUBTEST_1( product_extra(MatrixXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||||
CALL_SUBTEST_2( product_extra(MatrixXd(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
CALL_SUBTEST_2( product_extra(MatrixXd(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||||
|
CALL_SUBTEST_2( mat_mat_scalar_scalar_product() );
|
||||||
CALL_SUBTEST_3( product_extra(MatrixXcf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2), internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2))) );
|
CALL_SUBTEST_3( product_extra(MatrixXcf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2), internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2))) );
|
||||||
CALL_SUBTEST_4( product_extra(MatrixXcd(internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2), internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2))) );
|
CALL_SUBTEST_4( product_extra(MatrixXcd(internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2), internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2))) );
|
||||||
CALL_SUBTEST_5( zero_sized_objects() );
|
CALL_SUBTEST_5( zero_sized_objects() );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user