Thyra::SerialLinearOpBase< Scalar > Class Template Reference

Base subclass for simplistic in-core serial linear operators. More...

#include <Thyra_SerialLinearOpBaseDecl.hpp>

Inheritance diagram for Thyra::SerialLinearOpBase< Scalar >:

Inheritance graph
[legend]
List of all members.

Overridden from EuclideanLinearOpBase

Teuchos::RCP< const ScalarProdVectorSpaceBase<
Scalar > > 
rangeScalarProdVecSpc () const
 
Teuchos::RCP< const ScalarProdVectorSpaceBase<
Scalar > > 
domainScalarProdVecSpc () const
 
void euclideanApply (const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, MultiVectorBase< Scalar > *Y, const Scalar alpha, const Scalar beta) const
 Calls protected euclideanApply() function.

Protected constructors/initializers/accessors

 STANDARD_MEMBER_COMPOSITION_MEMBERS (bool, forceUnitStride)
 Set if unit stride is forced for vector data views or not.
 SerialLinearOpBase ()
virtual void setSpaces (const Teuchos::RCP< const ScalarProdVectorSpaceBase< Scalar > > &range, const Teuchos::RCP< const ScalarProdVectorSpaceBase< Scalar > > &domain)
 Initialize vector spaces using pre-formed ScalarProdVectorSpaceBase objects.
virtual void setDimensions (const Index dimRange, const Index dimDomain)
 Initialize vector spaces given dimensions (uses DefaultSerialVectorSpace).

Protected virtual functions to be overridden by subclasses

virtual void euclideanApply (const EOpTransp M_trans, const RTOpPack::ConstSubVectorView< Scalar > &x, const RTOpPack::SubVectorView< Scalar > *y, const Scalar alpha, const Scalar beta) const =0
 Apply the operator to explicit vector data.
virtual void euclideanApply (const EOpTransp M_trans, const RTOpPack::ConstSubMultiVectorView< Scalar > &X, const RTOpPack::SubMultiVectorView< Scalar > *Y, const Scalar alpha, const Scalar beta) const
 Apply the operator to explicit multi-vector data.

Detailed Description

template<class Scalar>
class Thyra::SerialLinearOpBase< Scalar >

Base subclass for simplistic in-core serial linear operators.

This subclass defines machinery for developing concrete LinearOpBase subclasses for serial vectors where it is assumed that all of the elements in associated vectors and multi-vectors are immediately available.

This base subclass derives from EuclideanLinearOpBase and therefore any application-specific scalar products can easily be incorporated.

Notes to subclass developers

The only function that a subclass must override in order to provide a concrete implementation is the explicit single-vector version euclideanApply().

This function is called on the subclass implementation passing in views of explicit data. The raw pointers to the input and input/output arrays are passed in simple templated classes RTOpPack::ConstSubVectorView and RTOpPack::SubVectorView. Getting raw pointers out of these objects is easy.

It is very easy to create concrete subclasses of SerialLinearOpBase (see SerialTridiagLinearOp for a concrete example). All one has to do is to create a derived base class (MySerialLinearOp for example) of the form:

