mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-19 08:09:36 +08:00
Fix /= when using evaluator as in changeset 2d90484450f3934db3f5db39ef37967fb9444263
This commit is contained in:
parent
749b56f6af
commit
dfc54e1bbf
@ -212,17 +212,7 @@ template<typename Derived>
|
|||||||
inline Derived& DenseBase<Derived>::operator/=(const Scalar& other)
|
inline Derived& DenseBase<Derived>::operator/=(const Scalar& other)
|
||||||
{
|
{
|
||||||
typedef typename Derived::PlainObject PlainObject;
|
typedef typename Derived::PlainObject PlainObject;
|
||||||
|
internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::div_assign_op<Scalar>());
|
||||||
typedef typename internal::conditional<NumTraits<Scalar>::IsInteger,
|
|
||||||
internal::div_assign_op<Scalar>,
|
|
||||||
internal::mul_assign_op<Scalar> >::type AssignOp;
|
|
||||||
|
|
||||||
Scalar actual_other;
|
|
||||||
if(NumTraits<Scalar>::IsInteger) actual_other = other;
|
|
||||||
else actual_other = Scalar(1)/other;
|
|
||||||
|
|
||||||
internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),actual_other), AssignOp());
|
|
||||||
|
|
||||||
return derived();
|
return derived();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
static bool g_called;
|
static bool g_called;
|
||||||
|
|
||||||
#define EIGEN_SPECIAL_SCALAR_MULTIPLE_PLUGIN { g_called = true; }
|
#define EIGEN_SPECIAL_SCALAR_MULTIPLE_PLUGIN { g_called = true; }
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
@ -107,4 +106,19 @@ void test_linearstructure()
|
|||||||
CALL_SUBTEST_10( real_complex<Matrix4cd>() );
|
CALL_SUBTEST_10( real_complex<Matrix4cd>() );
|
||||||
CALL_SUBTEST_10( real_complex<MatrixXcf>(10,10) );
|
CALL_SUBTEST_10( real_complex<MatrixXcf>(10,10) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef EIGEN_TEST_PART_4
|
||||||
|
{
|
||||||
|
// make sure that /=scalar and /scalar do not overflow
|
||||||
|
// rational: 1.0/4.94e-320 overflow, but m/4.94e-320 should not
|
||||||
|
Matrix4d m2, m3;
|
||||||
|
m3 = m2 = Matrix4d::Random()*1e-20;
|
||||||
|
m2 = m2 / 4.9e-320;
|
||||||
|
VERIFY_IS_APPROX(m2.cwiseQuotient(m2), Matrix4d::Ones());
|
||||||
|
m3 /= 4.9e-320;
|
||||||
|
VERIFY_IS_APPROX(m3.cwiseQuotient(m3), Matrix4d::Ones());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user