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 
79  if(tailSqNorm == RealScalar(0) && numext::imag(c0)==RealScalar(0))
80  {
81  tau = RealScalar(0);
82  beta = numext::real(c0);
83  essential.setZero();
84  }
85  else
86  {
87  beta = sqrt(numext::abs2(c0) + tailSqNorm);
88  if (numext::real(c0)>=RealScalar(0))
89  beta = -beta;
90  essential = tail / (c0 - beta);
91  tau = conj((beta - c0) / beta);
92  }
93 }
94 
110 template<typename Derived>
111 template<typename EssentialPart>
113  const EssentialPart& essential,
114  const Scalar& tau,
115  Scalar* workspace)
116 {
117  if(rows() == 1)
118  {
119  *this *= Scalar(1)-tau;
120  }
121  else
122  {
125  tmp.noalias() = essential.adjoint() * bottom;
126  tmp += this->row(0);
127  this->row(0) -= tau * tmp;
128  bottom.noalias() -= tau * essential * tmp;
129  }
130 }
131 
147 template<typename Derived>
148 template<typename EssentialPart>
150  const EssentialPart& essential,
151  const Scalar& tau,
152  Scalar* workspace)
153 {
154  if(cols() == 1)
155  {
156  *this *= Scalar(1)-tau;
157  }
158  else
159  {
162  tmp.noalias() = right * essential.conjugate();
163  tmp += this->col(0);
164  this->col(0) -= tau * tmp;
165  right.noalias() -= tau * tmp * essential.transpose();
166  }
167 }
168 
169 } // end namespace Eigen
170 
171 #endif // EIGEN_HOUSEHOLDER_H
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:104
Definition: LDLT.h:16
void makeHouseholder(EssentialPart &essential, Scalar &tau, RealScalar &beta) const
Definition: Householder.h:65
internal::traits< Derived >::Scalar Scalar
Definition: MatrixBase.h:56
EIGEN_STRONG_INLINE const CwiseUnaryOp< internal::scalar_abs2_op< Scalar >, const Derived > abs2() const
const ImagReturnType imag() const
void applyHouseholderOnTheLeft(const EssentialPart &essential, const Scalar &tau, Scalar *workspace)
Definition: Householder.h:112
RealReturnType real() const
Expression of a fixed-size or dynamic-size sub-vector.
SegmentReturnType tail(Index vecSize)
Definition: BlockMethods.h:810
NumTraits< Scalar >::Real RealScalar
Definition: DenseBase.h:65
Expression of a fixed-size or dynamic-size block.
Definition: Core/Block.h:102
RowXpr row(Index i)
Definition: BlockMethods.h:725
void applyHouseholderOnTheRight(const EssentialPart &essential, const Scalar &tau, Scalar *workspace)
Definition: Householder.h:149
void makeHouseholderInPlace(Scalar &tau, RealScalar &beta)
Definition: Householder.h:42
const int Dynamic
Definition: Constants.h:21
const CwiseUnaryOp< internal::scalar_sqrt_op< Scalar >, const Derived > sqrt() const
ColXpr col(Index i)
Definition: BlockMethods.h:708
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Definition: StaticAssert.h:126


tuw_aruco
Author(s): Lukas Pfeifhofer
autogenerated on Mon Jun 10 2019 15:40:50