diff options
Diffstat (limited to 'extern/Eigen3/Eigen/src/SparseCore/SparseFuzzy.h')
-rw-r--r-- | extern/Eigen3/Eigen/src/SparseCore/SparseFuzzy.h | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/extern/Eigen3/Eigen/src/SparseCore/SparseFuzzy.h b/extern/Eigen3/Eigen/src/SparseCore/SparseFuzzy.h index 45f36e9eb90..7d47eb94d2f 100644 --- a/extern/Eigen3/Eigen/src/SparseCore/SparseFuzzy.h +++ b/extern/Eigen3/Eigen/src/SparseCore/SparseFuzzy.h @@ -1,7 +1,7 @@ // This file is part of Eigen, a lightweight C++ template library // for linear algebra. // -// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr> +// Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr> // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed @@ -10,17 +10,20 @@ #ifndef EIGEN_SPARSE_FUZZY_H #define EIGEN_SPARSE_FUZZY_H -// template<typename Derived> -// template<typename OtherDerived> -// bool SparseMatrixBase<Derived>::isApprox( -// const OtherDerived& other, -// typename NumTraits<Scalar>::Real prec -// ) const -// { -// const typename internal::nested<Derived,2>::type nested(derived()); -// const typename internal::nested<OtherDerived,2>::type otherNested(other.derived()); -// return (nested - otherNested).cwise().abs2().sum() -// <= prec * prec * (std::min)(nested.cwise().abs2().sum(), otherNested.cwise().abs2().sum()); -// } +namespace Eigen { + +template<typename Derived> +template<typename OtherDerived> +bool SparseMatrixBase<Derived>::isApprox(const SparseMatrixBase<OtherDerived>& other, const RealScalar &prec) const +{ + const typename internal::nested_eval<Derived,2,PlainObject>::type actualA(derived()); + typename internal::conditional<bool(IsRowMajor)==bool(OtherDerived::IsRowMajor), + const typename internal::nested_eval<OtherDerived,2,PlainObject>::type, + const PlainObject>::type actualB(other.derived()); + + return (actualA - actualB).squaredNorm() <= prec * prec * numext::mini(actualA.squaredNorm(), actualB.squaredNorm()); +} + +} // end namespace Eigen #endif // EIGEN_SPARSE_FUZZY_H |