Go to the documentation of this file.
7 #ifndef SPECTRA_ARNOLDI_H
8 #define SPECTRA_ARNOLDI_H
15 #include "../MatOp/internal/ArnoldiOp.h"
16 #include "../Util/TypeTraits.h"
17 #include "../Util/SimpleRandom.h"
30 template <
typename Scalar,
typename ArnoldiOpType>
70 SimpleRandom<Scalar>
rng(seed + 123 *
iter);
75 m_op.perform_op(
v.data(),
f.data());
83 m_op.adjoint_product(
V,
f, Vf);
84 f.noalias() -=
V * Vf;
89 m_op.adjoint_product(
V,
f, Vf);
91 RealScalar ortho_err = Vf.cwiseAbs().maxCoeff();
94 while (count < 3 && ortho_err >=
m_eps * fnorm)
97 f.noalias() -=
V * Vf;
101 m_op.adjoint_product(
V,
f, Vf);
102 ortho_err = Vf.cwiseAbs().maxCoeff();
108 if (ortho_err <
m_eps * fnorm)
144 throw std::invalid_argument(
"initial residual vector cannot be zero");
149 m_op.perform_op(
v0.data(),
v.data());
158 m_op.perform_op(
v.data(),
w.data());
192 std::string
msg =
"Arnoldi: from_k (= " + std::to_string(from_k) +
193 ") is larger than the current subspace dimension (= " + std::to_string(
m_k) +
")";
194 throw std::invalid_argument(
msg);
207 for (
Index i = from_k;
i <= to_m - 1;
i++)
209 bool restart =
false;
236 m_op.adjoint_product(Vs,
w,
h);
248 RealScalar ortho_err = Vf.head(
i1).cwiseAbs().maxCoeff();
268 h.noalias() += Vf.head(
i1);
273 ortho_err = Vf.head(
i1).cwiseAbs().maxCoeff();
304 template <
typename Derived>
315 QMapConstVec
q(&
Q(0,
i), nnz);
316 Vs.col(
i).noalias() =
m_fac_V.leftCols(nnz) *
q;
329 #endif // SPECTRA_ARNOLDI_H
RealScalar f_norm() const
Index subspace_dim() const
void init(MapConstVec &v0, Index &op_counter)
const Matrix & matrix_H() const
const RealScalar m_near_0
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(DenseBase< OtherDerived > &other)
const Matrix & matrix_V() const
typename Eigen::NumTraits< Scalar >::Real RealScalar
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index rows, Index cols)
const Vector & vector_f() const
Arnoldi(ArnoldiOpType &&op, Index m)
void matrix_QtHQ(Matrix &dest) const
EIGEN_DEVICE_FUNC const Scalar & q
Arnoldi(const ArnoldiOpType &op, Index m)
void expand_basis(MapConstMat &V, const Index seed, Vector &f, RealScalar &fnorm, Index &op_counter)
void compress_V(const Eigen::MatrixBase< Derived > &Q)
A matrix or vector expression mapping an existing array of data.
void compress_H(const DoubleShiftQR< Scalar > &decomp)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
The quaternion class used to represent 3D orientations and rotations.
detail::enable_if_t<!detail::move_never< T >::value, T > move(object &&obj)
void compress_H(const UpperHessenbergQR< Scalar > &decomp)
iterator iter(handle obj)
Array< int, Dynamic, 1 > v
virtual void factorize_from(Index from_k, Index to_m, Index &op_counter)
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE Scalar * data() const
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
Base class for all dense matrices, vectors, and expressions.
virtual void matrix_QtHQ(Matrix &dest) const
Jet< T, N > sqrt(const Jet< T, N > &f)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
gtsam
Author(s):
autogenerated on Sun Feb 16 2025 04:00:56