1 #ifndef VIENNACL_LINALG_DETAIL_SPAI_SPAI_STATIC_HPP
2 #define VIENNACL_LINALG_DETAIL_SPAI_SPAI_STATIC_HPP
36 #include "boost/numeric/ublas/vector.hpp"
37 #include "boost/numeric/ublas/matrix.hpp"
38 #include "boost/numeric/ublas/matrix_proxy.hpp"
39 #include "boost/numeric/ublas/vector_proxy.hpp"
40 #include "boost/numeric/ublas/storage.hpp"
41 #include "boost/numeric/ublas/io.hpp"
42 #include "boost/numeric/ublas/lu.hpp"
43 #include "boost/numeric/ublas/triangular.hpp"
44 #include "boost/numeric/ublas/matrix_expression.hpp"
70 template <
typename SizeType>
73 return (std::find(J.begin(), J.end(), ind) != J.end());
85 template <
typename VectorType,
typename SparseVectorType>
86 void fanOutVector(
const VectorType& m_in,
const std::vector<unsigned int>& J, SparseVectorType& m)
90 m[J[i]] = m_in(cnt++);
97 template <
typename MatrixType,
typename VectorType>
98 void backwardSolve(
const MatrixType& R,
const VectorType& y, VectorType& x)
100 for (
long i = static_cast<long>(R.size2())-1; i >= 0 ; i--)
114 template <
typename VectorType,
typename ScalarType>
115 void projectI(
const std::vector<unsigned int>& I, VectorType& y,
unsigned int ind)
121 y(i) =
static_cast<ScalarType
>(1.0);
123 y(i) =
static_cast<ScalarType
>(0.0);
131 template <
typename SparseVectorType>
136 for(
typename SparseVectorType::const_iterator vec_it = v.begin(); vec_it != v.end(); ++vec_it)
139 J.push_back(vec_it->first);
141 std::sort(J.begin(), J.end());
148 template <
typename SparseMatrixType>
151 typedef typename SparseMatrixType::value_type ScalarType;
152 M.resize(A.size1(), A.size2(),
false);
153 for(
typename SparseMatrixType::const_iterator1 row_it = A.begin1(); row_it!= A.end1(); ++row_it)
156 for(
typename SparseMatrixType::const_iterator2 col_it = row_it.begin(); col_it != row_it.end(); ++col_it)
158 M(col_it.index1(),col_it.index2()) = static_cast<ScalarType>(1);
168 template <
typename SparseVectorType>
169 void projectRows(
const std::vector<SparseVectorType>& A_v_c,
const std::vector<unsigned int>& J, std::vector<unsigned int>& I)
173 for(
typename SparseVectorType::const_iterator col_it = A_v_c[J[i]].begin(); col_it!=A_v_c[J[i]].end(); ++col_it)
176 I.push_back(col_it->first);
179 std::sort(I.begin(), I.end());
std::size_t vcl_size_t
Definition: forwards.h:58
Implementations of dense matrix related operations including matrix-vector products.
Generic interface for matrix-vector and matrix-matrix products. See viennacl/linalg/vector_operations...
Implementation of the dense matrix class.
void backwardSolve(const MatrixType &R, const VectorType &y, VectorType &x)
Solution of linear:R*x=y system by backward substitution.
Definition: spai-static.hpp:98
bool isInIndexSet(const std::vector< SizeType > &J, SizeType ind)
Determines if element ind is in set {J}.
Definition: spai-static.hpp:71
void projectRows(const std::vector< SparseVectorType > &A_v_c, const std::vector< unsigned int > &J, std::vector< unsigned int > &I)
Row projection for matrix A(:,J) -> A(I,J), building index set of non-zero rows.
Definition: spai-static.hpp:169
Generic interface for the computation of inner products. See viennacl/linalg/vector_operations.hpp for implementations.
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:29
Implementation of the compressed_matrix class.
Implementations of operations using sparse matrices.
void fanOutVector(const VectorType &m_in, const std::vector< unsigned int > &J, SparseVectorType &m)
Projects solution of LS problem onto original column m.
Definition: spai-static.hpp:86
The conjugate gradient method is implemented here.
void buildColumnIndexSet(const SparseVectorType &v, std::vector< unsigned int > &J)
Builds index set of projected columns for current column of preconditioner.
Definition: spai-static.hpp:132
void initPreconditioner(const SparseMatrixType &A, SparseMatrixType &M)
Initialize preconditioner with sparcity pattern = p(A)
Definition: spai-static.hpp:149
void projectI(const std::vector< unsigned int > &I, VectorType &y, unsigned int ind)
Perform projection of set I on the unit-vector.
Definition: spai-static.hpp:115
Implementation of the ViennaCL scalar class.