35 #define BOOST_UBLAS_NDEBUG
41 #include <boost/numeric/ublas/io.hpp>
42 #include <boost/numeric/ublas/triangular.hpp>
43 #include <boost/numeric/ublas/matrix_sparse.hpp>
44 #include <boost/numeric/ublas/matrix.hpp>
45 #include <boost/numeric/ublas/matrix_proxy.hpp>
46 #include <boost/numeric/ublas/operation.hpp>
47 #include <boost/numeric/ublas/operation_sparse.hpp>
48 #include <boost/numeric/ublas/io.hpp>
49 #include <boost/numeric/ublas/lu.hpp>
52 #define VIENNACL_WITH_UBLAS 1
92 ublas::vector<ScalarType> rhs;
93 ublas::vector<ScalarType> ref_result;
94 ublas::vector<ScalarType> result;
95 ublas::compressed_matrix<ScalarType> ublas_matrix;
102 std::cout <<
"Error reading Matrix file" << std::endl;
108 std::cout <<
"Error reading RHS file" << std::endl;
114 std::cout <<
"Error reading Result file" << std::endl;
121 std::size_t vcl_size = rhs.size();
129 viennacl::copy(ref_result.begin(), ref_result.end(), vcl_ref_result.begin());
143 std::vector< std::map< unsigned int, ScalarType> > stl_matrix(rhs.size());
144 for (ublas::compressed_matrix<ScalarType>::iterator1 iter1 = ublas_matrix.begin1();
145 iter1 != ublas_matrix.end1();
148 for (ublas::compressed_matrix<ScalarType>::iterator2 iter2 = iter1.begin();
149 iter2 != iter1.end();
151 stl_matrix[iter2.index1()][
static_cast<unsigned int>(iter2.index2())] = *iter2;
153 std::vector<ScalarType> stl_rhs(rhs.size()), stl_result(result.size());
154 std::copy(rhs.begin(), rhs.end(), stl_rhs.begin());
161 std::cout <<
"Setting up preconditioners for uBLAS-matrix..." << std::endl;
167 std::cout <<
"Setting up preconditioners for ViennaCL-matrix..." << std::endl;
182 std::cout <<
"----- CG Method -----" << std::endl;
214 std::cout <<
"----- BiCGStab Method -----" << std::endl;
243 std::cout <<
"----- GMRES Method -----" << std::endl;
272 std::cout <<
"!!!! TUTORIAL COMPLETED SUCCESSFULLY !!!!" << std::endl;
A reader and writer for the matrix market format is implemented here.
ILU0 preconditioner class, can be supplied to solve()-routines.
Jacobi preconditioner class, can be supplied to solve()-routines. Generic version for non-ViennaCL ma...
Generic interface for matrix-vector and matrix-matrix products. See viennacl/linalg/vector_operations...
A tag for incomplete LU factorization with static pattern (ILU0)
The stabilized bi-conjugate gradient method is implemented here.
A tag for a jacobi preconditioner.
A block ILU preconditioner class, can be supplied to solve()-routines.
Implementation of a simple Jacobi preconditioner.
A tag for the solver GMRES. Used for supplying solver parameters and for dispatching the solve() func...
Implementation of the coordinate_matrix class.
VectorT solve(MatrixT const &matrix, VectorT const &rhs, bicgstab_tag const &tag, PreconditionerT const &precond)
Implementations of the generalized minimum residual method are in this file.
Implementations of incomplete factorization preconditioners. Convenience header file.
A tag for incomplete LU factorization with threshold (ILUT)
Implementation of the compressed_matrix class.
bool readVectorFromFile(const std::string &filename, VectorType &vec)
ILUT preconditioner class, can be supplied to solve()-routines.
The conjugate gradient method is implemented here.
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
void copy(std::vector< NumericT > &cpu_vec, circulant_matrix< NumericT, AlignmentV > &gpu_mat)
Copies a circulant matrix from the std::vector to the OpenCL device (either GPU or multi-core CPU) ...
A tag for the conjugate gradient Used for supplying solver parameters and for dispatching the solve()...
A sparse square matrix in compressed sparse rows format.
A tag for the stabilized Bi-conjugate gradient solver. Used for supplying solver parameters and for d...
long read_matrix_market_file(MatrixT &mat, const char *file, long index_base=1)
Reads a sparse matrix from a file (MatrixMarket format)
Implementation of the ViennaCL scalar class.
A sparse square matrix, where entries are stored as triplets (i,j, val), where i and j are the row an...