// @HEADER // ***************************************************************************** // Anasazi: Block Eigensolvers Package // // Copyright 2004 NTESS and the Anasazi contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef MY_BETTER_OPERATOR_HPP #define MY_BETTER_OPERATOR_HPP #include "AnasaziConfigDefs.hpp" #include "AnasaziOperator.hpp" #include "MyMultiVec.hpp" #include "Teuchos_BLAS.hpp" //! Simple example of a user's defined Anasazi::Operator class. /*! * This is a simple, single processor example of user's defined * Anasazi::Operator-derived class. The class is templated with ScalarType; * possible choices are, for example, "float", "double", or * "complex". * * This class is based on the MyOperator class written by * Oscar Chinallato (ETHZ/ICOS) and Marzio Sala (ETHZ/COLAB) * * \author Christopher Baker (FSU/SCS,SNL/CSRI) * */ template class MyBetterOperator : public Anasazi::Operator { public: //! Constructor MyBetterOperator(const int nrows, const int *colptr, const int nnz, const int *rowin, const ScalarType *vals) : _nr(nrows), _nnz(nnz), _cptr(nrows+1), _rind(nnz), _vals(nnz) { std::copy(colptr,colptr+nrows+1,_cptr.begin()); std::copy(rowin,rowin+nnz,_rind.begin()); std::copy(vals,vals+nnz,_vals.begin()); } //! Deconstructor ~MyBetterOperator() { } //! Applies the matrix to a multivector. void Apply(const Anasazi::MultiVec& X, Anasazi::MultiVec& Y) const { const MyMultiVec* MyX; MyX = dynamic_cast*>(&X); assert (MyX != 0); MyMultiVec* MyY; MyY = dynamic_cast*>(&Y); assert (MyY != 0); // Initialize output vector to zero. MyY->MvInit( Teuchos::ScalarTraits::zero() ); assert (X.GetNumberVecs() == Y.GetNumberVecs()); assert (X.GetGlobalLength() == Y.GetGlobalLength()); int nv = X.GetNumberVecs(); // Apply operator int IA1, IA2, ri; ScalarType aval; int i,j,v; for (j=0; j<_nr; j++) { IA1 = _cptr[j]-1; IA2 = _cptr[j+1]-1; for (i=IA1; i::iterator STIter; typedef std::vector::iterator IntIter; //! Number of rows and columns int _nr, _nnz; //! Column pointers std::vector _cptr; //! Row indices std::vector _rind; //! Values std::vector _vals; }; #endif //MY_BETTER_OPERATOR_HPP