12 #ifndef MY_BETTER_OPERATOR_HPP
13 #define MY_BETTER_OPERATOR_HPP
33 template <
class ScalarType>
41 const int nnz,
const int *rowin,
const ScalarType *vals)
44 std::copy<const int*,IntIter>(colptr,colptr+nrows+1,
_cptr.begin());
45 std::copy<const int*,IntIter>(rowin,rowin+nnz,
_rind.begin());
46 std::copy<const ScalarType*,STIter>(vals,vals+nnz,
_vals.begin());
78 for (j=0; j<
_nr; j++) {
81 for (i=IA1; i<IA2; i++) {
84 for (v=0; v<nv; v++) {
85 (*MyY)[v][ri] += aval*(*MyX)[v][j];
91 void Print( std::ostream& os ) {
92 for (
int j=0; j<
_nr; j++) {
94 int IA2 =
_cptr[j+1]-1;
95 for (
int i=IA1; i<IA2; i++) {
96 os <<
"("<<
_rind[i]-1<<
","<<j<<
")\t"<<
_vals[i]<< std::endl;
102 typedef typename std::vector<ScalarType>::iterator
STIter;
114 #endif //MY_BETTER_OPERATOR_HPP
std::vector< int >::iterator IntIter
std::vector< ScalarType >::iterator STIter
void Apply(const Belos::MultiVec< ScalarType > &X, Belos::MultiVec< ScalarType > &Y, Belos::ETrans trans=Belos::NOTRANS) const
Applies the matrix to a multivector.
MyBetterOperator(const int nrows, const int *colptr, const int nnz, const int *rowin, const ScalarType *vals)
Constructor.
~MyBetterOperator()
Deconstructor.
virtual int GetNumberVecs() const =0
The number of vectors (i.e., columns) in the multivector.
std::vector< ScalarType > _vals
Values.
void Print(std::ostream &os)
virtual ptrdiff_t GetGlobalLength() const =0
The number of rows in the multivector.
ETrans
Whether to apply the (conjugate) transpose of an operator.
Simple example of a user's defined Belos::MultiVec class.
Alternative run-time polymorphic interface for operators.
std::vector< int > _rind
Row indices.
std::vector< int > _cptr
Column pointers.
Alternative run-time polymorphic interface for operators.
Interface for multivectors used by Belos' linear solvers.
Belos header file which uses auto-configuration information to include necessary C++ headers...
void MvInit(const ScalarType alpha)
Replace each element of the vectors in *this with alpha.
Simple example of a user's defined Belos::Operator class.
int _nr
Number of rows and columns.