mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-03-01 18:26:24 +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::remove_all<DerivedCopy>::type DerivedCopyClean;
|
||||
DerivedCopy copy(derived());
|
||||
const DerivedCopy copy(derived());
|
||||
|
||||
enum {
|
||||
CanAlign = ( (int(DerivedCopyClean::Flags)&DirectAccessBit)
|
||||
|
@ -65,6 +65,8 @@ template<typename MatrixType> void stable_norm(const MatrixType& m)
|
||||
factor = internal::random<Scalar>();
|
||||
Scalar small = factor * ((std::numeric_limits<RealScalar>::min)() * RealScalar(1e4));
|
||||
|
||||
Scalar one(1);
|
||||
|
||||
MatrixType vzero = MatrixType::Zero(rows, cols),
|
||||
vrand = MatrixType::Random(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.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());
|
||||
|
||||
// test numext::isfinite
|
||||
|
Loading…
Reference in New Issue
Block a user