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"
71 template<
typename SizeT>
74 return (std::find(J.begin(), J.end(), ind) != J.end());
87 template<
typename VectorT,
typename SparseVectorT>
88 void fanOutVector(VectorT
const & m_in, std::vector<unsigned int>
const & J, SparseVectorT & m)
92 m[J[i]] = m_in(cnt++);
101 template<
typename MatrixT,
typename VectorT>
104 for (
long i2 = static_cast<long>(R.size2())-1; i2 >= 0; i2--)
108 for (
vcl_size_t j = static_cast<vcl_size_t>(i)+1; j < R.size2(); ++j)
121 template<
typename VectorT,
typename NumericT>
122 void projectI(std::vector<unsigned int>
const & I, VectorT & y,
unsigned int ind)
139 template<
typename SparseVectorT>
142 for (
typename SparseVectorT::const_iterator vec_it = v.begin(); vec_it != v.end(); ++vec_it)
143 J.push_back(vec_it->first);
145 std::sort(J.begin(), J.end());
153 template<
typename SparseMatrixT>
156 typedef typename SparseMatrixT::value_type NumericType;
158 M.resize(A.size1(), A.size2(),
false);
159 for (
typename SparseMatrixT::const_iterator1 row_it = A.begin1(); row_it!= A.end1(); ++row_it)
160 for (
typename SparseMatrixT::const_iterator2 col_it = row_it.begin(); col_it != row_it.end(); ++col_it)
161 M(col_it.index1(),col_it.index2()) = NumericType(1);
170 template<
typename SparseVectorT>
172 std::vector<unsigned int>
const & J,
173 std::vector<unsigned int> & I)
177 for (
typename SparseVectorT::const_iterator col_it = A_v_c[J[i]].begin(); col_it!=A_v_c[J[i]].end(); ++col_it)
180 I.push_back(col_it->first);
183 std::sort(I.begin(), I.end());
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.
Generic interface for the computation of inner products. See viennacl/linalg/vector_operations.hpp for implementations.
bool isInIndexSet(std::vector< SizeT > const &J, SizeT ind)
Determines if element ind is in set {J}.
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
void projectRows(std::vector< SparseVectorT > const &A_v_c, std::vector< unsigned int > const &J, std::vector< unsigned int > &I)
Row projection for matrix A(:,J) -> A(I,J), building index set of non-zero rows.
void backwardSolve(MatrixT const &R, VectorT const &y, VectorT &x)
Solution of linear:R*x=y system by backward substitution.
Implementation of the compressed_matrix class.
Implementations of operations using sparse matrices.
void projectI(std::vector< unsigned int > const &I, VectorT &y, unsigned int ind)
Perform projection of set I on the unit-vector.
The conjugate gradient method is implemented here.
void fanOutVector(VectorT const &m_in, std::vector< unsigned int > const &J, SparseVectorT &m)
Projects solution of LS problem onto original column m.
void buildColumnIndexSet(SparseVectorT const &v, std::vector< unsigned int > &J)
Builds index set of projected columns for current column of preconditioner.
void initPreconditioner(SparseMatrixT const &A, SparseMatrixT &M)
Initialize preconditioner with sparcity pattern = p(A)
Implementation of the ViennaCL scalar class.