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  static void run(MatrixType&, MatrixType&, const MatrixType&) {}
17 };
18 
19 // For real matrices, make sure none of the eigenvalues are negative.
20 template <typename MatrixType>
22  static void run(MatrixType& m, MatrixType& T, const MatrixType& U) {
23  const Index size = m.cols();
24 
25  for (Index i = 0; i < size; ++i) {
26  if (i == size - 1 || T.coeff(i + 1, i) == 0)
27  T.coeffRef(i, i) = std::abs(T.coeff(i, i));
28  else
29  ++i;
30  }
31  m = U * T * U.transpose();
32  }
33 };
34 
37 
38 template <typename MatrixType>
40  static void run(MatrixType& result, typename MatrixType::Index size) {
41  result = MatrixType::Random(size, size);
43  MatrixType T = schur.matrixT();
45  }
46 };
47 
48 template <typename MatrixType>
50  static void run(MatrixType& result, typename MatrixType::Index size) { result = MatrixType::Random(size, size); }
51 };
52 
53 template <typename Derived, typename OtherDerived>
55  return std::sqrt((A - B).cwiseAbs2().sum() / (std::min)(A.cwiseAbs2().sum(), B.cwiseAbs2().sum()));
56 }
AnnoyingScalar abs(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:135
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
int i
Definition: BiCGSTAB_step_by_step.cpp:9
ComplexSchur< MatrixXcf > schur(4)
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
NumTraits< Scalar >::Real RealScalar
Definition: bench_gemm.cpp:46
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
Definition: matrices.h:74
@ IsComplex
Definition: common.h:73
#define min(a, b)
Definition: datatypes.h:22
int * m
Definition: level2_cplx_impl.h:294
Derived::RealScalar relerr(const MatrixBase< Derived > &A, const MatrixBase< OtherDerived > &B)
Definition: matrix_functions.h:54
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
double U
Swimming speed.
Definition: two_d_variable_diff_adapt.cc:53
static void run(MatrixType &result, typename MatrixType::Index size)
Definition: matrix_functions.h:40
static void run(MatrixType &result, typename MatrixType::Index size)
Definition: matrix_functions.h:50
Definition: matrix_functions.h:36
static void run(MatrixType &m, MatrixType &T, const MatrixType &U)
Definition: matrix_functions.h:22
Definition: matrix_functions.h:15
static void run(MatrixType &, MatrixType &, const MatrixType &)
Definition: matrix_functions.h:16