Thyra Version of the Day
Thyra_OperatorVectorTypes.hpp
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 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov) 
00038 // 
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 #ifndef THYRA_OPERATOR_VECTOR_TYPES_HPP
00043 #define THYRA_OPERATOR_VECTOR_TYPES_HPP
00044 
00045 #include "Thyra_ConfigDefs.hpp"
00046 #include "RTOpPack_Types.hpp"
00047 #include "Teuchos_Range1D.hpp"
00048 #include "Teuchos_RCP.hpp"
00049 #include "Teuchos_FancyOStream.hpp"
00050 #include "Teuchos_Array.hpp"
00051 #include "Teuchos_ArrayRCP.hpp"
00052 #include "Teuchos_ArrayView.hpp"
00053 #include "Teuchos_Tuple.hpp"
00054 #include "Teuchos_ParameterList.hpp"
00055 #include "Teuchos_ScalarTraits.hpp"
00056 #include "Teuchos_TypeNameTraits.hpp"
00057 
00058 
00059 namespace Thyra {
00060 
00061 // Using declarations from Teuchos
00062 
00067 using Teuchos::Ptr;
00072 using Teuchos::RCP;
00077 using Teuchos::Array;
00082 using Teuchos::ArrayView;
00087 using Teuchos::ArrayRCP;
00092 using Teuchos::Tuple;
00097 typedef Teuchos::Range1D Range1D;
00102 using Teuchos::FancyOStream;
00107 using Teuchos::ParameterList;
00112 using Teuchos::ScalarTraits;
00117 using Teuchos::typeName;
00122 using Teuchos::TypeNameTraits;
00127 typedef Teuchos::Ordinal Ordinal;
00128 
00129 
00134 enum EConj {
00135   NONCONJ_ELE     
00136   ,CONJ_ELE       
00137 };
00138 
00139 
00144 inline
00145 const char* toString(EConj conj)
00146 {
00147   switch(conj) {
00148     case NONCONJ_ELE:    return "NONCONJ_ELE";
00149     case CONJ_ELE:       return "CONJ_ELE";
00150     default: TEUCHOS_TEST_FOR_EXCEPT(true);
00151   }
00152   return "BAD"; // Should never be called!
00153 }
00154 
00155 
00160 enum EOpTransp {
00162   NOTRANS,
00166   CONJ,
00168   TRANS,
00172   CONJTRANS
00173 };
00174 
00175 
00180 inline
00181 const char* toString(EOpTransp transp)
00182 {
00183   switch(transp) {
00184     case NOTRANS:    return "NOTRANS";
00185     case CONJ:       return "CONJ";
00186     case TRANS:      return "TRANS";
00187     case CONJTRANS:  return "CONJTRANS";
00188     default: TEUCHOS_TEST_FOR_EXCEPT(true);
00189   }
00190   return "BAD"; // Should never be called!
00191 }
00192 
00193 
00199 inline
00200 EOpTransp real_trans(EOpTransp transp)
00201 {
00202   switch(transp) {
00203     case NOTRANS:    return NOTRANS;
00204     case CONJ:       return NOTRANS;
00205     case TRANS:      return TRANS;
00206     case CONJTRANS:  return TRANS;
00207     default: TEUCHOS_TEST_FOR_EXCEPT(true);
00208   }
00209   return NOTRANS; // Will never be called!
00210 }
00211 
00212 
00217 inline 
00218 EOpTransp not_trans( EOpTransp transp )
00219 {
00220   switch(transp) {
00221     case NOTRANS:    return TRANS;
00222     case CONJ:       return CONJTRANS;
00223     case TRANS:      return CONJ;
00224     case CONJTRANS:  return NOTRANS;
00225     default: TEUCHOS_TEST_FOR_EXCEPT(true);
00226   }
00227   return NOTRANS; // Will never be called!
00228 }
00229 
00230 
00235 inline
00236 EOpTransp trans_trans( EOpTransp trans1, EOpTransp trans2 )
00237 {
00238   if( trans1 == trans2 )
00239     return NOTRANS;
00240   if( trans1 == NOTRANS )
00241     return trans2;
00242   if( trans2 == NOTRANS )
00243     return trans1;
00244   if( ( trans1 == CONJ && trans2 == TRANS ) || ( trans2 == CONJ && trans1 == TRANS ) )
00245     return CONJTRANS;
00246   if( ( trans1 == TRANS && trans2 == CONJTRANS ) || ( trans2 == TRANS && trans1 == CONJTRANS ) )
00247     return CONJ;
00248   if( ( trans1 == CONJ && trans2 == CONJTRANS ) || ( trans2 == CONJ && trans1 == CONJTRANS ) )
00249     return TRANS;
00250   else
00251     TEUCHOS_TEST_FOR_EXCEPT(true);
00252   return NOTRANS; // Will never be executed!
00253 }
00254 
00255 
00260 inline
00261 EConj transToConj( EOpTransp trans )
00262 {
00263   switch(trans) {
00264     case NOTRANS:    return NONCONJ_ELE;
00265     case CONJ:       return CONJ_ELE;
00266     case TRANS:      return NONCONJ_ELE;
00267     case CONJTRANS:  return CONJ_ELE;
00268     default: TEUCHOS_TEST_FOR_EXCEPT(true);
00269   }
00270   return NONCONJ_ELE; // Will never be called!
00271 }
00272 
00277 inline
00278 EOpTransp applyConjToTrans( EConj conj )
00279 {
00280   switch(conj) {
00281     case NONCONJ_ELE: return NOTRANS;
00282     case CONJ_ELE:    return CONJ;
00283     default: TEUCHOS_TEST_FOR_EXCEPT(true);
00284   }
00285   return NOTRANS; // Will never be called!
00286 }
00287 
00288 
00293 inline
00294 EOpTransp applyTransposeConjToTrans( EConj conj )
00295 {
00296   switch(conj) {
00297     case NONCONJ_ELE: return TRANS;
00298     case CONJ_ELE:    return CONJTRANS;
00299     default: TEUCHOS_TEST_FOR_EXCEPT(true);
00300   }
00301   return NOTRANS; // Will never be called!
00302 }
00303 
00309 enum EViewType {
00310   VIEW_TYPE_DIRECT   
00311   ,VIEW_TYPE_DETACHED  
00312 };
00313 
00314 
00319 enum EStrideType {
00321   STRIDE_TYPE_UNIT,
00323   STRIDE_TYPE_NONUNIT
00324 };
00325 
00326 
00327 namespace Exceptions {
00328 
00329 
00335 class UnInitialized : public std::logic_error
00336 {public: UnInitialized(const std::string& what_arg)
00337    : std::logic_error(what_arg) {}};
00338 
00339 
00344 class IncompatibleVectorSpaces : public std::logic_error
00345 {public:
00346   IncompatibleVectorSpaces(const std::string& what_arg)
00347     : std::logic_error(what_arg) {}
00348 };
00349 
00350 
00355 class OpNotSupported : public std::logic_error
00356 {public: OpNotSupported(const std::string& what_arg)
00357    : std::logic_error(what_arg) {}};
00358 
00359 
00360 } // namespace Exceptions
00361 
00362 
00363 // Fundamental ANA operator/vector interface classes
00364 
00365 
00366 template<class Scalar> class VectorSpaceFactoryBase;
00367 template<class Scalar> class VectorSpaceBase;
00368 template<class Scalar> class LinearOpBase;
00369 template<class Scalar> class MultiVectorBase;
00370 template<class Scalar> class VectorBase;
00371 
00372 
00373 } // end namespace Thyra
00374 
00375 
00376 #endif // THYRA_OPERATOR_VECTOR_TYPES_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines