73 #ifndef GMM_PRECOND_MR_APPROX_INVERSE_H 
   74 #define GMM_PRECOND_MR_APPROX_INVERSE_H 
   83   template <
typename Matrix>
 
   86     typedef typename linalg_traits<Matrix>::value_type value_type;
 
   87     typedef typename number_traits<value_type>::magnitude_type magnitude_type;
 
   88     typedef typename principal_orientation_type<
typename 
   89       linalg_traits<Matrix>::sub_orientation>::potype sub_orientation;
 
   91     typedef col_matrix<VVector> MMatrix;
 
   95     magnitude_type threshold;
 
   97     void build_with(
const Matrix& A);
 
   99                               magnitude_type threshold_)
 
  100       : M(mat_nrows(A), mat_ncols(A))
 
  101     { threshold = threshold_; nb_it = nb_it_; build_with(A); }
 
  103     { threshold = magnitude_type(1E-7); nb_it = 5; }
 
  105     { threshold = threshold_; nb_it = nb_it_; } 
 
  106     const MMatrix &approx_inverse(
void)
 const { 
return M; }
 
  109   template <
typename Matrix, 
typename V1, 
typename V2> 
inline 
  111   { 
mult(P.M, v1, v2); }
 
  113   template <
typename Matrix, 
typename V1, 
typename V2> 
inline 
  114   void transposed_mult(
const mr_approx_inverse_precond<Matrix>& P,
 
  116   { mult(gmm::conjugated(P.M), v1, v2); }
 
  118   template <
typename Matrix>
 
  119   void mr_approx_inverse_precond<Matrix>::build_with(
const Matrix& A) {
 
  121     typedef value_type T;
 
  122     typedef magnitude_type R;
 
  123     VVector m(mat_ncols(A)),r(mat_ncols(A)),ei(mat_ncols(A)),Ar(mat_ncols(A)); 
 
  125     if (alpha == T(0)) 
alpha = T(1);
 
  127     for (
size_type i = 0; i < mat_nrows(A); ++i) {
 
  137         if (gmm::abs(nAr) > R(0)) {
 
  139           gmm::clean(m, threshold * gmm::vect_norm2(m));
 
  142       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).