mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-13 00:21:49 +08:00
Workaround weird MSVC bug
(grafted from 4b2cebade8512abe05e94fd08ef901d818d8912b )
This commit is contained in:
parent
40ddac243e
commit
a2d6c106a4
@ -180,8 +180,10 @@ public:
|
||||
RealScalar threshold() const
|
||||
{
|
||||
eigen_assert(m_isInitialized || m_usePrescribedThreshold);
|
||||
// this temporary is needed to workaround a MSVC issue
|
||||
Index diagSize = (std::max<Index>)(1,m_diagSize);
|
||||
return m_usePrescribedThreshold ? m_prescribedThreshold
|
||||
: (std::max<Index>)(1,m_diagSize)*NumTraits<Scalar>::epsilon();
|
||||
: diagSize*NumTraits<Scalar>::epsilon();
|
||||
}
|
||||
|
||||
/** \returns true if \a U (full or thin) is asked for in this SVD decomposition */
|
||||
|
@ -69,6 +69,19 @@ void jacobisvd_method()
|
||||
VERIFY_IS_APPROX(m.jacobiSvd(ComputeFullU|ComputeFullV).solve(m), m);
|
||||
}
|
||||
|
||||
namespace Foo {
|
||||
class Bar {};
|
||||
bool operator<(const Bar&, const Bar&) { return true; }
|
||||
}
|
||||
// regression test for a very strange MSVC issue for which simply
|
||||
// including SVDBase.h messes up with std::max and custom scalar type
|
||||
void msvc_workaround()
|
||||
{
|
||||
const Foo::Bar a;
|
||||
const Foo::Bar b;
|
||||
std::max EIGEN_NOT_A_MACRO (a,b);
|
||||
}
|
||||
|
||||
void test_jacobisvd()
|
||||
{
|
||||
CALL_SUBTEST_3(( jacobisvd_verify_assert(Matrix3f()) ));
|
||||
@ -122,4 +135,6 @@ void test_jacobisvd()
|
||||
CALL_SUBTEST_9( svd_preallocate<void>() );
|
||||
|
||||
CALL_SUBTEST_2( svd_underoverflow<void>() );
|
||||
|
||||
msvc_workaround();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user