9 #include <cusp/linear_operator.h> 10 #include <cusp/csr_matrix.h> 11 #include <cusp/precond/diagonal.h> 12 #include <cusp/precond/aggregation/smoothed_aggregation.h> 13 #include <cusp/precond/ainv.h> 14 #include <cusp/detail/format.h> 23 template <
typename Matrix>
28 cusp::linear_operator<
typename Matrix::value_type,
29 typename Matrix::memory_space,
30 typename Matrix::index_type>*
LO;
36 typedef typename cusp::unknown_format
format;
48 void update(
const Matrix &A);
51 template <
typename VectorType1,
typename VectorType2>
52 void operator()(
const VectorType1 &x, VectorType2 &y)
const;
63 template <
class Matrix>
66 typedef typename Matrix::value_type ValueType;
67 typedef typename Matrix::index_type IndexType;
68 typedef typename Matrix::memory_space MemorySpace;
78 LO =
new cusp::precond::diagonal<ValueType, MemorySpace>(A);
81 LO =
new cusp::precond::aggregation::smoothed_aggregation<IndexType, ValueType, MemorySpace>(A);
84 LO =
new cusp::precond::nonsym_bridson_ainv<ValueType, MemorySpace>(A);
87 printf(
"Error: Unknown preconditionerType!\n");
96 template <
typename Matrix>
108 template <
class Matrix>
111 typedef typename Matrix::value_type ValueType;
112 typedef typename Matrix::index_type IndexType;
113 typedef typename Matrix::memory_space MemorySpace;
119 *
LO = cusp::precond::diagonal<ValueType, MemorySpace>(A);
122 *
LO = cusp::precond::aggregation::smoothed_aggregation<IndexType, ValueType, MemorySpace>(A);
125 *
LO = cusp::precond::nonsym_bridson_ainv<ValueType, MemorySpace>(A);
128 printf(
"Error: Unknown preconditionerType!\n");
138 template <
typename Matrix>
139 template <
typename VectorType1,
typename VectorType2>
152 cusp::precond::diagonal<value_type, memory_space> *diag =
153 static_cast<cusp::precond::diagonal<value_type, memory_space> *
>(
LO);
154 diag->operator()(x,y);
158 cusp::precond::aggregation::smoothed_aggregation<index_type, value_type, memory_space> *SA =
159 static_cast<cusp::precond::aggregation::smoothed_aggregation<index_type, value_type, memory_space> *
>(
LO);
164 cusp::precond::nonsym_bridson_ainv<value_type, memory_space> *AI =
165 static_cast<cusp::precond::nonsym_bridson_ainv<value_type, memory_space> *
>(
LO);
170 printf(
"Error: Unknown preconditionerType!\n");
Definition of custom types required by the code.
void operator()(const VectorType1 &x, VectorType2 &y) const
Overloads the operator (). This is required due to the way preconditioners are implemented in Cusp - ...
Stores the preconditioner for a given system.
preconditionerType type
type of preconditioner
Matrix::value_type value_type
cusp::unknown_format format
Matrix::memory_space memory_space
cusp::linear_operator<typename Matrix::value_type, typename Matrix::memory_space, typename Matrix::index_type > * LO
linear operator
preconditionerType
Specifies the type of preconditioner.
smoothed aggregation preconditioner
Matrix::index_type index_type
approximate inverse preconditioner
~preconditioner()
Destructor. Deletes the preconditioner.
void update(const Matrix &A)
Updates the preconditioner of the system.