mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Fix compilation of stableNorm with some expressions as input
This commit is contained in:
parent
73214c4bd0
commit
06bf1047f9
@ -165,7 +165,7 @@ MatrixBase<Derived>::stableNorm() const
|
|||||||
|
|
||||||
typedef typename internal::nested_eval<Derived,2>::type DerivedCopy;
|
typedef typename internal::nested_eval<Derived,2>::type DerivedCopy;
|
||||||
typedef typename internal::remove_all<DerivedCopy>::type DerivedCopyClean;
|
typedef typename internal::remove_all<DerivedCopy>::type DerivedCopyClean;
|
||||||
DerivedCopy copy(derived());
|
const DerivedCopy copy(derived());
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
CanAlign = ( (int(DerivedCopyClean::Flags)&DirectAccessBit)
|
CanAlign = ( (int(DerivedCopyClean::Flags)&DirectAccessBit)
|
||||||
|
@ -65,6 +65,8 @@ template<typename MatrixType> void stable_norm(const MatrixType& m)
|
|||||||
factor = internal::random<Scalar>();
|
factor = internal::random<Scalar>();
|
||||||
Scalar small = factor * ((std::numeric_limits<RealScalar>::min)() * RealScalar(1e4));
|
Scalar small = factor * ((std::numeric_limits<RealScalar>::min)() * RealScalar(1e4));
|
||||||
|
|
||||||
|
Scalar one(1);
|
||||||
|
|
||||||
MatrixType vzero = MatrixType::Zero(rows, cols),
|
MatrixType vzero = MatrixType::Zero(rows, cols),
|
||||||
vrand = MatrixType::Random(rows, cols),
|
vrand = MatrixType::Random(rows, cols),
|
||||||
vbig(rows, cols),
|
vbig(rows, cols),
|
||||||
@ -78,6 +80,14 @@ template<typename MatrixType> void stable_norm(const MatrixType& m)
|
|||||||
VERIFY_IS_APPROX(vrand.blueNorm(), vrand.norm());
|
VERIFY_IS_APPROX(vrand.blueNorm(), vrand.norm());
|
||||||
VERIFY_IS_APPROX(vrand.hypotNorm(), vrand.norm());
|
VERIFY_IS_APPROX(vrand.hypotNorm(), vrand.norm());
|
||||||
|
|
||||||
|
// test with expressions as input
|
||||||
|
VERIFY_IS_APPROX((one*vrand).stableNorm(), vrand.norm());
|
||||||
|
VERIFY_IS_APPROX((one*vrand).blueNorm(), vrand.norm());
|
||||||
|
VERIFY_IS_APPROX((one*vrand).hypotNorm(), vrand.norm());
|
||||||
|
VERIFY_IS_APPROX((one*vrand+one*vrand-one*vrand).stableNorm(), vrand.norm());
|
||||||
|
VERIFY_IS_APPROX((one*vrand+one*vrand-one*vrand).blueNorm(), vrand.norm());
|
||||||
|
VERIFY_IS_APPROX((one*vrand+one*vrand-one*vrand).hypotNorm(), vrand.norm());
|
||||||
|
|
||||||
RealScalar size = static_cast<RealScalar>(m.size());
|
RealScalar size = static_cast<RealScalar>(m.size());
|
||||||
|
|
||||||
// test numext::isfinite
|
// test numext::isfinite
|
||||||
|
Loading…
x
Reference in New Issue
Block a user