10#ifndef EIGEN_RANDCOLPIVOTINGHOUSEHOLDERQR_H
11#define EIGEN_RANDCOLPIVOTINGHOUSEHOLDERQR_H
16#include "./InternalHeaderCheck.h"
22template <
typename MatrixType_,
typename PermutationIndex_>
23struct traits<RandColPivHouseholderQR<MatrixType_, PermutationIndex_>> : traits<MatrixType_> {
24 using XprKind = MatrixXpr;
25 using StorageKind = SolverStorage;
26 using PermutationIndex = PermutationIndex_;
31template <
typename Derived,
typename Engine>
32EIGEN_STRONG_INLINE std::enable_if_t<!NumTraits<typename Derived::Scalar>::IsComplex> fill_gaussian(
33 MatrixBase<Derived>& mat, Engine& engine) {
34 using Scalar =
typename Derived::Scalar;
35 std::normal_distribution<Scalar> dist(Scalar(0), Scalar(1));
36 for (Index j = 0; j < mat.cols(); ++j)
37 for (Index i = 0; i < mat.rows(); ++i) mat.coeffRef(i, j) = dist(engine);
42template <
typename Derived,
typename Engine>
43EIGEN_STRONG_INLINE std::enable_if_t<NumTraits<typename Derived::Scalar>::IsComplex> fill_gaussian(
44 MatrixBase<Derived>& mat, Engine& engine) {
45 using Scalar =
typename Derived::Scalar;
46 using RealScalar =
typename NumTraits<Scalar>::Real;
47 std::normal_distribution<RealScalar> dist(RealScalar(0), RealScalar(1));
48 for (Index j = 0; j < mat.cols(); ++j)
49 for (Index i = 0; i < mat.rows(); ++i) mat.coeffRef(i, j) = Scalar(dist(engine), dist(engine));
57template <
typename RealScalar,
typename Scalar,
typename RecomputeFn>
58EIGEN_STRONG_INLINE
void lawn176_norm_downdate(RealScalar& norm_updated, RealScalar& norm_direct, Scalar pivot_entry,
59 RealScalar downdate_threshold, RecomputeFn&& tail_norm_fn) {
60 if (numext::is_exactly_zero(norm_updated))
return;
61 RealScalar t = numext::abs(pivot_entry) / norm_updated;
62 t = (RealScalar(1) + t) * (RealScalar(1) - t);
63 if (t < RealScalar(0)) t = RealScalar(0);
64 RealScalar t2 = t * numext::abs2<RealScalar>(norm_updated / norm_direct);
65 if (t2 <= downdate_threshold) {
66 norm_direct = tail_norm_fn();
67 norm_updated = norm_direct;
69 norm_updated *= numext::sqrt(t);
131template <
typename MatrixType_,
typename PermutationIndex_>
133 public RankRevealingBase<RandColPivHouseholderQR<MatrixType_, PermutationIndex_>> {
135 using MatrixType = MatrixType_;
137 using RankRevealingBase_ = RankRevealingBase<RandColPivHouseholderQR>;
149 using PermutationIndex = PermutationIndex_;
153 MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
154 MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
156 using HCoeffsType =
typename internal::plain_diag_type<MatrixType>::type;
158 using IntRowVectorType =
typename internal::plain_row_type<MatrixType, PermutationIndex>::type;
159 using RowVectorType =
typename internal::plain_row_type<MatrixType>::type;
160 using RealRowVectorType =
typename internal::plain_row_type<MatrixType, RealScalar>::type;
161 using HouseholderSequenceType =
163 using PlainObject =
typename MatrixType::PlainObject;
168 static constexpr Index kAutoBlockSize = 0;
172 static constexpr Index kKernelFloor = 48;
174 static constexpr Index kBlockCeiling = 1024;
184 static constexpr Index kAutoBlockedPathMinSize = 192;
189 static Index defaultL2Bytes() {
190 std::ptrdiff_t l1, l2, l3;
191 internal::manage_caching_sizes(GetAction, &l1, &l2, &l3);
216 static Index computeAutoBlockSize(Index rows, Index
size) {
221 if (rows <= 0 ||
size <= 0)
return Index(0);
222 const Index scalar_bytes = Index(
sizeof(Scalar));
223 const Index b_cache = numext::maxi(Index(1), (defaultL2Bytes() / Index(2)) / (rows * scalar_bytes));
224 const Index b_bqrrp =
size / Index(32);
226 Index b = numext::maxi(Index(kKernelFloor), b_bqrrp);
227 b = numext::mini(b, numext::maxi(Index(kKernelFloor), b_cache));
228 b = numext::mini(b, Index(kBlockCeiling));
232 void init(Index rows, Index cols) {
233 Index diag = numext::mini(rows, cols);
234 m_hCoeffs.resize(diag);
235 m_colsPermutation.resize(cols);
237 m_isInitialized =
false;
248 template <
typename InputType>
255 template <
typename InputType>
261#ifdef EIGEN_PARSED_BY_DOXYGEN
262 template <
typename Rhs>
266 HouseholderSequenceType householderQ()
const;
267 HouseholderSequenceType matrixQ()
const {
return householderQ(); }
269 const MatrixType& matrixQR()
const {
270 eigen_assert(m_isInitialized &&
"RandColPivHouseholderQR is not initialized.");
274 const MatrixType& matrixR()
const {
275 eigen_assert(m_isInitialized &&
"RandColPivHouseholderQR is not initialized.");
279 template <
typename InputType>
282 const PermutationType& colsPermutation()
const {
283 eigen_assert(m_isInitialized &&
"RandColPivHouseholderQR is not initialized.");
284 return m_colsPermutation;
287 typename MatrixType::Scalar determinant()
const;
288 typename MatrixType::RealScalar absDeterminant()
const;
289 typename MatrixType::RealScalar logAbsDeterminant()
const;
290 typename MatrixType::Scalar signDeterminant()
const;
292 RealScalar pivotCoeff(
Index i)
const {
return numext::abs(m_qr.coeff(i, i)); }
294 inline Inverse<RandColPivHouseholderQR> inverse()
const {
295 eigen_assert(m_isInitialized &&
"RandColPivHouseholderQR is not initialized.");
296 return Inverse<RandColPivHouseholderQR>(*
this);
299 inline Index rows()
const {
return m_qr.rows(); }
300 inline Index cols()
const {
return m_qr.cols(); }
302 const HCoeffsType& hCoeffs()
const {
return m_hCoeffs; }
305 eigen_assert(m_isInitialized &&
"Decomposition is not initialized.");
321 eigen_assert(b >= 0 &&
"Block size must be non-negative.");
356#ifndef EIGEN_PARSED_BY_DOXYGEN
357 template <
typename RhsType,
typename DstType>
358 void _solve_impl(
const RhsType& rhs, DstType& dst)
const;
360 template <
bool Conjugate,
typename RhsType,
typename DstType>
361 void _solve_impl_transposed(
const RhsType& rhs, DstType& dst)
const;
365 friend class internal::CompleteOrthogonalDecompositionImpl<MatrixType, PermutationIndex,
RandColPivHouseholderQR>;
367 EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
369 void computeInPlace();
377 Index unblocked_pivoted_qr(Index row0, Index col0, Index ncols, RealScalar threshold_helper);
381 void finalize_rank(RealScalar threshold_helper);
384 HCoeffsType m_hCoeffs;
385 PermutationType m_colsPermutation;
386 RowVectorType m_temp;
387 Index m_blockSize = kAutoBlockSize;
389 bool m_seedSet =
false;
390 bool m_isInitialized =
false;
394template <
typename MatrixType,
typename PermutationIndex>
395typename MatrixType::Scalar RandColPivHouseholderQR<MatrixType, PermutationIndex>::determinant()
const {
396 eigen_assert(m_isInitialized &&
"RandColPivHouseholderQR is not initialized.");
397 EIGEN_INTERNAL_ASSERT_SQUARE_MSG(m_qr,
"You can't take the determinant of a non-square matrix!");
399 internal::householder_determinant<HCoeffsType, Scalar, NumTraits<Scalar>::IsComplex>::run(m_hCoeffs, detQ);
400 return isInjective() ? (detQ * Scalar(m_det_p)) * internal::scaled_prod(m_qr.diagonal()).value() : Scalar(0);
403template <
typename MatrixType,
typename PermutationIndex>
404typename MatrixType::RealScalar RandColPivHouseholderQR<MatrixType, PermutationIndex>::absDeterminant()
const {
405 eigen_assert(m_isInitialized &&
"RandColPivHouseholderQR is not initialized.");
406 EIGEN_INTERNAL_ASSERT_SQUARE_MSG(m_qr,
"You can't take the determinant of a non-square matrix!");
407 return isInjective() ? internal::scaled_prod(m_qr.diagonal()).abs() : RealScalar(0);
410template <
typename MatrixType,
typename PermutationIndex>
411typename MatrixType::RealScalar RandColPivHouseholderQR<MatrixType, PermutationIndex>::logAbsDeterminant()
const {
412 eigen_assert(m_isInitialized &&
"RandColPivHouseholderQR is not initialized.");
413 EIGEN_INTERNAL_ASSERT_SQUARE_MSG(m_qr,
"You can't take the determinant of a non-square matrix!");
414 return isInjective() ? internal::log_abs_prod(m_qr.diagonal()) : -
NumTraits<RealScalar>::infinity();
417template <
typename MatrixType,
typename PermutationIndex>
418typename MatrixType::Scalar RandColPivHouseholderQR<MatrixType, PermutationIndex>::signDeterminant()
const {
419 eigen_assert(m_isInitialized &&
"RandColPivHouseholderQR is not initialized.");
420 EIGEN_INTERNAL_ASSERT_SQUARE_MSG(m_qr,
"You can't take the determinant of a non-square matrix!");
422 internal::householder_determinant<HCoeffsType, Scalar, NumTraits<Scalar>::IsComplex>::run(m_hCoeffs, detQ);
423 return isInjective() ? (detQ * Scalar(m_det_p)) * m_qr.diagonal().array().sign().prod() : Scalar(0);
426template <
typename MatrixType,
typename PermutationIndex>
427template <
typename InputType>
430 m_qr.resize(matrix.rows(), matrix.cols());
436template <
typename MatrixType,
typename PermutationIndex>
437Index RandColPivHouseholderQR<MatrixType, PermutationIndex>::unblocked_pivoted_qr(Index row0, Index col0, Index ncols,
438 RealScalar threshold_helper) {
439 const Index rows = m_qr.rows();
440 const Index col_end = col0 + ncols;
441 const Index sub_rows = rows - row0;
442 Index num_transpositions = 0;
445 const bool stable_norms = internal::column_norms_with_fallback(m_qr.block(row0, col0, sub_rows, ncols), norms_direct);
447 const RealScalar downdate_threshold = numext::sqrt(NumTraits<RealScalar>::epsilon());
449 const Index size = (std::min)(sub_rows, ncols);
450 for (Index k = 0; k < size; ++k) {
452 RealScalar biggest_norm = norms_updated.tail(ncols - k).maxCoeff(&biggest);
455 if (this->m_nonzero_pivots == m_qr.diagonalSize() &&
456 biggest_norm < threshold_helper * numext::sqrt(RealScalar(rows - row0 - k)))
457 this->m_nonzero_pivots = col0 + k;
460 m_qr.col(col0 + k).swap(m_qr.col(col0 + biggest));
461 std::swap(norms_updated.coeffRef(k), norms_updated.coeffRef(biggest));
462 std::swap(norms_direct.coeffRef(k), norms_direct.coeffRef(biggest));
463 m_colsPermutation.applyTranspositionOnTheRight(col0 + k, col0 + biggest);
464 ++num_transpositions;
468 m_qr.col(col0 + k).tail(sub_rows - k).makeHouseholderInPlace(m_hCoeffs.coeffRef(col0 + k), beta);
469 m_qr.coeffRef(row0 + k, col0 + k) = beta;
470 if (numext::abs(beta) > this->m_maxpivot) this->m_maxpivot = numext::abs(beta);
476 const Index trail_cols = col_end - col0 - k - 1;
477 if (trail_cols > 0) {
478 m_qr.block(row0 + k, col0 + k + 1, sub_rows - k, trail_cols)
479 .applyHouseholderOnTheLeft(m_qr.col(col0 + k).tail(sub_rows - k - 1), m_hCoeffs.coeff(col0 + k),
480 &m_temp.coeffRef(col0 + k + 1));
483 for (Index j = k + 1; j < ncols; ++j) {
484 internal::lawn176_norm_downdate(norms_updated.coeffRef(j), norms_direct.coeffRef(j),
485 m_qr.coeff(row0 + k, col0 + j), downdate_threshold, [&] {
486 const auto tail = m_qr.col(col0 + j).tail(sub_rows - k - 1);
487 return stable_norms ? tail.stableNorm() : tail.norm();
491 return num_transpositions;
494template <
typename MatrixType,
typename PermutationIndex>
495void RandColPivHouseholderQR<MatrixType, PermutationIndex>::finalize_rank(RealScalar threshold_helper) {
496 const Index rows = m_qr.rows();
497 const Index size = (std::min)(rows, m_qr.cols());
505 if (this->m_nonzero_pivots == size) {
506 for (Index i = 0; i < size; ++i) {
507 RealScalar a = numext::abs(m_qr.coeff(i, i));
508 if (a < threshold_helper * numext::sqrt(RealScalar(rows - i))) {
509 this->m_nonzero_pivots = i;
516template <
typename MatrixType,
typename PermutationIndex>
517void RandColPivHouseholderQR<MatrixType, PermutationIndex>::computeInPlace() {
518 eigen_assert(m_qr.cols() <= NumTraits<PermutationIndex>::highest());
520 const Index rows = m_qr.rows();
521 const Index cols = m_qr.cols();
522 const Index size = (std::min)(rows, cols);
524 m_hCoeffs.resize(size);
526 m_colsPermutation.resize(cols);
527 m_colsPermutation.setIdentity();
528 this->m_nonzero_pivots = size;
529 this->m_maxpivot = RealScalar(0);
530 Index num_transpositions = 0;
538 internal::column_norms_with_fallback(m_qr, initial_norms);
539 const RealScalar threshold_helper =
540 cols == 0 ? RealScalar(0)
541 : initial_norms.maxCoeff() *
NumTraits<RealScalar>::epsilon() / numext::sqrt(RealScalar(rows));
543 const bool auto_block = (m_blockSize == kAutoBlockSize);
544 const Index requested_b = auto_block ? computeAutoBlockSize(rows, size) : m_blockSize;
545 const Index b = (std::min)(requested_b, size);
556 const bool can_block = (b > 0) && (size >= 2 * b) && (rows > b) && (!auto_block || size >= kAutoBlockedPathMinSize);
558 num_transpositions += unblocked_pivoted_qr(0, 0, cols, threshold_helper);
559 m_det_p = (num_transpositions % 2) ? -1 : 1;
560 finalize_rank(threshold_helper);
561 m_isInitialized =
true;
581 WorkMatrix Y(b, cols);
582 WorkMatrix YT(cols, b);
583 WorkMatrix sketch_R(b, b);
585 WorkVector y_hcoeffs(b);
586 WorkVector y_temp(cols);
592 WorkMatrix G(b, rows);
593 uint64_t seed = m_seed;
595 std::random_device rd;
596 seed = (uint64_t(rd()) << 32) | uint64_t(rd());
598 std::mt19937_64 engine(seed);
599 internal::fill_gaussian(G, engine);
600 Y.noalias() = G * m_qr;
604 bool blocked_terminated_early =
false;
605 while (k + b <= size && cols - k > b) {
606 const Index n_remain = cols - k;
607 const Index trail_cols = n_remain - b;
608 const Index sub_rows = rows - k;
614 auto Y_curr = Y.middleCols(k, n_remain);
615 auto Y_T = YT.topRows(n_remain);
616 Y_T = Y_curr.transpose();
618 typename IpivType::StorageIndex nb_lu_transp = 0;
619 internal::partial_lu_inplace(Y_T, ipiv, nb_lu_transp);
625 for (Index i = 0; i < b; ++i) {
626 Index dst =
static_cast<Index
>(ipiv.coeff(i));
628 m_qr.col(k + i).swap(m_qr.col(k + dst));
629 Y.col(k + i).swap(Y.col(k + dst));
630 m_colsPermutation.applyTranspositionOnTheRight(k + i, k + dst);
631 ++num_transpositions;
642 WorkMatrixRef Y_curr_ref(Y_curr);
644 internal::householder_qr_inplace_blocked<WorkMatrixRef, Ref<WorkVector>>::run(
645 Y_curr_ref, y_hc_ref, (std::min)(b, Index(48)), y_temp.data());
651 sketch_R = Y.block(0, k, b, b);
654 sketch_R.template triangularView<StrictlyLower>().setZero();
657 auto panel = m_qr.block(k, k, sub_rows, b);
658 auto hCoeffsSegment = m_hCoeffs.segment(k, b);
660 QrPanelRef panel_ref(panel);
661 HCoeffsRef hc_ref(hCoeffsSegment);
662 internal::householder_qr_inplace_blocked<QrPanelRef, HCoeffsRef>::run(
663 panel_ref, hc_ref, (std::min)(b, Index(48)), m_temp.data());
666 this->m_maxpivot = (std::max)(this->m_maxpivot, m_qr.diagonal().segment(k, b).cwiseAbs().maxCoeff());
676 Index panel_rank = b;
678 const RealScalar relative_cutoff = this->m_maxpivot * NumTraits<RealScalar>::epsilon() * RealScalar(4 * size);
679 for (Index i = 0; i < b; ++i) {
680 RealScalar a = numext::abs(m_qr.coeff(k + i, k + i));
681 if (a <= relative_cutoff) {
693 auto trailing = m_qr.block(k, k + b, sub_rows, trail_cols);
694 internal::apply_block_householder_on_the_left(trailing, panel, hCoeffsSegment,
697 if (panel_rank < b) {
702 if (this->m_nonzero_pivots == size) {
703 this->m_nonzero_pivots = k + panel_rank;
706 blocked_terminated_early =
true;
721 m_qr.block(k, k, b, b).template triangularView<Upper>().template solveInPlace<OnTheRight>(sketch_R);
722 Y.middleCols(k + b, trail_cols).noalias() -= sketch_R * m_qr.block(k, k + b, b, trail_cols);
732 if (k < cols && (k < size || blocked_terminated_early)) {
733 num_transpositions += unblocked_pivoted_qr(k, k, cols - k, threshold_helper);
736 m_det_p = (num_transpositions % 2) ? -1 : 1;
741 finalize_rank(threshold_helper);
743 m_isInitialized =
true;
746#ifndef EIGEN_PARSED_BY_DOXYGEN
747template <
typename MatrixType_,
typename PermutationIndex_>
748template <
typename RhsType,
typename DstType>
750 const Index nonzero_pivots = nonzeroPivots();
752 if (nonzero_pivots == 0) {
757 typename RhsType::PlainObject c(rhs);
759 c.applyOnTheLeft(householderQ().setLength(nonzero_pivots).adjoint());
761 m_qr.topLeftCorner(nonzero_pivots, nonzero_pivots)
762 .template triangularView<Upper>()
763 .solveInPlace(c.topRows(nonzero_pivots));
765 for (Index i = 0; i < nonzero_pivots; ++i) dst.row(m_colsPermutation.indices().coeff(i)) = c.row(i);
766 for (Index i = nonzero_pivots; i < cols(); ++i) dst.row(m_colsPermutation.indices().coeff(i)).setZero();
769template <
typename MatrixType_,
typename PermutationIndex_>
770template <
bool Conjugate,
typename RhsType,
typename DstType>
772 DstType& dst)
const {
773 const Index nonzero_pivots = nonzeroPivots();
775 if (nonzero_pivots == 0) {
780 typename RhsType::PlainObject c(m_colsPermutation.transpose() * rhs);
782 m_qr.topLeftCorner(nonzero_pivots, nonzero_pivots)
783 .template triangularView<Upper>()
785 .template conjugateIf<Conjugate>()
786 .solveInPlace(c.topRows(nonzero_pivots));
788 dst.topRows(nonzero_pivots) = c.topRows(nonzero_pivots);
789 dst.bottomRows(rows() - nonzero_pivots).setZero();
791 dst.applyOnTheLeft(householderQ().setLength(nonzero_pivots).
template conjugateIf<!Conjugate>());
797template <
typename DstXprType,
typename MatrixType,
typename PermutationIndex>
798struct Assignment<DstXprType, Inverse<RandColPivHouseholderQR<MatrixType, PermutationIndex>>,
799 internal::assign_op<typename DstXprType::Scalar,
800 typename RandColPivHouseholderQR<MatrixType, PermutationIndex>::Scalar>,
802 using QrType = RandColPivHouseholderQR<MatrixType, PermutationIndex>;
803 using SrcXprType = Inverse<QrType>;
804 static void run(DstXprType& dst,
const SrcXprType& src,
805 const internal::assign_op<typename DstXprType::Scalar, typename QrType::Scalar>&) {
806 dst = src.nestedExpression().solve(MatrixType::Identity(src.rows(), src.cols()));
812template <
typename MatrixType,
typename PermutationIndex>
813typename RandColPivHouseholderQR<MatrixType, PermutationIndex>::HouseholderSequenceType
814RandColPivHouseholderQR<MatrixType, PermutationIndex>::householderQ()
const {
815 eigen_assert(m_isInitialized &&
"RandColPivHouseholderQR is not initialized.");
816 return HouseholderSequenceType(m_qr, m_hCoeffs.conjugate());
823template <
typename Derived>
824template <
typename PermutationIndexType>
826MatrixBase<Derived>::randColPivHouseholderQr()
const {
EvalReturnType eval() const
Definition DenseBase.h:389
Sequence of Householder reflections acting on subspaces with decreasing size.
Definition HouseholderSequence.h:155
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:53
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:188
Permutation matrix.
Definition PermutationMatrix.h:346
Randomized blocked Householder rank-revealing QR with column pivoting.
Definition RandColPivHouseholderQR.h:133
RandColPivHouseholderQR(Index rows, Index cols)
Constructor with memory preallocation.
Definition RandColPivHouseholderQR.h:245
RandColPivHouseholderQR & setBlockSize(Index b)
Sets the panel block size b.
Definition RandColPivHouseholderQR.h:320
RandColPivHouseholderQR & setOversampling(Index)
Sets the oversampling parameter p.
Definition RandColPivHouseholderQR.h:334
Index oversampling() const
Definition RandColPivHouseholderQR.h:354
Index blockSize() const
Returns the user-set panel block size, or 0 if the algorithm should pick automatically....
Definition RandColPivHouseholderQR.h:351
RandColPivHouseholderQR()=default
Default constructor.
RandColPivHouseholderQR(EigenBase< InputType > &matrix)
Inplace constructor: takes a Ref and decomposes in place.
Definition RandColPivHouseholderQR.h:256
RandColPivHouseholderQR(const EigenBase< InputType > &matrix)
Constructs and computes a QR factorization from matrix.
Definition RandColPivHouseholderQR.h:249
RandColPivHouseholderQR & setSeed(uint64_t seed)
Fixes the seed of the internal RNG for reproducible factorization.
Definition RandColPivHouseholderQR.h:341
Index dimensionOfKernel() const
Definition RankRevealingBase.h:139
bool isInjective() const
Definition RankRevealingBase.h:151
bool isSurjective() const
Definition RankRevealingBase.h:163
RandColPivHouseholderQR & setThreshold(const RealScalar &threshold)
Definition RankRevealingBase.h:87
Index nonzeroPivots() const
Definition RankRevealingBase.h:186
RealScalar threshold() const
Definition RankRevealingBase.h:110
RealScalar maxPivot() const
Definition RankRevealingBase.h:194
Index rank() const
Definition RankRevealingBase.h:125
bool isInvertible() const
Definition RankRevealingBase.h:174
A matrix or vector expression mapping an existing expression.
Definition Ref.h:261
Pseudo expression representing a solving operation.
Definition Solve.h:63
constexpr Derived & derived()
Definition EigenBase.h:50
Represents a sequence of transpositions (row/column interchange)
Definition Transpositions.h:144
ComputationInfo
Definition Constants.h:455
@ Success
Definition Constants.h:457
Definition EigenBase.h:34
constexpr Index cols() const noexcept
Definition EigenBase.h:62
constexpr Derived & derived()
Definition EigenBase.h:50
constexpr Index rows() const noexcept
Definition EigenBase.h:60
constexpr Index size() const noexcept
Definition EigenBase.h:65
Eigen::Index Index
The interface type of indices.
Definition EigenBase.h:44
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition NumTraits.h:267