Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef EIGEN_BLOCK_HOUSEHOLDER_H
00027 #define EIGEN_BLOCK_HOUSEHOLDER_H
00028
00029
00030
00031 namespace internal {
00032
00034 template<typename TriangularFactorType,typename VectorsType,typename CoeffsType>
00035 void make_block_householder_triangular_factor(TriangularFactorType& triFactor, const VectorsType& vectors, const CoeffsType& hCoeffs)
00036 {
00037 typedef typename TriangularFactorType::Index Index;
00038 typedef typename VectorsType::Scalar Scalar;
00039 const Index nbVecs = vectors.cols();
00040 eigen_assert(triFactor.rows() == nbVecs && triFactor.cols() == nbVecs && vectors.rows()>=nbVecs);
00041
00042 for(Index i = 0; i < nbVecs; i++)
00043 {
00044 Index rs = vectors.rows() - i;
00045 Scalar Vii = vectors(i,i);
00046 vectors.const_cast_derived().coeffRef(i,i) = Scalar(1);
00047 triFactor.col(i).head(i).noalias() = -hCoeffs(i) * vectors.block(i, 0, rs, i).adjoint()
00048 * vectors.col(i).tail(rs);
00049 vectors.const_cast_derived().coeffRef(i, i) = Vii;
00050
00051 triFactor.col(i).head(i) = triFactor.block(0,0,i,i).template triangularView<Upper>()
00052 * triFactor.col(i).head(i);
00053 triFactor(i,i) = hCoeffs(i);
00054 }
00055 }
00056
00058 template<typename MatrixType,typename VectorsType,typename CoeffsType>
00059 void apply_block_householder_on_the_left(MatrixType& mat, const VectorsType& vectors, const CoeffsType& hCoeffs)
00060 {
00061 typedef typename MatrixType::Index Index;
00062 enum { TFactorSize = MatrixType::ColsAtCompileTime };
00063 Index nbVecs = vectors.cols();
00064 Matrix<typename MatrixType::Scalar, TFactorSize, TFactorSize> T(nbVecs,nbVecs);
00065 make_block_householder_triangular_factor(T, vectors, hCoeffs);
00066
00067 const TriangularView<VectorsType, UnitLower>& V(vectors);
00068
00069
00070 Matrix<typename MatrixType::Scalar,VectorsType::ColsAtCompileTime,MatrixType::ColsAtCompileTime,0,
00071 VectorsType::MaxColsAtCompileTime,MatrixType::MaxColsAtCompileTime> tmp = V.adjoint() * mat;
00072
00073 tmp = T.template triangularView<Upper>().adjoint() * tmp;
00074 mat.noalias() -= V * tmp;
00075 }
00076
00077 }
00078
00079 #endif // EIGEN_BLOCK_HOUSEHOLDER_H