54 template<
typename MatrixT,
typename VectorT>
55 struct monitor_user_data
57 monitor_user_data(MatrixT
const & A, VectorT
const & b, VectorT
const & guess) : A_ptr(&A), b_ptr(&b), guess_ptr(&guess) {}
61 VectorT
const *guess_ptr;
73 template<
typename VectorT,
typename NumericT,
typename MatrixT>
74 bool my_custom_monitor(VectorT
const & current_approx,
NumericT residual_estimate,
void *user_data)
77 monitor_user_data<MatrixT, VectorT>
const *data =
reinterpret_cast<monitor_user_data<MatrixT, VectorT> const*
>(user_data);
80 VectorT x = current_approx + *data->guess_ptr;
102 std::vector<std::map<unsigned int, ScalarType> > stl_A;
105 std::cout <<
"Error reading Matrix file" << std::endl;
141 std::cout <<
"----- CG Method -----" << std::endl;
151 my_cg_solver.set_initial_guess(init_guess);
159 std::cout <<
"----- BiCGStab Method -----" << std::endl;
169 my_bicgstab_solver.set_initial_guess(init_guess);
171 my_bicgstab_solver(A, b, jacobi);
177 std::cout <<
"----- GMRES Method -----" << std::endl;
189 my_gmres_solver.set_initial_guess(init_guess);
191 my_gmres_solver(A, b);
196 std::cout <<
"!!!! TUTORIAL COMPLETED SUCCESSFULLY !!!!" << std::endl;
const vcl_size_t & size2() const
Returns the number of columns.
T norm_2(std::vector< T, A > const &v1)
A reader and writer for the matrix market format is implemented here.
Jacobi preconditioner class, can be supplied to solve()-routines. Generic version for non-ViennaCL ma...
const vcl_size_t & size1() const
Returns the number of rows.
Generic interface for matrix-vector and matrix-matrix products. See viennacl/linalg/vector_operations...
The stabilized bi-conjugate gradient method is implemented here.
A tag for a jacobi preconditioner.
Implementation of a simple Jacobi preconditioner.
A tag for the solver GMRES. Used for supplying solver parameters and for dispatching the solve() func...
VectorT prod(std::vector< std::vector< T, A1 >, A2 > const &matrix, VectorT const &vector)
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Implementations of the generalized minimum residual method are in this file.
Implementation of the compressed_matrix class.
The conjugate gradient method is implemented here.
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
Represents a vector consisting of scalars 's' only, i.e. v[i] = s for all i. To be used as an initial...
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) ...
size_type size() const
Returns the length of the vector (cf. std::vector)
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.