10 #ifndef EIGEN_STABLENORM_H 11 #define EIGEN_STABLENORM_H 17 template<
typename ExpressionType,
typename Scalar>
20 Scalar maxCoeff = bl.cwiseAbs().maxCoeff();
29 scale =
Scalar(1)/invScale;
42 else if(maxCoeff!=maxCoeff)
50 ssq += (bl*invScale).squaredNorm();
53 template<
typename Derived>
61 const Derived& vec(_vec.
derived());
62 static bool initialized =
false;
63 static RealScalar b1, b2, s1m, s2m, rbig, relerr;
66 int ibeta, it, iemin, iemax, iexp;
77 it = std::numeric_limits<RealScalar>::digits;
78 iemin = std::numeric_limits<RealScalar>::min_exponent;
79 iemax = std::numeric_limits<RealScalar>::max_exponent;
82 iexp = -((1-iemin)/2);
84 iexp = (iemax + 1 - it)/2;
89 iexp = - ((iemax+it)/2);
101 for(
typename Derived::InnerIterator it(vec, 0); it; ++it)
103 RealScalar ax =
abs(it.value());
128 amed =
sqrt(asml) / s1m;
131 return sqrt(asml)/s1m;
137 if(asml <= abig*relerr)
155 template<
typename Derived>
161 const Index blockSize = 4096;
168 const DerivedCopy
copy(derived());
181 return abs(this->coeff(0));
186 for (; bi<
n; bi+=blockSize)
188 return scale *
sqrt(ssq);
200 template<
typename Derived>
212 template<
typename Derived>
221 #endif // EIGEN_STABLENORM_H
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half pow(const half &a, const half &b)
RealScalar blueNorm() const
const unsigned int DirectAccessBit
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
void stable_norm_kernel(const ExpressionType &bl, Scalar &ssq, Scalar &scale, Scalar &invScale)
static constexpr size_t size(Tuple< Args... > &)
Provides access to the number of elements in a tuple as a compile-time constant expression.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T maxi(const T &x, const T &y)
RealScalar stableNorm() const
static Index first_default_aligned(const DenseBase< Derived > &m)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const AbsReturnType abs() const
NumTraits< Scalar >::Real RealScalar
NumTraits< typename traits< Derived >::Scalar >::Real blueNorm_impl(const EigenBase< Derived > &_vec)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Abs2ReturnType abs2() const
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
const VectorBlock< const Derived > ConstSegmentReturnType
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)
NumTraits< Scalar >::Real RealScalar
#define EIGEN_MAX_STATIC_ALIGN_BYTES
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseAbsReturnType cwiseAbs() const
#define EIGEN_STACK_ALLOCATION_LIMIT
int EIGEN_BLAS_FUNC() copy(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
EIGEN_DEVICE_FUNC Derived & derived()
RealScalar hypotNorm() const