Householder.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) 2010 Benoit Jacob <jacob.benoit.1@gmail.com>
5 // Copyright (C) 2009 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_HOUSEHOLDER_H
12 #define EIGEN_HOUSEHOLDER_H
13 
14 namespace Eigen {
15 
16 namespace internal {
17 template<int n> struct decrement_size
18 {
19  enum {
20  ret = n==Dynamic ? n : n-1
21  };
22 };
23 }
24 
41 template<typename Derived>
43 {
45  makeHouseholder(essentialPart, tau, beta);
46 }
47 
63 template<typename Derived>
64 template<typename EssentialPart>
66  EssentialPart& essential,
67  Scalar& tau,
68  RealScalar& beta) const
69 {
70  using std::sqrt;
71  using numext::conj;
72 
73  EIGEN_STATIC_ASSERT_VECTOR_ONLY(EssentialPart)
75 
76  RealScalar tailSqNorm = size()==1 ? RealScalar(0) : tail.squaredNorm();
77  Scalar c0 = coeff(0);
79 
80  if(tailSqNorm <= tol && numext::abs2(numext::imag(c0))<=tol)
81  {
82  tau = RealScalar(0);
83  beta = numext::real(c0);
84  essential.setZero();
85  }
86  else
87  {
88  beta = sqrt(numext::abs2(c0) + tailSqNorm);
89  if (numext::real(c0)>=RealScalar(0))
90  beta = -beta;
91  essential = tail / (c0 - beta);
92  tau = conj((beta - c0) / beta);
93  }
94 }
95 
111 template<typename Derived>
112 template<typename EssentialPart>
114  const EssentialPart& essential,
115  const Scalar& tau,
116  Scalar* workspace)
117 {
118  if(rows() == 1)
119  {
120  *this *= Scalar(1)-tau;
121  }
122  else if(tau!=Scalar(0))
123  {
126  tmp.noalias() = essential.adjoint() * bottom;
127  tmp += this->row(0);
128  this->row(0) -= tau * tmp;
129  bottom.noalias() -= tau * essential * tmp;
130  }
131 }
132 
148 template<typename Derived>
149 template<typename EssentialPart>
151  const EssentialPart& essential,
152  const Scalar& tau,
153  Scalar* workspace)
154 {
155  if(cols() == 1)
156  {
157  *this *= Scalar(1)-tau;
158  }
159  else if(tau!=Scalar(0))
160  {
163  tmp.noalias() = right * essential.conjugate();
164  tmp += this->col(0);
165  this->col(0) -= tau * tmp;
166  right.noalias() -= tau * tmp * essential.transpose();
167  }
168 }
169 
170 } // end namespace Eigen
171 
172 #endif // EIGEN_HOUSEHOLDER_H
SCALAR Scalar
Definition: bench_gemm.cpp:33
const AutoDiffScalar< DerType > & conj(const AutoDiffScalar< DerType > &x)
float real
Definition: datatypes.h:10
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:66
EIGEN_DEVICE_FUNC SegmentReturnType tail(Index n)
This is the const version of tail(Index).
Definition: BlockMethods.h:949
#define min(a, b)
Definition: datatypes.h:19
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:94
int n
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
void makeHouseholder(EssentialPart &essential, Scalar &tau, RealScalar &beta) const
Definition: Householder.h:65
void applyHouseholderOnTheLeft(const EssentialPart &essential, const Scalar &tau, Scalar *workspace)
Definition: Householder.h:113
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
Expression of a fixed-size or dynamic-size sub-vector.
m row(1)
static char right
NumTraits< Scalar >::Real RealScalar
Definition: bench_gemm.cpp:34
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Abs2ReturnType abs2() const
NumTraits< Scalar >::Real RealScalar
Definition: DenseBase.h:73
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:103
void applyHouseholderOnTheRight(const EssentialPart &essential, const Scalar &tau, Scalar *workspace)
Definition: Householder.h:150
m col(1)
EIGEN_DEVICE_FUNC const ImagReturnType imag() const
const G double tol
Definition: Group.h:83
void makeHouseholderInPlace(Scalar &tau, RealScalar &beta)
Definition: Householder.h:42
const int Dynamic
Definition: Constants.h:21
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Definition: StaticAssert.h:139
ScalarWithExceptions conj(const ScalarWithExceptions &x)
Definition: exceptions.cpp:74


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