| 1 | // This file is part of Eigen, a lightweight C++ template librarycxx . . $ `<file>/lib/fab/vendor/Eigen/src/Householder/Householder.h`/ |
| 2 | // for linear algebra. |
| 3 | // |
| 4 | // Copyright (C) 2010 Benoit Jacob <[email protected]> |
| 5 | // Copyright (C) 2009 Gael Guennebaud <[email protected]> |
| 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_Hcxx . . $ `lib/fab/vendor/Eigen/src/Householder/Householder.h:12:9`! |
| 13 | |
| 14 | namespace Eigencxx . . $ Eigen/ { |
| 15 | |
| 16 | namespace internalcxx . . $ Eigen/internal/ { |
| 17 | template<int n> struct decrement_sizecxx . . $ Eigen/internal/decrement_size# |
| 18 | { |
| 19 | enumcxx . . $ Eigen/internal/decrement_size#$anonymous_type_0# { |
| 20 | retcxx . . $ Eigen/internal/decrement_size#ret. = n==Dynamiccxx . . $ Eigen/Dynamic. ? n : n-1 |
| 21 | }; |
| 22 | }; |
| 23 | } |
| 24 | |
| 25 | /** Computes the elementary reflector H such that: |
| 26 | * \f$ H *this = [ beta 0 ... 0]^T \f$ |
| 27 | * where the transformation H is: |
| 28 | * \f$ H = I - tau v v^*\f$ |
| 29 | * and the vector v is: |
| 30 | * \f$ v^T = [1 essential^T] \f$ |
| 31 | * |
| 32 | * The essential part of the vector \c v is stored in *this. |
| 33 | * |
| 34 | * On output: |
| 35 | * \param tau the scaling factor of the Householder transformation |
| 36 | * \param beta the result of H * \c *this |
| 37 | * |
| 38 | * \sa MatrixBase::makeHouseholder(), MatrixBase::applyHouseholderOnTheLeft(), |
| 39 | * MatrixBase::applyHouseholderOnTheRight() |
| 40 | */ |
| 41 | template<typename Derived> |
| 42 | void MatrixBasecxx . . $ Eigen/MatrixBase#<Derived>::makeHouseholderInPlacecxx . . $ Eigen/MatrixBase#makeHouseholderInPlace(c2536db293e7f8f5).(Scalarcxx . . $ Eigen/MatrixBase#Scalar#& tau, RealScalarcxx . . $ Eigen/MatrixBase#RealScalar#& beta) |
| 43 | { |
| 44 | VectorBlockcxx . . $ Eigen/VectorBlock#<Derived, internalcxx . . $ Eigen/internal/::decrement_sizecxx . . $ Eigen/internal/decrement_size#<Base::SizeAtCompileTime>::ret> essentialPart(derived(), 1, size()-1); |
| 45 | makeHouseholdercxx . . $ Eigen/MatrixBase#makeHouseholder(9bf5be9cead728cc).(essentialPart, tau, beta); |
| 46 | } |
| 47 | |
| 48 | /** Computes the elementary reflector H such that: |
| 49 | * \f$ H *this = [ beta 0 ... 0]^T \f$ |
| 50 | * where the transformation H is: |
| 51 | * \f$ H = I - tau v v^*\f$ |
| 52 | * and the vector v is: |
| 53 | * \f$ v^T = [1 essential^T] \f$ |
| 54 | * |
| 55 | * On output: |
| 56 | * \param essential the essential part of the vector \c v |
| 57 | * \param tau the scaling factor of the Householder transformation |
| 58 | * \param beta the result of H * \c *this |
| 59 | * |
| 60 | * \sa MatrixBase::makeHouseholderInPlace(), MatrixBase::applyHouseholderOnTheLeft(), |
| 61 | * MatrixBase::applyHouseholderOnTheRight() |
| 62 | */ |
| 63 | template<typename Derived> |
| 64 | template<typename EssentialPart> |
| 65 | void MatrixBasecxx . . $ Eigen/MatrixBase#<Derived>::makeHouseholdercxx . . $ Eigen/MatrixBase#makeHouseholder(9bf5be9cead728cc).( |
| 66 | EssentialPart& essential, |
| 67 | Scalarcxx . . $ Eigen/MatrixBase#Scalar#& tau, |
| 68 | RealScalarcxx . . $ Eigen/MatrixBase#RealScalar#& beta) const |
| 69 | { |
| 70 | using stdcxx . . $ std/::sqrtcxx . . $ Eigen/MatrixBase#makeHouseholder(9bf5be9cead728cc).sqrt(a358fd9634d01384).; |
| 71 | using numextcxx . . $ Eigen/numext/::conjcxx . . $ Eigen/MatrixBase#makeHouseholder(9bf5be9cead728cc).conj(7318bb9358454951).; |
| 72 | |
| 73 | EIGEN_STATIC_ASSERT_VECTOR_ONLYcxx . . $ `lib/fab/vendor/Eigen/src/Core/util/StaticAssert.h:128:9`!(EssentialPart) |
| 74 | VectorBlockcxx . . $ Eigen/VectorBlock#<const Derived, EssentialPart::SizeAtCompileTime> tail(derived(), 1, size()-1); |
| 75 | |
| 76 | RealScalarcxx . . $ Eigen/MatrixBase#RealScalar# tailSqNorm = size()==1 ? RealScalarcxx . . $ Eigen/MatrixBase#RealScalar#(0) : tail.squaredNorm(); |
| 77 | Scalarcxx . . $ Eigen/MatrixBase#Scalar# c0 = coeff(0); |
| 78 | |
| 79 | if(tailSqNorm == RealScalarcxx . . $ Eigen/MatrixBase#RealScalar#(0) && numextcxx . . $ Eigen/numext/::imagcxx . . $ Eigen/numext/imag(7b709d11b5aee992).(c0)==RealScalarcxx . . $ Eigen/MatrixBase#RealScalar#(0)) |
| 80 | { |
| 81 | tau = RealScalarcxx . . $ Eigen/MatrixBase#RealScalar#(0); |
| 82 | beta = numextcxx . . $ Eigen/numext/::realcxx . . $ Eigen/numext/real(9fff23bc4be709fb).(c0); |
| 83 | essential.setZero(); |
| 84 | } |
| 85 | else |
| 86 | { |
| 87 | beta = sqrtcxx . . $ Eigen/MatrixBase#makeHouseholder(9bf5be9cead728cc).sqrt(a358fd9634d01384).(numextcxx . . $ Eigen/numext/::abs2cxx . . $ Eigen/numext/abs2(70b90807620a8982).(c0) + tailSqNorm); |
| 88 | if (numextcxx . . $ Eigen/numext/::realcxx . . $ Eigen/numext/real(9fff23bc4be709fb).(c0)>=RealScalarcxx . . $ Eigen/MatrixBase#RealScalar#(0)) |
| 89 | beta = -beta; |
| 90 | essential = tail /cxx . . $ Eigen/`operator/`(d9bc0e56bbab6561). (c0 - beta); |
| 91 | tau = conjcxx . . $ Eigen/MatrixBase#makeHouseholder(9bf5be9cead728cc).conj(7318bb9358454951).((beta - c0) /cxx . . $ Eigen/`operator/`(d9bc0e56bbab6561). beta); |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | /** Apply the elementary reflector H given by |
| 96 | * \f$ H = I - tau v v^*\f$ |
| 97 | * with |
| 98 | * \f$ v^T = [1 essential^T] \f$ |
| 99 | * from the left to a vector or matrix. |
| 100 | * |
| 101 | * On input: |
| 102 | * \param essential the essential part of the vector \c v |
| 103 | * \param tau the scaling factor of the Householder transformation |
| 104 | * \param workspace a pointer to working space with at least |
| 105 | * this->cols() * essential.size() entries |
| 106 | * |
| 107 | * \sa MatrixBase::makeHouseholder(), MatrixBase::makeHouseholderInPlace(), |
| 108 | * MatrixBase::applyHouseholderOnTheRight() |
| 109 | */ |
| 110 | template<typename Derived> |
| 111 | template<typename EssentialPart> |
| 112 | void MatrixBasecxx . . $ Eigen/MatrixBase#<Derived>::applyHouseholderOnTheLeftcxx . . $ Eigen/MatrixBase#applyHouseholderOnTheLeft(482192995be19ac5).( |
| 113 | const EssentialPart& essential, |
| 114 | const Scalarcxx . . $ Eigen/MatrixBase#Scalar#& tau, |
| 115 | Scalarcxx . . $ Eigen/MatrixBase#Scalar#* workspace) |
| 116 | { |
| 117 | if(rows() == 1) |
| 118 | { |
| 119 | *this *= Scalarcxx . . $ Eigen/MatrixBase#Scalar#(1)-tau; |
| 120 | } |
| 121 | else |
| 122 | { |
| 123 | Mapcxx . . $ Eigen/Map#<typename internalcxx . . $ Eigen/internal/::plain_row_typecxx . . $ Eigen/internal/plain_row_type#<PlainObject>::type> tmp(workspace,cols()); |
| 124 | Blockcxx . . $ Eigen/Block#<Derived, EssentialPart::SizeAtCompileTime, Derived::ColsAtCompileTime> bottom(derived(), 1, 0, rows()-1, cols()); |
| 125 | tmp.noalias() = essential.adjoint() *cxx . . $ Eigen/`operator*`(138cccbaccb3e907). bottom; |
| 126 | tmp += this->rowcxx . . $ Eigen/DenseBase#row(c672c5967ae26290).(0); |
| 127 | this->rowcxx . . $ Eigen/DenseBase#row(c672c5967ae26290).(0) -= tau *cxx . . $ Eigen/`operator*`(138cccbaccb3e907). tmp; |
| 128 | bottom.noalias() -= tau *cxx . . $ Eigen/`operator*`(138cccbaccb3e907). essential *cxx . . $ Eigen/`operator*`(138cccbaccb3e907). tmp; |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | /** Apply the elementary reflector H given by |
| 133 | * \f$ H = I - tau v v^*\f$ |
| 134 | * with |
| 135 | * \f$ v^T = [1 essential^T] \f$ |
| 136 | * from the right to a vector or matrix. |
| 137 | * |
| 138 | * On input: |
| 139 | * \param essential the essential part of the vector \c v |
| 140 | * \param tau the scaling factor of the Householder transformation |
| 141 | * \param workspace a pointer to working space with at least |
| 142 | * this->cols() * essential.size() entries |
| 143 | * |
| 144 | * \sa MatrixBase::makeHouseholder(), MatrixBase::makeHouseholderInPlace(), |
| 145 | * MatrixBase::applyHouseholderOnTheLeft() |
| 146 | */ |
| 147 | template<typename Derived> |
| 148 | template<typename EssentialPart> |
| 149 | void MatrixBasecxx . . $ Eigen/MatrixBase#<Derived>::applyHouseholderOnTheRightcxx . . $ Eigen/MatrixBase#applyHouseholderOnTheRight(482192995be19ac5).( |
| 150 | const EssentialPart& essential, |
| 151 | const Scalarcxx . . $ Eigen/MatrixBase#Scalar#& tau, |
| 152 | Scalarcxx . . $ Eigen/MatrixBase#Scalar#* workspace) |
| 153 | { |
| 154 | if(cols() == 1) |
| 155 | { |
| 156 | *this *= Scalarcxx . . $ Eigen/MatrixBase#Scalar#(1)-tau; |
| 157 | } |
| 158 | else |
| 159 | { |
| 160 | Mapcxx . . $ Eigen/Map#<typename internalcxx . . $ Eigen/internal/::plain_col_typecxx . . $ Eigen/internal/plain_col_type#<PlainObject>::type> tmp(workspace,rows()); |
| 161 | Blockcxx . . $ Eigen/Block#<Derived, Derived::RowsAtCompileTime, EssentialPart::SizeAtCompileTime> right(derived(), 0, 1, rows(), cols()-1); |
| 162 | tmp.noalias() = right *cxx . . $ Eigen/`operator*`(138cccbaccb3e907). essential.conjugate(); |
| 163 | tmp += this->colcxx . . $ Eigen/DenseBase#col(cf71781cb13cd297).(0); |
| 164 | this->colcxx . . $ Eigen/DenseBase#col(cf71781cb13cd297).(0) -= tau *cxx . . $ Eigen/`operator*`(138cccbaccb3e907). tmp; |
| 165 | right.noalias() -= tau *cxx . . $ Eigen/`operator*`(138cccbaccb3e907). tmp *cxx . . $ Eigen/`operator*`(138cccbaccb3e907). essential.transpose(); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | } // end namespace Eigen |
| 170 | |
| 171 | #endif // EIGEN_HOUSEHOLDER_H |