Go to the documentation of this file.
10 #ifndef EIGEN_MATRIX_FUNCTION_H
11 #define EIGEN_MATRIX_FUNCTION_H
29 template <
typename MatrixType>
52 template <
typename MatrixType>
59 N.template triangularView<Upper>().solveInPlace(
e);
60 return e.cwiseAbs().maxCoeff();
63 template <
typename MatrixType>
75 for (
Index s = 1; double(
s) < 1.1 * double(
rows) + 10.0;
s++) {
76 Fincr = m_f(avgEival,
static_cast<int>(
s)) *
P;
81 const RealScalar F_norm =
F.cwiseAbs().rowwise().sum().maxCoeff();
82 const RealScalar Fincr_norm = Fincr.cwiseAbs().rowwise().sum().maxCoeff();
94 const RealScalar P_norm =
P.cwiseAbs().rowwise().sum().maxCoeff();
107 template <
typename Index,
typename ListOfClusters>
110 typename std::list<Index>::iterator
j;
111 for (
typename ListOfClusters::iterator
i = clusters.begin();
i != clusters.end(); ++
i) {
112 j = std::find(
i->begin(),
i->end(),
key);
116 return clusters.end();
130 template <
typename EivalsType,
typename Cluster>
137 if (qi == clusters.end()) {
140 clusters.push_back(
l);
148 && std::find(qi->begin(), qi->end(),
j) == qi->end()) {
150 if (qj == clusters.end()) {
153 qi->insert(qi->end(), qj->begin(), qj->end());
162 template <
typename ListOfClusters,
typename Index>
165 const Index numClusters =
static_cast<Index>(clusters.size());
166 clusterSize.
setZero(numClusters);
167 Index clusterIndex = 0;
168 for (
typename ListOfClusters::const_iterator cluster = clusters.begin(); cluster != clusters.end(); ++cluster) {
169 clusterSize[clusterIndex] = cluster->size();
175 template <
typename VectorType>
178 blockStart.resize(clusterSize.rows());
180 for (
Index i = 1;
i < clusterSize.rows();
i++) {
181 blockStart(
i) = blockStart(
i-1) + clusterSize(
i-1);
186 template <
typename EivalsType,
typename ListOfClusters,
typename VectorType>
189 eivalToCluster.resize(
eivals.rows());
190 Index clusterIndex = 0;
191 for (
typename ListOfClusters::const_iterator cluster = clusters.begin(); cluster != clusters.end(); ++cluster) {
193 if (std::find(cluster->begin(), cluster->end(),
i) != cluster->end()) {
194 eivalToCluster[
i] = clusterIndex;
202 template <
typename DynVectorType,
typename VectorType>
205 DynVectorType indexNextEntry = blockStart;
206 permutation.resize(eivalToCluster.rows());
207 for (
Index i = 0;
i < eivalToCluster.rows();
i++) {
208 Index cluster = eivalToCluster[
i];
209 permutation[
i] = indexNextEntry[cluster];
210 ++indexNextEntry[cluster];
215 template <
typename VectorType,
typename MatrixType>
218 for (
Index i = 0;
i < permutation.rows() - 1;
i++) {
220 for (
j =
i;
j < permutation.rows();
j++) {
221 if (permutation(
j) ==
i)
break;
224 for (
Index k =
j-1; k >=
i; k--) {
226 rotation.makeGivens(
T(k, k+1),
T(k+1, k+1) -
T(k, k));
227 T.applyOnTheLeft(k, k+1,
rotation.adjoint());
230 std::swap(permutation.coeffRef(k), permutation.coeffRef(k+1));
241 template <
typename MatrixType,
typename AtomicType,
typename VectorType>
244 fT.setZero(
T.rows(),
T.cols());
245 for (
Index i = 0;
i < clusterSize.rows(); ++
i) {
246 fT.block(blockStart(
i), blockStart(
i), clusterSize(
i), clusterSize(
i))
247 = atomic.compute(
T.block(blockStart(
i), blockStart(
i), clusterSize(
i), clusterSize(
i)));
273 template <
typename MatrixType>
322 template <
typename MatrixType,
typename VectorType>
327 static const int Options = MatrixType::Options;
330 for (
Index k = 1; k < clusterSize.rows(); k++) {
331 for (
Index i = 0;
i < clusterSize.rows() - k;
i++) {
333 DynMatrixType
A =
T.block(blockStart(
i), blockStart(
i), clusterSize(
i), clusterSize(
i));
334 DynMatrixType
B = -
T.block(blockStart(
i+k), blockStart(
i+k), clusterSize(
i+k), clusterSize(
i+k));
335 DynMatrixType
C = fT.block(blockStart(
i), blockStart(
i), clusterSize(
i), clusterSize(
i))
336 *
T.block(blockStart(
i), blockStart(
i+k), clusterSize(
i), clusterSize(
i+k));
337 C -=
T.block(blockStart(
i), blockStart(
i+k), clusterSize(
i), clusterSize(
i+k))
338 * fT.block(blockStart(
i+k), blockStart(
i+k), clusterSize(
i+k), clusterSize(
i+k));
340 C += fT.block(blockStart(
i), blockStart(
m), clusterSize(
i), clusterSize(
m))
341 *
T.block(blockStart(
m), blockStart(
i+k), clusterSize(
m), clusterSize(
i+k));
342 C -=
T.block(blockStart(
i), blockStart(
m), clusterSize(
i), clusterSize(
m))
343 * fT.block(blockStart(
m), blockStart(
i+k), clusterSize(
m), clusterSize(
i+k));
345 fT.block(blockStart(
i), blockStart(
i+k), clusterSize(
i), clusterSize(
i+k))
379 template <
typename AtomicType,
typename ResultType>
389 template <
typename MatrixType>
392 template <
typename MatA,
typename AtomicType,
typename ResultType>
393 static void run(
const MatA&
A, AtomicType& atomic, ResultType &
result)
397 static const int Rows = Traits::RowsAtCompileTime,
Cols = Traits::ColsAtCompileTime;
398 static const int MaxRows = Traits::MaxRowsAtCompileTime, MaxCols = Traits::MaxColsAtCompileTime;
400 typedef std::complex<Scalar> ComplexScalar;
403 ComplexMatrix CA =
A.template cast<ComplexScalar>();
404 ComplexMatrix Cresult;
413 template <
typename MatrixType>
416 template <
typename MatA,
typename AtomicType,
typename ResultType>
417 static void run(
const MatA&
A, AtomicType& atomic, ResultType &
result)
428 std::list<std::list<Index> > clusters;
454 result =
U * (fT.template triangularView<Upper>() *
U.adjoint());
470 template<
typename Derived>
class MatrixFunctionReturnValue
471 :
public ReturnByValue<MatrixFunctionReturnValue<Derived> >
493 template <
typename ResultType>
503 AtomicType atomic(
m_f);
517 template<
typename Derived>
528 template <
typename Derived>
535 template <
typename Derived>
543 template <
typename Derived>
548 return MatrixFunctionReturnValue<Derived>(derived(), internal::stem_function_cos<ComplexScalar>);
551 template <
typename Derived>
556 return MatrixFunctionReturnValue<Derived>(derived(), internal::stem_function_sinh<ComplexScalar>);
559 template <
typename Derived>
564 return MatrixFunctionReturnValue<Derived>(derived(), internal::stem_function_cosh<ComplexScalar>);
569 #endif // EIGEN_MATRIX_FUNCTION_H
Rot3 rotation(const Pose3 &pose, OptionalJacobian< 3, 6 > H)
MatrixType compute(const MatrixType &A)
Compute matrix function of atomic matrix.
MatrixType::Scalar Scalar
void matrix_function_compute_permutation(const DynVectorType &blockStart, const DynVectorType &eivalToCluster, VectorType &permutation)
Compute permutation which groups ei'vals in same cluster together.
Namespace containing all symbols from the Eigen library.
static void run(const MatA &A, AtomicType &atomic, ResultType &result)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Jet< T, N > sin(const Jet< T, N > &f)
MatrixFunctionReturnValue(const Derived &A, StemFunction f)
Constructor.
internal::ref_selector< Derived >::type DerivedNested
void matrix_function_compute_block_start(const VectorType &clusterSize, VectorType &blockStart)
Compute start of each block using clusterSize.
Eigen::Triplet< double > T
ListOfClusters::iterator matrix_function_find_cluster(Index key, ListOfClusters &clusters)
Find cluster in clusters containing some value.
cout<< "Here is a random 4x4 matrix, A:"<< endl<< A<< endl<< endl;ComplexSchur< MatrixXcf > schurOfA(A, false)
const MatrixFunctionReturnValue< Derived > matrixFunction(StemFunction f) const
Helper function for the unsupported MatrixFunctions module.
Rotation given by a cosine-sine pair.
static const float matrix_function_separation
Maximum distance allowed between eigenvalues to be considered "close".
Jet< T, N > cos(const Jet< T, N > &f)
const EIGEN_DEVICE_FUNC CoshReturnType cosh() const
Derived::PlainObject ReturnType
void matrix_function_compute_block_atomic(const MatrixType &T, AtomicType &atomic, const VectorType &blockStart, const VectorType &clusterSize, MatrixType &fT)
Compute block diagonal part of matrix function.
void matrix_function_compute_map(const EivalsType &eivals, const ListOfClusters &clusters, VectorType &eivalToCluster)
Compute mapping of eigenvalue indices to cluster indices.
MatrixFunctionAtomic(StemFunction f)
Constructor.
static const Line3 l(Rot3(), 1, 1)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
void swap(GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &a, GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &b)
A small structure to hold a non zero as a triplet (i,j,value).
void evalTo(ResultType &result) const
Compute the matrix function.
const gtsam::Symbol key('X', 0)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Helper class for computing matrix functions of atomic matrices.
NumTraits< Scalar >::Real RealScalar
std::complex< typename NumTraits< Scalar >::Real > ComplexScalar
void matrix_function_partition_eigenvalues(const EivalsType &eivals, std::list< Cluster > &clusters)
Partition eigenvalues in clusters of ei'vals close to each other.
static void run(const MatrixType &A, AtomicType &atomic, ResultType &result)
Compute the matrix function.
stem_function< Scalar >::type StemFunction
NumTraits< typename MatrixType::Scalar >::Real matrix_function_compute_mu(const MatrixType &A)
Matrix< Scalar, Dynamic, Dynamic > C
MatrixType matrix_function_solve_triangular_sylvester(const MatrixType &A, const MatrixType &B, const MatrixType &C)
Solve a triangular Sylvester equation AX + XB = C.
Proxy for the matrix function of some matrix (expression).
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
mp::number< mp::cpp_dec_float< 100 >, mp::et_on > Real
void matrix_function_compute_above_diagonal(const MatrixType &T, const VectorType &blockStart, const VectorType &clusterSize, MatrixType &fT)
Compute part of matrix function above block diagonal.
Class for computing matrix functions.
The matrix class, also used for vectors and row-vectors.
EIGEN_DEVICE_FUNC Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > & setZero(Index size)
void matrix_function_compute_cluster_size(const ListOfClusters &clusters, Matrix< Index, Dynamic, 1 > &clusterSize)
Compute size of each cluster given a partitioning.
void matrix_function_permute_schur(VectorType &permutation, MatrixType &U, MatrixType &T)
Permute Schur decomposition in U and T according to permutation.
static void run(const MatA &A, AtomicType &atomic, ResultType &result)
const EIGEN_DEVICE_FUNC SinhReturnType sinh() const
internal::stem_function< Scalar >::type StemFunction
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:12:18