24 #ifndef HOUSEHOLDERQR_HPP 25 #define HOUSEHOLDERQR_HPP 27 #include <boost/numeric/ublas/matrix.hpp> 28 #include <boost/numeric/ublas/matrix_proxy.hpp> 29 #include <boost/numeric/ublas/vector_proxy.hpp> 30 #include <boost/numeric/ublas/io.hpp> 31 #include <boost/numeric/ublas/matrix_expression.hpp> 40 ublas::matrix<T>& result,
43 result.resize (size,size);
45 for(
unsigned int row=0; row< vector.size(); ++row)
47 for(
unsigned int col=0; col < vector.size(); ++col)
48 result(row,col) = vector(col) * vector(row);
55 const ublas::matrix<T>& RightSmall)
61 (LeftLarge.size1() >= RightSmall.size1())
62 && (LeftLarge.size2() >= RightSmall.size2())
66 cerr <<
"invalid matrix dimensions" << endl;
70 size_t row_offset = LeftLarge.size2() - RightSmall.size2();
71 size_t col_offset = LeftLarge.size1() - RightSmall.size1();
73 for(
unsigned int row = 0; row < RightSmall.size2(); ++row )
74 for(
unsigned int col = 0; col < RightSmall.size1(); ++col )
75 LeftLarge(col_offset+col,row_offset+row) -= RightSmall(col,row);
88 (M.size1() == M.size2())
92 cerr <<
"invalid matrix dimensions" << endl;
95 size_t size = M.size1();
99 HTemp = identity_matrix<T>(size);
100 Q = identity_matrix<T>(size);
104 for(
unsigned int col = 0; col < size-1; ++col)
107 ublas::vector<T> RRowView = column(R,col);
108 vector_range< ublas::vector<T> > X2 (RRowView, range (col, size));
109 ublas::vector<T> X = X2;
115 X(0) += -1*norm_2(X);
117 HTemp.resize(X.size(),X.size(),
true);
122 HTemp *= ( 2 / inner_prod(X,X) );
125 H = identity_matrix<T>(size);
137 #endif // HOUSEHOLDERQR_HPP
void HouseholderCornerSubstraction(ublas::matrix< T > &LeftLarge, const ublas::matrix< T > &RightSmall)
void HouseholderQR(const ublas::matrix< T > &M, ublas::matrix< T > &Q, ublas::matrix< T > &R)
void TransposeMultiply(const ublas::vector< T > &vector, ublas::matrix< T > &result, size_t size)