RealSvd2x2.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-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
5 // Copyright (C) 2013-2016 Gael Guennebaud <gael.guennebaud@inria.fr>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_REALSVD2X2_H
12 #define EIGEN_REALSVD2X2_H
13 
14 // IWYU pragma: private
15 #include "./InternalHeaderCheck.h"
16 
17 namespace Eigen {
18 
19 namespace internal {
20 
21 template <typename MatrixType, typename RealScalar, typename Index>
23  JacobiRotation<RealScalar> *j_right) {
24  using std::abs;
25  using std::sqrt;
27  m << numext::real(matrix.coeff(p, p)), numext::real(matrix.coeff(p, q)), numext::real(matrix.coeff(q, p)),
28  numext::real(matrix.coeff(q, q));
30  RealScalar t = m.coeff(0, 0) + m.coeff(1, 1);
31  RealScalar d = m.coeff(1, 0) - m.coeff(0, 1);
32 
34  rot1.s() = RealScalar(0);
35  rot1.c() = RealScalar(1);
36  } else {
37  // If d!=0, then t/d cannot overflow because the magnitude of the
38  // entries forming d are not too small compared to the ones forming t.
39  RealScalar u = t / d;
41  rot1.s() = RealScalar(1) / tmp;
42  rot1.c() = u / tmp;
43  }
44  m.applyOnTheLeft(0, 1, rot1);
45  j_right->makeJacobi(m, 0, 1);
46  *j_left = rot1 * j_right->transpose();
47 }
48 
49 } // end namespace internal
50 
51 } // end namespace Eigen
52 
53 #endif // EIGEN_REALSVD2X2_H
AnnoyingScalar abs(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:135
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
float * p
Definition: Tutorial_Map_using.cpp:9
NumTraits< Scalar >::Real RealScalar
Definition: bench_gemm.cpp:46
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
Rotation given by a cosine-sine pair.
Definition: Jacobi.h:38
EIGEN_DEVICE_FUNC Scalar & s()
Definition: Jacobi.h:50
EIGEN_DEVICE_FUNC JacobiRotation transpose() const
Definition: Jacobi.h:61
EIGEN_DEVICE_FUNC Scalar & c()
Definition: Jacobi.h:48
EIGEN_DEVICE_FUNC bool makeJacobi(const MatrixBase< Derived > &, Index p, Index q)
Definition: Jacobi.h:131
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
Eigen::Map< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor >, 0, Eigen::OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: common.h:85
float real
Definition: datatypes.h:10
#define min(a, b)
Definition: datatypes.h:22
int * m
Definition: level2_cplx_impl.h:294
Eigen::Matrix< Scalar, Dynamic, Dynamic, ColMajor > tmp
Definition: level3_impl.h:365
void real_2x2_jacobi_svd(const MatrixType &matrix, Index p, Index q, JacobiRotation< RealScalar > *j_left, JacobiRotation< RealScalar > *j_right)
Definition: RealSvd2x2.h:22
EIGEN_DEVICE_FUNC const Scalar & q
Definition: SpecialFunctionsImpl.h:2019
EIGEN_DEVICE_FUNC bool abs2(bool x)
Definition: MathFunctions.h:1102
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
Definition: Eigen_Colamd.h:49
t
Definition: plotPSD.py:36