72 #ifndef GMM_PRECOND_MR_APPROX_INVERSE_H
73 #define GMM_PRECOND_MR_APPROX_INVERSE_H
82 template <
typename Matrix>
85 typedef typename linalg_traits<Matrix>::value_type value_type;
86 typedef typename number_traits<value_type>::magnitude_type magnitude_type;
87 typedef typename principal_orientation_type<
typename
88 linalg_traits<Matrix>::sub_orientation>::potype sub_orientation;
90 typedef col_matrix<VVector> MMatrix;
94 magnitude_type threshold;
96 void build_with(
const Matrix& A);
98 magnitude_type threshold_)
99 : M(mat_nrows(A), mat_ncols(A))
100 { threshold = threshold_; nb_it = nb_it_; build_with(A); }
102 { threshold = magnitude_type(1E-7); nb_it = 5; }
104 { threshold = threshold_; nb_it = nb_it_; }
105 const MMatrix &approx_inverse(
void)
const {
return M; }
108 template <
typename Matrix,
typename V1,
typename V2>
inline
110 {
mult(P.M, v1, v2); }
112 template <
typename Matrix,
typename V1,
typename V2>
inline
113 void transposed_mult(
const mr_approx_inverse_precond<Matrix>& P,
115 { mult(gmm::conjugated(P.M), v1, v2); }
117 template <
typename Matrix>
118 void mr_approx_inverse_precond<Matrix>::build_with(
const Matrix& A) {
120 typedef value_type T;
121 typedef magnitude_type R;
122 VVector m(mat_ncols(A)),r(mat_ncols(A)),ei(mat_ncols(A)),Ar(mat_ncols(A));
124 if (alpha == T(0))
alpha = T(1);
126 for (
size_type i = 0; i < mat_nrows(A); ++i) {
136 if (gmm::abs(nAr) > R(0)) {
138 gmm::clean(m, threshold * gmm::vect_norm2(m));
141 if (gmm::vect_norm2(m) == R(0)) m[i] =
alpha;
sparse vector built upon std::map.
void copy(const L1 &l1, L2 &l2)
*/
linalg_traits< M >::value_type mat_trace(const M &m)
Trace of a matrix.
void clear(L &l)
clear (fill with zeros) a vector or matrix.
void resize(V &v, size_type n)
*/
void clean(L &l, double threshold)
Clean a vector or matrix (replace near-zero entries with zeroes).
void mult(const L1 &l1, const L2 &l2, L3 &l3)
*/
strongest_value_type< V1, V2 >::value_type vect_sp(const V1 &v1, const V2 &v2)
*/
void add(const L1 &l1, L2 &l2)
*/
number_traits< typename linalg_traits< M >::value_type >::magnitude_type mat_euclidean_norm_sqr(const M &m)
*/
size_t size_type
used as the common size type in the library
size_type alpha(short_type n, short_type d)
Return the value of which is the number of monomials of a polynomial of variables and degree .
Approximate inverse via MR iteration (see P301 of Saad book).