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
78 using namespace boost::numeric;
93 ublas::vector<ScalarType> rhs;
94 ublas::vector<ScalarType> ref_result;
95 ublas::vector<ScalarType> result;
96 ublas::compressed_matrix<ScalarType> ublas_matrix;
103 std::cout <<
"Error reading Matrix file" << std::endl;
109 std::cout <<
"Error reading RHS file" << std::endl;
115 std::cout <<
"Error reading Result file" << std::endl;
122 std::size_t vcl_size = rhs.size();
130 viennacl::copy(ref_result.begin(), ref_result.end(), vcl_ref_result.begin());
144 std::vector< std::map< unsigned int, ScalarType> > stl_matrix(rhs.size());
145 for (ublas::compressed_matrix<ScalarType>::iterator1 iter1 = ublas_matrix.begin1();
146 iter1 != ublas_matrix.end1();
149 for (ublas::compressed_matrix<ScalarType>::iterator2 iter2 = iter1.begin();
150 iter2 != iter1.end();
152 stl_matrix[iter2.index1()][
static_cast<unsigned int>(iter2.index2())] = *iter2;
160 std::cout <<
"Setting up preconditioners for uBLAS-matrix..." << std::endl;
166 std::cout <<
"Setting up preconditioners for ViennaCL-matrix..." << std::endl;
181 std::cout <<
"----- CG Method -----" << std::endl;
204 std::cout <<
"----- BiCGStab Method -----" << std::endl;
225 std::cout <<
"----- GMRES Method -----" << std::endl;
245 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.
viennacl::vector< NumericT > solve(viennacl::compressed_matrix< NumericT > const &A, viennacl::vector_base< NumericT > const &rhs, bicgstab_tag const &tag, viennacl::linalg::no_precond)
Overload for the pipelined BiCGStab implementation for the ViennaCL sparse matrix types...
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...