matrix_functions.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009-2011 Jitse Niesen <jitse@maths.leeds.ac.uk>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #include "main.h"
11 #include <unsupported/Eigen/MatrixFunctions>
12 
13 // For complex matrices, any matrix is fine.
16 {
17  static void run(MatrixType&, MatrixType&, const MatrixType&)
18  { }
19 };
20 
21 // For real matrices, make sure none of the eigenvalues are negative.
22 template<typename MatrixType>
24 {
25  static void run(MatrixType& m, MatrixType& T, const MatrixType& U)
26  {
27  const Index size = m.cols();
28 
29  for (Index i=0; i < size; ++i) {
30  if (i == size - 1 || T.coeff(i+1,i) == 0)
31  T.coeffRef(i,i) = std::abs(T.coeff(i,i));
32  else
33  ++i;
34  }
35  m = U * T * U.transpose();
36  }
37 };
38 
41 
42 template <typename MatrixType>
44 {
45  static void run(MatrixType& result, typename MatrixType::Index size)
46  {
47  result = MatrixType::Random(size, size);
49  MatrixType T = schur.matrixT();
51  }
52 };
53 
54 template <typename MatrixType>
56 {
57  static void run(MatrixType& result, typename MatrixType::Index size)
58  {
59  result = MatrixType::Random(size, size);
60  }
61 };
62 
63 template <typename Derived, typename OtherDerived>
65 {
66  return std::sqrt((A - B).cwiseAbs2().sum() / (std::min)(A.cwiseAbs2().sum(), B.cwiseAbs2().sum()));
67 }
B
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition: bench_gemm.cpp:49
MatrixType
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
generateTestMatrix< MatrixType, 1 >::run
static void run(MatrixType &result, typename MatrixType::Index size)
Definition: matrix_functions.h:57
processTriangularMatrix
Definition: matrix_functions.h:15
result
Values result
Definition: OdometryOptimize.cpp:8
IsComplex
@ IsComplex
Definition: gtsam/3rdparty/Eigen/blas/common.h:98
A
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:48
size
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
Eigen::RealSchur< MatrixType >
relerr
Derived::RealScalar relerr(const MatrixBase< Derived > &A, const MatrixBase< OtherDerived > &B)
Definition: matrix_functions.h:64
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
Eigen::Triplet< double >
generateTestMatrix
Definition: matrix_functions.h:40
schur
ComplexSchur< MatrixXcf > schur(4)
cwiseAbs2
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE CwiseAbs2ReturnType cwiseAbs2() const
Definition: MatrixCwiseUnaryOps.h:46
RealScalar
NumTraits< Scalar >::Real RealScalar
Definition: bench_gemm.cpp:47
processTriangularMatrix::run
static void run(MatrixType &, MatrixType &, const MatrixType &)
Definition: matrix_functions.h:17
processTriangularMatrix< MatrixType, 0 >::run
static void run(MatrixType &m, MatrixType &T, const MatrixType &U)
Definition: matrix_functions.h:25
main.h
generateTestMatrix< MatrixType, 0 >::run
static void run(MatrixType &result, typename MatrixType::Index size)
Definition: matrix_functions.h:45
min
#define min(a, b)
Definition: datatypes.h:19
U
@ U
Definition: testDecisionTree.cpp:349
abs
#define abs(x)
Definition: datatypes.h:17
Eigen::MatrixBase
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
ceres::sqrt
Jet< T, N > sqrt(const Jet< T, N > &f)
Definition: jet.h:418
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:03:03