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 }
Matrix3f m
SCALAR Scalar
Definition: bench_gemm.cpp:33
ComplexSchur< MatrixXcf > schur(4)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseAbs2ReturnType cwiseAbs2() const
#define min(a, b)
Definition: datatypes.h:19
const MatrixType & matrixU() const
Returns the orthogonal matrix in the Schur decomposition.
Definition: RealSchur.h:127
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
MatrixXf MatrixType
static void run(MatrixType &result, typename MatrixType::Index size)
Derived::RealScalar relerr(const MatrixBase< Derived > &A, const MatrixBase< OtherDerived > &B)
const MatrixType & matrixT() const
Returns the quasi-triangular matrix in the Schur decomposition.
Definition: RealSchur.h:144
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
Values result
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
const mpreal sum(const mpreal tab[], const unsigned long int n, int &status, mp_rnd_t mode=mpreal::get_default_rnd())
Definition: mpreal.h:2381
NumTraits< Scalar >::Real RealScalar
Definition: bench_gemm.cpp:34
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseAbs2ReturnType cwiseAbs2() const
Definition: MatrixBase.h:46
static void run(MatrixType &, MatrixType &, const MatrixType &)
static void run(MatrixType &result, typename MatrixType::Index size)
#define abs(x)
Definition: datatypes.h:17
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
static void run(MatrixType &m, MatrixType &T, const MatrixType &U)


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:42:49