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);
78  const RealScalar tol = (std::numeric_limits<RealScalar>::min)();
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
const AutoDiffScalar< DerType > & conj(const AutoDiffScalar< DerType > &x)
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:66
EIGEN_DEVICE_FUNC RealReturnType real() const
EIGEN_DEVICE_FUNC SegmentReturnType tail(Index n)
This is the const version of tail(Index).
Definition: BlockMethods.h:949
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:88
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
Definition: LDLT.h:16
static constexpr size_t size(Tuple< Args... > &)
Provides access to the number of elements in a tuple as a compile-time constant expression.
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
Expression of a fixed-size or dynamic-size sub-vector.
EIGEN_DEVICE_FUNC ColXpr col(Index i)
This is the const version of col().
Definition: BlockMethods.h:838
EIGEN_DEVICE_FUNC RowXpr row(Index i)
This is the const version of row(). */.
Definition: BlockMethods.h:859
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
EIGEN_DEVICE_FUNC const ImagReturnType imag() const
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:137


hebiros
Author(s): Xavier Artache , Matthew Tesch
autogenerated on Thu Sep 3 2020 04:08:14