Thyra_SerialLinearOpBase.hpp

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //    Thyra: Interfaces and Support for Abstract Numerical Algorithms
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifndef THYRA_SERIAL_LINEAR_OP_BASE_HPP
00030 #define THYRA_SERIAL_LINEAR_OP_BASE_HPP
00031 
00032 #include "Thyra_SerialLinearOpBaseDecl.hpp"
00033 #include "Thyra_EuclideanLinearOpBase.hpp"
00034 #include "Thyra_DefaultSerialVectorSpace.hpp"
00035 #include "Thyra_DetachedVectorView.hpp"
00036 #include "Thyra_DetachedMultiVectorView.hpp"
00037 
00038 namespace Thyra {
00039 
00040 // Overridden from EuclideanLinearOpBase
00041 
00042 template<class Scalar>
00043 Teuchos::RefCountPtr< const ScalarProdVectorSpaceBase<Scalar> >
00044 SerialLinearOpBase<Scalar>::rangeScalarProdVecSpc() const
00045 {
00046   return range_;
00047 }
00048 
00049 template<class Scalar>
00050 Teuchos::RefCountPtr< const ScalarProdVectorSpaceBase<Scalar> >
00051 SerialLinearOpBase<Scalar>::domainScalarProdVecSpc() const
00052 {
00053   return domain_;
00054 }
00055 
00056 template<class Scalar>
00057 void SerialLinearOpBase<Scalar>::euclideanApply(
00058   const ETransp                     M_trans
00059   ,const MultiVectorBase<Scalar>    &X
00060   ,MultiVectorBase<Scalar>          *Y
00061   ,const Scalar                     alpha
00062   ,const Scalar                     beta
00063   ) const
00064 {
00065 #ifdef TEUCHOS_DEBUG
00066   THYRA_ASSERT_LINEAR_OP_MULTIVEC_APPLY_SPACES("SerialLinearOpBase<Scalar>::apply()",*this,M_trans,X,Y);
00067 #endif
00068   const ConstDetachedMultiVectorView<Scalar>         X_ev(X);
00069   const DetachedMultiVectorView<Scalar>  Y_ev(*Y);
00070   this->euclideanApply(M_trans,X_ev.smv(),&Y_ev.smv(),alpha,beta);
00071 }
00072 
00073 // protected
00074 
00075 // Constructors/initializers/accessors
00076 
00077 template<class Scalar>
00078 SerialLinearOpBase<Scalar>::SerialLinearOpBase()
00079   :forceUnitStride_(true)
00080 {}
00081 
00082 template<class Scalar>
00083 void SerialLinearOpBase<Scalar>::setSpaces(
00084   const Teuchos::RefCountPtr<const ScalarProdVectorSpaceBase<Scalar> >     &range
00085   ,const Teuchos::RefCountPtr<const ScalarProdVectorSpaceBase<Scalar> >    &domain
00086   )
00087 {
00088 #ifdef TEUCHOS_DEBUG
00089   TEST_FOR_EXCEPT(range.get()==NULL);
00090   TEST_FOR_EXCEPT(domain.get()==NULL);
00091 #endif
00092   range_  = range;
00093   domain_ = domain;
00094 }
00095 
00096 template<class Scalar>
00097 void SerialLinearOpBase<Scalar>::setDimensions(
00098   const Index                                                dimRange
00099   ,const Index                                               dimDomain
00100   )
00101 {
00102 #ifdef TEUCHOS_DEBUG
00103   TEST_FOR_EXCEPT( dimRange <= 0 );
00104   TEST_FOR_EXCEPT( dimDomain <= 0 );
00105 #endif
00106   range_  = Teuchos::rcp(new DefaultSerialVectorSpace<Scalar>(dimRange));
00107   domain_ = Teuchos::rcp(new DefaultSerialVectorSpace<Scalar>(dimDomain));
00108 }
00109 
00110 // Virtual functions to be overridden by subclasses
00111 
00112 template<class Scalar>
00113 void SerialLinearOpBase<Scalar>::euclideanApply(
00114   const ETransp                                     M_trans
00115   ,const RTOpPack::ConstSubMultiVectorView<Scalar>          &X
00116   ,const RTOpPack::SubMultiVectorView<Scalar>   *Y
00117   ,const Scalar                                     alpha
00118   ,const Scalar                                     beta
00119   ) const
00120 {
00121   for(Index j = 0; j < X.numSubCols(); ++j ) {
00122     const RTOpPack::ConstSubVectorView<Scalar>         X_j = X.col(j);
00123     const RTOpPack::SubVectorView<Scalar>  Y_j = Y->col(j);
00124     this->euclideanApply(M_trans,X_j,&Y_j,alpha,beta);
00125   }
00126 }
00127 
00128 } // end namespace Thyra
00129 
00130 #endif  // THYRA_SERIAL_LINEAR_OP_BASE_HPP

Generated on Thu Sep 18 12:33:03 2008 for Thyra Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1