10#ifndef ANASAZI_HELPER_TRAITS_HPP 
   11#define ANASAZI_HELPER_TRAITS_HPP 
   19#include "Teuchos_LAPACK.hpp" 
   30    template <
class ScalarType>
 
   40                    const std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& rRV,
 
   41                    const std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& iRV,
 
   42                    std::vector<
Value<ScalarType> >* RV, std::vector<int>* RO, std::vector<int>* RI );
 
   49                    const std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& iRV,
 
   50                    Teuchos::SerialDenseMatrix<int, ScalarType>* S );
 
   56                    const std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& iRV,
 
   57                    const Teuchos::SerialDenseMatrix<int, ScalarType>& S,
 
   58                    std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>* RR);
 
 
   63    template<
class ScalarType>
 
   65            const std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& rRV,
 
   66            const std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& iRV,
 
   69        typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;
 
   70        MagnitudeType MT_ZERO = Teuchos::ScalarTraits<MagnitudeType>::zero();
 
   72        int curDim = (int)rRV.size();
 
   80            if ( iRV[i] != MT_ZERO ) {
 
   83                (*RV)[i].set(rRV[i], iRV[i]);
 
   84                (*RV)[i+1].set(rRV[i+1], iRV[i+1]);
 
   87                if ( (*RV)[i].imagpart < MT_ZERO ) {
 
   90                    (*RV)[i] = (*RV)[i+1];
 
   91                    (*RV)[i+1] = tmp_ritz;
 
   93                    int tmp_order = (*RO)[i];
 
   94                    (*RO)[i] = (*RO)[i+1];
 
   95                    (*RO)[i+1] = tmp_order;
 
   98                RI->push_back(1); RI->push_back(-1);
 
  103                (*RV)[i].set(rRV[i], MT_ZERO);
 
 
  111    template<
class ScalarType>
 
  113            const std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& iRV,
 
  114            Teuchos::SerialDenseMatrix<int, ScalarType>* S )
 
  116        ScalarType ST_ONE = Teuchos::ScalarTraits<ScalarType>::one();
 
  118        typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;
 
  119        MagnitudeType MT_ZERO = Teuchos::ScalarTraits<MagnitudeType>::zero();
 
  121        Teuchos::LAPACK<int,MagnitudeType> lapack_mag;
 
  122        Teuchos::BLAS<int,ScalarType> blas;
 
  124        int i = 0, curDim = S->numRows();
 
  126        ScalarType* s_ptr = S->values();
 
  127        while( i < curDim ) {
 
  128            if ( iRV[i] != MT_ZERO ) {
 
  129                temp = lapack_mag.LAPY2( blas.NRM2( curDim, s_ptr+i*curDim, 1 ), 
 
  130                        blas.NRM2( curDim, s_ptr+(i+1)*curDim, 1 ) );
 
  131                blas.SCAL( curDim, ST_ONE/temp, s_ptr+i*curDim, 1 );
 
  132                blas.SCAL( curDim, ST_ONE/temp, s_ptr+(i+1)*curDim, 1 );
 
  135                temp = blas.NRM2( curDim, s_ptr+i*curDim, 1 );
 
  136                blas.SCAL( curDim, ST_ONE/temp, s_ptr+i*curDim, 1 );
 
 
  142    template<
class ScalarType>
 
  144            const std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& iRV,
 
  145            const Teuchos::SerialDenseMatrix<int, ScalarType>& S,
 
  146            std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>* RR )
 
  148        typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;
 
  149        MagnitudeType MT_ZERO = Teuchos::ScalarTraits<MagnitudeType>::zero();
 
  151        Teuchos::LAPACK<int,MagnitudeType> lapack_mag;
 
  152        Teuchos::BLAS<int,ScalarType> blas;
 
  155        int s_stride = S.stride();
 
  156        int s_rows = S.numRows();
 
  157        int s_cols = S.numCols();
 
  158        ScalarType* s_ptr = S.values();
 
  160        while( i < s_cols ) {
 
  161            if ( iRV[i] != MT_ZERO ) {
 
  162                (*RR)[i] = lapack_mag.LAPY2( blas.NRM2(s_rows, s_ptr + i*s_stride, 1),
 
  163                                             blas.NRM2(s_rows, s_ptr + (i+1)*s_stride, 1) );
 
  164                (*RR)[i+1] = (*RR)[i];
 
  167                (*RR)[i] = blas.NRM2(s_rows, s_ptr + i*s_stride, 1);
 
 
  173#ifdef HAVE_TEUCHOS_COMPLEX 
  188              const std::vector<T>& rRV, 
 
  189              const std::vector<T>& iRV,
 
  190              std::vector<
Value<std::complex<T> > >* RV, 
 
  191              std::vector<int>* RO, std::vector<int>* RI );
 
  194                const std::vector<T>& iRV,
 
  195                Teuchos::SerialDenseMatrix<
int, std::complex<T> >* S );
 
  198                const std::vector<T>& iRV,
 
  199                const Teuchos::SerialDenseMatrix<
int, std::complex<T> >& S,
 
  200                std::vector<T>* RR );
 
  204    void HelperTraits<std::complex<T> >::sortRitzValues( 
 
  205            const std::vector<T>& rRV, 
 
  206            const std::vector<T>& iRV,
 
  207            std::vector<Value<std::complex<T> > >* RV, 
 
  208            std::vector<int>* RO, std::vector<int>* RI )
 
  211        int curDim = (int)rRV.size();
 
  218        while( i < curDim ) {
 
  219            (*RV)[i].set(rRV[i], iRV[i]);
 
  226    void HelperTraits<std::complex<T> >::scaleRitzVectors( 
 
  227            const std::vector<T>& iRV,
 
  228            Teuchos::SerialDenseMatrix<
int, std::complex<T> >* S )
 
  231      typedef std::complex<T> ST;
 
  232      ST ST_ONE = Teuchos::ScalarTraits<ST>::one();
 
  234      Teuchos::BLAS<int,ST> blas;
 
  236      int i = 0, curDim = S->numRows();
 
  238      ST* s_ptr = S->values();
 
  239      while( i < curDim ) {
 
  240        temp = blas.NRM2( curDim, s_ptr+i*curDim, 1 );
 
  241        blas.SCAL( curDim, ST_ONE/temp, s_ptr+i*curDim, 1 );
 
  247    void HelperTraits<std::complex<T> >::computeRitzResiduals( 
 
  248            const std::vector<T>& iRV,
 
  249            const Teuchos::SerialDenseMatrix<
int, std::complex<T> >& S,
 
  253        Teuchos::BLAS<int,std::complex<T> > blas;
 
  255        int s_stride = S.stride();
 
  256        int s_rows = S.numRows();
 
  257        int s_cols = S.numCols();
 
  258        std::complex<T>* s_ptr = S.values();
 
  260        for (
int i=0; i<s_cols; ++i ) {
 
  261            (*RR)[i] = blas.NRM2(s_rows, s_ptr + i*s_stride, 1);
 
Anasazi header file which uses auto-configuration information to include necessary C++ headers.
 
Types and exceptions used within Anasazi solvers and interfaces.
 
Class which defines basic traits for working with different scalar types.
 
static void computeRitzResiduals(const std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &iRV, const Teuchos::SerialDenseMatrix< int, ScalarType > &S, std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > *RR)
Helper function for correctly computing the Ritz residuals of the projected eigenproblem.
 
static void scaleRitzVectors(const std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &iRV, Teuchos::SerialDenseMatrix< int, ScalarType > *S)
Helper function for correctly scaling the eigenvectors of the projected eigenproblem.
 
static void sortRitzValues(const std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &rRV, const std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &iRV, std::vector< Value< ScalarType > > *RV, std::vector< int > *RO, std::vector< int > *RI)
Helper function for correctly storing the Ritz values when the eigenproblem is non-Hermitian.
 
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package.
 
This struct is used for storing eigenvalues and Ritz values, as a pair of real values.