1 #ifndef VIENNACL_LINALG_JACOBI_PRECOND_HPP_
2 #define VIENNACL_LINALG_JACOBI_PRECOND_HPP_
48 template <
typename MatrixType,
49 bool is_viennacl = detail::row_scaling_for_viennacl<MatrixType>::value >
52 typedef typename MatrixType::value_type ScalarType;
60 void init(MatrixType
const & mat)
64 for (
typename MatrixType::const_iterator1 row_it = mat.begin1();
68 bool diag_found =
false;
69 for (
typename MatrixType::const_iterator2 col_it = row_it.begin();
70 col_it != row_it.end();
73 if (col_it.index1() == col_it.index2())
75 diag_A[col_it.index1()] = *col_it;
80 throw "ViennaCL: Zero in diagonal encountered while setting up Jacobi preconditioner!";
86 template <
typename VectorType>
87 void apply(VectorType & vec)
const
95 std::vector<ScalarType> diag_A;
103 template <
typename MatrixType>
115 void init(MatrixType
const & mat)
121 template <
unsigned int ALIGNMENT>
viennacl::vector_expression< const vector_base< T >, const vector_base< T >, op_element_binary< op_div > > element_div(vector_base< T > const &v1, vector_base< T > const &v2)
std::size_t vcl_size_t
Definition: forwards.h:58
Jacobi preconditioner class, can be supplied to solve()-routines. Generic version for non-ViennaCL ma...
Definition: jacobi_precond.hpp:50
vcl_size_t size1(MatrixType const &mat)
Generic routine for obtaining the number of rows of a matrix (ViennaCL, uBLAS, etc.)
Definition: size.hpp:216
This file provides the forward declarations for the main types used within ViennaCL.
A tag for a jacobi preconditioner.
Definition: jacobi_precond.hpp:43
Represents a generic 'context' similar to an OpenCL context, but is backend-agnostic and thus also su...
Definition: context.hpp:39
Meta function which checks whether a tag is tag_viennacl.
Definition: tag_of.hpp:364
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:29
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Definition: size.hpp:144
Implementation of the compressed_matrix class.
Implementations of operations using sparse matrices.
void init(MatrixType const &mat)
Definition: jacobi_precond.hpp:60
A row normalization preconditioner is implemented here.
A vector class representing a linear memory sequence on the GPU. Inspired by boost::numeric::ublas::v...
Definition: forwards.h:208
T::ERROR_CANNOT_DEDUCE_CPU_SCALAR_TYPE_FOR_T type
Definition: result_of.hpp:276
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
void apply(viennacl::vector< ScalarType, ALIGNMENT > &vec) const
Definition: jacobi_precond.hpp:122
viennacl::enable_if< viennacl::is_any_sparse_matrix< SparseMatrixType >::value >::type row_info(SparseMatrixType const &mat, vector< SCALARTYPE, VEC_ALIGNMENT > &vec, row_info_types info_selector)
Definition: sparse_matrix_operations.hpp:50
jacobi_precond(MatrixType const &mat, jacobi_tag const &)
Definition: jacobi_precond.hpp:109
jacobi_precond(MatrixType const &mat, jacobi_tag const &)
Definition: jacobi_precond.hpp:55
void apply(VectorType &vec) const
Apply to res = b - Ax, i.e. jacobi applied vec (right hand side),.
Definition: jacobi_precond.hpp:87
void init(MatrixType const &mat)
Definition: jacobi_precond.hpp:115
Definition: forwards.h:696