template<class Scalar>
class MySerialLinearOp : public SerialLinearOpBase<Scalar> {
private:
  // Declare your classes private data
  ...
public:
  // Declare you classes constructors, destructor, and other initialization functions
  ...
protected:
  // Override of the version of euclideanApply() that takes explicit vector data
  void euclideanApply(
    const EOpTransp                                M_trans
    ,const RTOpPack::ConstSubVectorView<Scalar>          &x_in
    ,const RTOpPack::SubVectorView<Scalar>   *y_out
    ,const Scalar                                alpha
    ,const Scalar                                beta
    ) const
    {
      // Get raw pointers to vector data to make me feel better!
      const Scalar *x     = x_in.values();
      const Index  x_dim  = x_in.subDim();
      Scalar       *y     = y_out->values();
      const Index  y_dim  = y_out->subDim();
      // Perform operation the operation
      if( real_trans(M_trans) == ::Thyra::NOTRANS ) {
        // Perform the non-transposed operation: y = alpha*M*x + beta*y
        ...
      }
      else {
        // Perform the transposed operation:     y = alpha*M'*x + beta*y
        ...
      }
  };

If you do not need to handle arbitrary scalar data types then you do not have to support them. For example, to define a subclass that only supports double you would declare a non-templated version of the form:

class MySerialLinearOp : public SerialLinearOpBase<double> {
private:
  // Declare your classes private data
  ...
public:
  // Declare you classes constructors, destructor and other initialization functions
  ...
protected:
  // Override of the version of euclideanApply() that takes explicit vector data
  void euclideanApply(
    const EOpTransp                                M_trans
    ,const RTOpPack::ConstSubVectorView<double>          &x_in
    ,const RTOpPack::SubVectorView<double>   *y_out
    ,const double                                alpha
    ,const double                                beta
    ) const
    {
      // Get raw pointers to vector data to make me feel better!
      const double *x     = x_in.values();
      const Index  x_dim  = x_in.subDim();
      double       *y     = y_out->values();
      const Index  y_dim  = y_out->subDim();
      // Perform operation the operation
      if( real_trans(M_trans) == ::Thyra::NOTRANS ) {
        // Perform the non-transposed operation: y = alpha*M*x + beta*y
        ...
      }
      else {
        // Perform the transposed operation:     y = alpha*M'*x + beta*y
        ...
      }
  };

By default, pointers to explicit data returned from x.values() and y->values() above are forced to have unit stride to simplify things. However, if your subclass can efficiently handle non-unit stride vector data (as the BLAS can for example) then you can allow this by calling the function this->forceUnitStride() and passing in false. The function this->forceUnitStride() can only be called by your subclasses as it is declared protected so do not worry about silly users messing with this, it is none of their business.

The explicit multi-vector version of euclideanApply() has a default implementation that calls the explicit single-vector version (that a subclass must supply) one column at a time. A subclass should only override this default multi-vector version if it can do something more efficient.

Definition at line 162 of file Thyra_SerialLinearOpBaseDecl.hpp.


Constructor & Destructor Documentation

template<class Scalar>
Thyra::SerialLinearOpBase< Scalar >::SerialLinearOpBase (  )  [protected]

Construct to uninitialized

Postconditions:

Definition at line 78 of file Thyra_SerialLinearOpBase.hpp.


Member Function Documentation

template<class Scalar>
Teuchos::RCP< const ScalarProdVectorSpaceBase< Scalar > > Thyra::SerialLinearOpBase< Scalar >::rangeScalarProdVecSpc (  )  const [virtual]

Implements Thyra::EuclideanLinearOpBase< Scalar >.

Definition at line 44 of file Thyra_SerialLinearOpBase.hpp.

template<class Scalar>
Teuchos::RCP< const ScalarProdVectorSpaceBase< Scalar > > Thyra::SerialLinearOpBase< Scalar >::domainScalarProdVecSpc (  )  const [virtual]

Implements Thyra::EuclideanLinearOpBase< Scalar >.

Definition at line 51 of file Thyra_SerialLinearOpBase.hpp.

template<class Scalar>
void Thyra::SerialLinearOpBase< Scalar >::euclideanApply ( const EOpTransp  M_trans,
const MultiVectorBase< Scalar > &  X,
MultiVectorBase< Scalar > *  Y,
const Scalar  alpha,
const Scalar  beta 
) const [virtual]

Calls protected euclideanApply() function.

Implements Thyra::SingleScalarEuclideanLinearOpBase< Scalar >.

Definition at line 57 of file Thyra_SerialLinearOpBase.hpp.

template<class Scalar>
Thyra::SerialLinearOpBase< Scalar >::STANDARD_MEMBER_COMPOSITION_MEMBERS ( bool  ,
forceUnitStride   
) [protected]

Set if unit stride is forced for vector data views or not.

Parameters:
forceUnitStride [in]
Postconditions:

template<class Scalar>
void Thyra::SerialLinearOpBase< Scalar >::setSpaces ( const Teuchos::RCP< const ScalarProdVectorSpaceBase< Scalar > > &  range,
const Teuchos::RCP< const ScalarProdVectorSpaceBase< Scalar > > &  domain 
) [protected, virtual]

Initialize vector spaces using pre-formed ScalarProdVectorSpaceBase objects.

Parameters:
range [in] Smart pointer to range space
domain [in] Smart pointer to domain space
Preconditions:

Postconditions:

Definition at line 83 of file Thyra_SerialLinearOpBase.hpp.

template<class Scalar>
void Thyra::SerialLinearOpBase< Scalar >::setDimensions ( const Index  dimRange,
const Index  dimDomain 
) [protected, virtual]

Initialize vector spaces given dimensions (uses DefaultSerialVectorSpace).

Parameters:
dimRange [in] The dimension of the serial range space
dimDomain [in] The dimension of the serial domain space
Preconditions:

Postconditions:

Definition at line 97 of file Thyra_SerialLinearOpBase.hpp.

template<class Scalar>
virtual void Thyra::SerialLinearOpBase< Scalar >::euclideanApply ( const EOpTransp  M_trans,
const RTOpPack::ConstSubVectorView< Scalar > &  x,
const RTOpPack::SubVectorView< Scalar > *  y,
const Scalar  alpha,
const Scalar  beta 
) const [protected, pure virtual]

Apply the operator to explicit vector data.

See LinearOpBase::euclideanApply() for a discussion of the arguments to this function. What differentiates this function is that x and y are passed as objects with explicit pointers to vector data.

Since this function is protected and does not get directly called by a client. Instead, this function is called by the vector version of euclideanApply().

template<class Scalar>
void Thyra::SerialLinearOpBase< Scalar >::euclideanApply ( const EOpTransp  M_trans,
const RTOpPack::ConstSubMultiVectorView< Scalar > &  X,
const RTOpPack::SubMultiVectorView< Scalar > *  Y,
const Scalar  alpha,
const Scalar  beta 
) const [protected, virtual]

Apply the operator to explicit multi-vector data.

See LinearOpBase::euclideanApply() for a discussion of the arguments to this function. What differentiates this function is that X and Y are passed as objects with explicit pointers to multi-vector data.

Since this function is protected and does not get directly called by a client. Instead, this function is called by the multi-vector version of euclideanApply().

The default implementation just calls the above vector version one column at a time. A subclass should only override this function if it can provide a cache-smart version. At any rate, one can get up and going very quickly by just providing an override for the simpler single-vector version. Then latter, if profiling data justifies it, one can provide a specialized override for this function in an attempt to improve performance.

Definition at line 113 of file Thyra_SerialLinearOpBase.hpp.


The documentation for this class was generated from the following files:
Generated on Wed May 12 21:42:35 2010 for Thyra Operator/Vector Support by  doxygen 1.4.7