37 #include <Eigen/Sparse>
40 #define VIENNACL_WITH_EIGEN 1
57 int main(
int,
char *[])
61 Eigen::SparseMatrix<ScalarType, Eigen::RowMajor> eigen_matrix(65025, 65025);
62 Eigen::VectorXf eigen_rhs;
63 Eigen::VectorXf eigen_result;
64 Eigen::VectorXf ref_result;
65 Eigen::VectorXf residual;
70 std::cout <<
"Reading matrix (this might take some time)..." << std::endl;
71 eigen_matrix.reserve(65025 * 7);
74 std::cout <<
"Error reading Matrix file. Make sure you run from the build/-folder." << std::endl;
78 std::cout <<
"Done: reading matrix" << std::endl;
82 std::cout <<
"Error reading RHS file" << std::endl;
88 std::cout <<
"Error reading Result file" << std::endl;
95 std::cout <<
"----- Running CG -----" << std::endl;
98 residual = eigen_matrix * eigen_result - eigen_rhs;
104 std::cout <<
"----- Running BiCGStab -----" << std::endl;
107 residual = eigen_matrix * eigen_result - eigen_rhs;
113 std::cout <<
"----- Running GMRES -----" << std::endl;
116 residual = eigen_matrix * eigen_result - eigen_rhs;
122 std::cout << std::endl;
123 std::cout <<
"!!!! TUTORIAL COMPLETED SUCCESSFULLY !!!!" << std::endl;
124 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...
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.
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)