37 #include <Eigen/Sparse>
40 #define VIENNACL_WITH_EIGEN 1
53 #include "../benchmarks/benchmark-utils.hpp"
59 int main(
int,
char *[])
63 Eigen::SparseMatrix<ScalarType, Eigen::RowMajor> eigen_matrix(65025, 65025);
64 Eigen::VectorXf eigen_rhs;
65 Eigen::VectorXf eigen_result;
66 Eigen::VectorXf ref_result;
67 Eigen::VectorXf residual;
72 std::cout <<
"Reading matrix (this might take some time)..." << std::endl;
73 eigen_matrix.reserve(65025 * 7);
76 std::cout <<
"Error reading Matrix file. Make sure you run from the build/-folder." << std::endl;
80 std::cout <<
"Done: reading matrix" << std::endl;
84 std::cout <<
"Error reading RHS file" << std::endl;
90 std::cout <<
"Error reading Result file" << std::endl;
97 std::cout <<
"----- Running CG -----" << std::endl;
100 residual = eigen_matrix * eigen_result - eigen_rhs;
106 std::cout <<
"----- Running BiCGStab -----" << std::endl;
109 residual = eigen_matrix * eigen_result - eigen_rhs;
115 std::cout <<
"----- Running GMRES -----" << std::endl;
118 residual = eigen_matrix * eigen_result - eigen_rhs;
124 std::cout << std::endl;
125 std::cout <<
"!!!! TUTORIAL COMPLETED SUCCESSFULLY !!!!" << std::endl;
126 std::cout << std::endl;
T norm_2(std::vector< T, A > const &v1)
A reader and writer for the matrix market format is implemented here.
The stabilized bi-conjugate gradient method is implemented here.
A tag for the solver GMRES. Used for supplying solver parameters and for dispatching the solve() func...
Implementations of the generalized minimum residual method are in this file.
Implementations of incomplete factorization preconditioners. Convenience header file.
bool readVectorFromFile(const std::string &filename, VectorType &vec)
The conjugate gradient method is implemented here.
A tag for the conjugate gradient Used for supplying solver parameters and for dispatching the solve()...
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)
viennacl::vector< NumericT > solve(MatrixT const &A, viennacl::vector_base< NumericT > const &rhs, bicgstab_tag const &tag, viennacl::linalg::no_precond)
Implementation of a pipelined stabilized Bi-conjugate gradient solver.