Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
Eigen  3.4.0
 
Loading...
Searching...
No Matches
Householder.h
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
14namespace Eigen {
15
16namespace internal {
17template<int n> struct decrement_size
18{
19 enum {
20 ret = n==Dynamic ? n : n-1
21 };
22};
23}
24
41template<typename Derived>
42EIGEN_DEVICE_FUNC
44{
46 makeHouseholder(essentialPart, tau, beta);
47}
48
64template<typename Derived>
65template<typename EssentialPart>
66EIGEN_DEVICE_FUNC
68 EssentialPart& essential,
69 Scalar& tau,
70 RealScalar& beta) const
71{
72 using std::sqrt;
73 using numext::conj;
74
75 EIGEN_STATIC_ASSERT_VECTOR_ONLY(EssentialPart)
77
78 RealScalar tailSqNorm = size()==1 ? RealScalar(0) : tail.squaredNorm();
79 Scalar c0 = coeff(0);
80 const RealScalar tol = (std::numeric_limits<RealScalar>::min)();
81
82 if(tailSqNorm <= tol && numext::abs2(numext::imag(c0))<=tol)
83 {
84 tau = RealScalar(0);
85 beta = numext::real(c0);
86 essential.setZero();
87 }
88 else
89 {
90 beta = sqrt(numext::abs2(c0) + tailSqNorm);
91 if (numext::real(c0)>=RealScalar(0))
92 beta = -beta;
93 essential = tail / (c0 - beta);
94 tau = conj((beta - c0) / beta);
95 }
96}
97
113template<typename Derived>
114template<typename EssentialPart>
115EIGEN_DEVICE_FUNC
117 const EssentialPart& essential,
118 const Scalar& tau,
119 Scalar* workspace)
120{
121 if(rows() == 1)
122 {
123 *this *= Scalar(1)-tau;
124 }
125 else if(tau!=Scalar(0))
126 {
129 tmp.noalias() = essential.adjoint() * bottom;
130 tmp += this->row(0);
131 this->row(0) -= tau * tmp;
132 bottom.noalias() -= tau * essential * tmp;
133 }
134}
135
151template<typename Derived>
152template<typename EssentialPart>
153EIGEN_DEVICE_FUNC
155 const EssentialPart& essential,
156 const Scalar& tau,
157 Scalar* workspace)
158{
159 if(cols() == 1)
160 {
161 *this *= Scalar(1)-tau;
162 }
163 else if(tau!=Scalar(0))
164 {
167 tmp.noalias() = right * essential;
168 tmp += this->col(0);
169 this->col(0) -= tau * tmp;
170 right.noalias() -= tau * tmp * essential.adjoint();
171 }
172}
173
174} // end namespace Eigen
175
176#endif // EIGEN_HOUSEHOLDER_H
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:105
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:66
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:96
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:50
Expression of a fixed-size or dynamic-size sub-vector.
Definition: VectorBlock.h:60
Namespace containing all symbols from the Eigen library.
Definition: Core:141
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_conjugate_op< typename Derived::Scalar >, const Derived > conj(const Eigen::ArrayBase< Derived > &x)
const int Dynamic
Definition: Constants.h:22