67 #ifndef GMM_MODIFIED_GRAM_SCHMIDT_H
68 #define GMM_MODIFIED_GRAM_SCHMIDT_H
75 class modified_gram_schmidt {
77 typedef dense_matrix<T> MAT;
82 modified_gram_schmidt(
int restart,
size_t s) : M(s, restart+1) {}
84 typename linalg_traits<MAT>::const_sub_col_type
85 operator[](
size_t i)
const {
return mat_const_col(M, i); }
87 typename linalg_traits<MAT>::sub_col_type
88 operator[](
size_t i) {
return mat_col(M, i); }
90 inline size_type nrows(
void)
const {
return M.nrows(); }
91 inline size_type ncols(
void)
const {
return M.ncols(); }
92 MAT &mat(
void) {
return M; }
93 const MAT &mat(
void)
const {
return M; }
97 template <
typename T,
typename VecHi>
inline
98 void orthogonalize(modified_gram_schmidt<T>& V,
const VecHi& Hi_,
size_t i) {
99 VecHi& Hi =
const_cast<VecHi&
>(Hi_);
101 for (
size_t k = 0; k <= i; k++) {
103 gmm::add(gmm::scaled(V[k], -Hi[k]), V[i+1]);
107 template <
typename T,
typename VecHi>
108 void orthogonalize_with_refinment(modified_gram_schmidt<T>& V,
109 const VecHi& Hi_,
size_t i) {
110 VecHi& Hi =
const_cast<VecHi&
>(Hi_);
111 orthogonalize(V, Hi_, i);
113 sub_interval SUBI(0, V.nrows()), SUBJ(0, i+1);
114 std::vector<T> corr(i+1);
117 gmm::mult(sub_matrix(V.mat(), SUBI, SUBJ),
118 scaled(corr, T(-1)), V[i+1],V[i+1]);
119 gmm::add(corr, sub_vector(Hi, SUBJ));
122 template <
typename T,
typename VecS,
typename VecX>
123 void combine(modified_gram_schmidt<T>& V,
const VecS& s, VecX& x,
size_t i)
124 {
for (
size_t j = 0; j < i; ++j) gmm::add(gmm::scaled(V[j], s[j]), x); }
strongest_value_type< V1, V2 >::value_type vect_hp(const V1 &v1, const V2 &v2)
*/
void mult(const L1 &l1, const L2 &l2, L3 &l3)
*/
void add(const L1 &l1, L2 &l2)
*/
conjugated_return< L >::return_type conjugated(const L &v)
return a conjugated view of the input matrix or vector.
Include the base gmm files.
size_t size_type
used as the common size type in the library