mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-10 23:21:47 +08:00
Fix compilation of stableNorm with some expressions as input
(grafted from 06bf1047f99afec61062e188ec4e68efbf203d86 )
This commit is contained in:
parent
bb28a2aada
commit
33b972d8b3
@ -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…
x
Reference in New Issue
Block a user