10#ifndef EIGEN_MATRIX_SQUARE_ROOT
11#define EIGEN_MATRIX_SQUARE_ROOT
19template <
typename MatrixType,
typename ResultType>
28 = (
es.eigenvectors() *
es.eigenvalues().cwiseSqrt().asDiagonal() *
es.eigenvectors().inverse()).
real();
34template <
typename MatrixType,
typename ResultType>
43template <
typename MatrixType,
typename ResultType>
56template <
typename MatrixType,
typename ResultType>
69template <
typename MatrixType>
88 rhs.coeffRef(0) =
C.
coeff(0,0);
89 rhs.coeffRef(1) =
C.
coeff(0,1);
90 rhs.coeffRef(2) =
C.
coeff(1,0);
91 rhs.coeffRef(3) =
C.
coeff(1,1);
96 X.coeffRef(0,0) =
result.coeff(0);
97 X.coeffRef(0,1) =
result.coeff(1);
98 X.coeffRef(1,0) =
result.coeff(2);
99 X.coeffRef(1,1) =
result.coeff(3);
103template <
typename MatrixType,
typename ResultType>
119template <
typename MatrixType,
typename ResultType>
125 if (
i ==
size - 1 ||
T.coeff(
i+1,
i) == 0) {
138template <
typename MatrixType,
typename ResultType>
143 if (
T.coeff(
j,
j-1) != 0)
146 if (
i > 0 &&
T.coeff(
i,
i-1) != 0)
179template <
typename MatrixType,
typename ResultType>
183 result.resize(
arg.rows(),
arg.cols());
203template <
typename MatrixType,
typename ResultType>
207 typedef typename MatrixType::Scalar
Scalar;
213 result.resize(
arg.rows(),
arg.cols());
215 result.coeffRef(
i,
i) = sqrt(
arg.coeff(
i,
i));
220 Scalar tmp = (result.row(
i).segment(
i+1,
j-
i-1) * result.col(
j).segment(
i+1,
j-
i-1)).value();
222 result.coeffRef(
i,
j) = (
arg.coeff(
i,
j) - tmp) / (result.coeff(
i,
i) + result.coeff(
j,
j));
237template <typename MatrixType, int IsComplex = NumTraits<typename internal::traits<MatrixType>::Scalar>
::IsComplex>
253template <
typename MatrixType>
257 template <
typename ResultType>
279template <
typename MatrixType>
283 template <
typename ResultType>
335 template <
typename ResultType>
336 inline void evalTo(ResultType& result)
const
340 DerivedEvalType tmp(
m_src);
352template<
typename Derived>
359template <
typename Derived>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArgReturnType arg() const
Definition ArrayCwiseUnaryOps.h:66
int i
Definition BiCGSTAB_step_by_step.cpp:9
cout<< "Here is a random 4x4 matrix, A:"<< endl<< A<< endl<< endl;ComplexSchur< MatrixXcf > schurOfA(A, false)
EigenSolver< MatrixXf > es
Definition EigenSolver_compute.cpp:1
#define eigen_assert(x)
Definition Macros.h:1037
m m block(1, 0, 2, 2)<< 4
int rows
Definition Tutorial_commainit_02.cpp:1
int cols
Definition Tutorial_commainit_02.cpp:1
Eigen::Triplet< double > T
Definition Tutorial_sparse_example.cpp:6
Scalar Scalar int size
Definition benchVecAdd.cpp:17
SCALAR Scalar
Definition bench_gemm.cpp:46
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition bench_gemm.cpp:49
MatrixXf MatrixType
Definition benchmark-blocking-sizes.cpp:52
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
Proxy for the matrix square root of some matrix (expression).
Definition MatrixSquareRoot.h:318
internal::ref_selector< Derived >::type DerivedNested
Definition MatrixSquareRoot.h:320
Index cols() const
Definition MatrixSquareRoot.h:345
const DerivedNested m_src
Definition MatrixSquareRoot.h:348
void evalTo(ResultType &result) const
Compute the matrix square root.
Definition MatrixSquareRoot.h:336
MatrixSquareRootReturnValue(const Derived &src)
Constructor.
Definition MatrixSquareRoot.h:328
Index rows() const
Definition MatrixSquareRoot.h:344
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & coeff(Index rowId, Index colId) const
Definition PlainObjectBase.h:152
Definition ReturnByValue.h:52
Definition TensorRef.h:81
@ IsComplex
Definition common.h:98
#define X
Definition icosphere.cpp:20
void matrix_sqrt_quasi_triangular_1x2_off_diagonal_block(const MatrixType &T, Index i, Index j, ResultType &sqrtT)
Definition MatrixSquareRoot.h:44
void matrix_sqrt_quasi_triangular_solve_auxiliary_equation(MatrixType &X, const MatrixType &A, const MatrixType &B, const MatrixType &C)
Definition MatrixSquareRoot.h:70
void matrix_sqrt_quasi_triangular_diagonal(const MatrixType &T, ResultType &sqrtT)
Definition MatrixSquareRoot.h:120
void matrix_sqrt_quasi_triangular_2x2_diagonal_block(const MatrixType &T, Index i, ResultType &sqrtT)
Definition MatrixSquareRoot.h:20
void matrix_sqrt_quasi_triangular_off_diagonal(const MatrixType &T, ResultType &sqrtT)
Definition MatrixSquareRoot.h:139
void matrix_sqrt_quasi_triangular_2x2_off_diagonal_block(const MatrixType &T, Index i, Index j, ResultType &sqrtT)
Definition MatrixSquareRoot.h:104
void matrix_sqrt_quasi_triangular_1x1_off_diagonal_block(const MatrixType &T, Index i, Index j, ResultType &sqrtT)
Definition MatrixSquareRoot.h:35
void matrix_sqrt_quasi_triangular_2x1_off_diagonal_block(const MatrixType &T, Index i, Index j, ResultType &sqrtT)
Definition MatrixSquareRoot.h:57
Namespace containing all symbols from the Eigen library.
Definition bench_norm.cpp:85
void matrix_sqrt_quasi_triangular(const MatrixType &arg, ResultType &result)
Compute matrix square root of quasi-triangular matrix.
Definition MatrixSquareRoot.h:180
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
void matrix_sqrt_triangular(const MatrixType &arg, ResultType &result)
Compute matrix square root of triangular matrix.
Definition MatrixSquareRoot.h:204
Definition BandTriangularSolver.h:13
MatrixType::PlainObject PlainType
Definition MatrixSquareRoot.h:256
static void run(const MatrixType &arg, ResultType &result)
Definition MatrixSquareRoot.h:258
static void run(const MatrixType &arg, ResultType &result)
Definition MatrixSquareRoot.h:284
MatrixType::PlainObject PlainType
Definition MatrixSquareRoot.h:282
Helper struct for computing matrix square roots of general matrices.
Definition MatrixSquareRoot.h:239
static void run(const MatrixType &arg, ResultType &result)
Compute the matrix square root.
Derived::PlainObject ReturnType
Definition MatrixSquareRoot.h:355
Definition ForwardDeclarations.h:17
std::ptrdiff_t j
Definition tut_arithmetic_redux_minmax.cpp:2