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_OPERATOR_VECTOR_TYPES_HPP 00030 #define THYRA_OPERATOR_VECTOR_TYPES_HPP 00031 00032 #include "Thyra_ConfigDefs.hpp" 00033 #include "RTOpPack_Types.hpp" 00034 #include "Teuchos_Range1D.hpp" 00035 #include "Teuchos_RCP.hpp" 00036 #include "Teuchos_FancyOStream.hpp" 00037 #include "Teuchos_Array.hpp" 00038 #include "Teuchos_ArrayRCP.hpp" 00039 #include "Teuchos_ArrayView.hpp" 00040 #include "Teuchos_Tuple.hpp" 00041 #include "Teuchos_ParameterList.hpp" 00042 #include "Teuchos_ScalarTraits.hpp" 00043 #include "Teuchos_TypeNameTraits.hpp" 00044 00045 00046 namespace Thyra { 00047 00048 00049 // Using declarations from Teuchos 00050 00052 using Teuchos::Ptr; 00054 using Teuchos::RCP; 00056 using Teuchos::Array; 00058 using Teuchos::ArrayView; 00060 using Teuchos::ArrayRCP; 00062 using Teuchos::Tuple; 00064 using Teuchos::FancyOStream; 00066 using Teuchos::ParameterList; 00068 using Teuchos::ScalarTraits; 00070 using Teuchos::typeName; 00072 using Teuchos::TypeNameTraits; 00073 00078 00079 // 00080 // Basic types 00081 // 00082 00083 00085 typedef Teuchos::Range1D::Index Ordinal; 00086 00087 00089 typedef Ordinal Index; 00090 00091 00093 typedef Teuchos::Range1D Range1D; 00094 00095 00098 enum EConj { 00099 NONCONJ_ELE 00100 ,CONJ_ELE 00101 }; 00102 00103 00106 inline 00107 const char* toString(EConj conj) 00108 { 00109 switch(conj) { 00110 case NONCONJ_ELE: return "NONCONJ_ELE"; 00111 case CONJ_ELE: return "CONJ_ELE"; 00112 default: TEST_FOR_EXCEPT(true); 00113 } 00114 return "BAD"; // Should never be called! 00115 } 00116 00117 00120 enum EOpTransp { 00122 NOTRANS, 00126 CONJ, 00128 TRANS, 00132 CONJTRANS 00133 }; 00134 00135 00137 typedef EOpTransp ETransp; 00138 00139 00142 inline 00143 const char* toString(EOpTransp transp) 00144 { 00145 switch(transp) { 00146 case NOTRANS: return "NOTRANS"; 00147 case CONJ: return "CONJ"; 00148 case TRANS: return "TRANS"; 00149 case CONJTRANS: return "CONJTRANS"; 00150 default: TEST_FOR_EXCEPT(true); 00151 } 00152 return "BAD"; // Should never be called! 00153 } 00154 00155 00159 inline 00160 EOpTransp real_trans(EOpTransp transp) 00161 { 00162 switch(transp) { 00163 case NOTRANS: return NOTRANS; 00164 case CONJ: return NOTRANS; 00165 case TRANS: return TRANS; 00166 case CONJTRANS: return TRANS; 00167 default: TEST_FOR_EXCEPT(true); 00168 } 00169 return NOTRANS; // Will never be called! 00170 } 00171 00172 00175 inline 00176 EOpTransp not_trans( EOpTransp transp ) 00177 { 00178 switch(transp) { 00179 case NOTRANS: return TRANS; 00180 case CONJ: return CONJTRANS; 00181 case TRANS: return CONJ; 00182 case CONJTRANS: return NOTRANS; 00183 default: TEST_FOR_EXCEPT(true); 00184 } 00185 return NOTRANS; // Will never be called! 00186 } 00187 00188 00191 inline 00192 EOpTransp trans_trans( EOpTransp trans1, EOpTransp trans2 ) 00193 { 00194 if( trans1 == trans2 ) 00195 return NOTRANS; 00196 if( trans1 == NOTRANS ) 00197 return trans2; 00198 if( trans2 == NOTRANS ) 00199 return trans1; 00200 if( ( trans1 == CONJ && trans2 == TRANS ) || ( trans2 == CONJ && trans1 == TRANS ) ) 00201 return CONJTRANS; 00202 if( ( trans1 == TRANS && trans2 == CONJTRANS ) || ( trans2 == TRANS && trans1 == CONJTRANS ) ) 00203 return CONJ; 00204 if( ( trans1 == CONJ && trans2 == CONJTRANS ) || ( trans2 == CONJ && trans1 == CONJTRANS ) ) 00205 return TRANS; 00206 else 00207 TEST_FOR_EXCEPT(true); 00208 return NOTRANS; // Will never be executed! 00209 } 00210 00211 00214 inline 00215 EConj transToConj( EOpTransp trans ) 00216 { 00217 switch(trans) { 00218 case NOTRANS: return NONCONJ_ELE; 00219 case CONJ: return CONJ_ELE; 00220 case TRANS: return NONCONJ_ELE; 00221 case CONJTRANS: return CONJ_ELE; 00222 default: TEST_FOR_EXCEPT(true); 00223 } 00224 return NONCONJ_ELE; // Will never be called! 00225 } 00226 00229 inline 00230 EOpTransp applyConjToTrans( EConj conj ) { 00231 switch(conj) { 00232 case NONCONJ_ELE: return NOTRANS; 00233 case CONJ_ELE: return CONJ; 00234 default: TEST_FOR_EXCEPT(true); 00235 } 00236 return NOTRANS; // Will never be called! 00237 } 00238 00239 00242 inline 00243 EOpTransp applyTransposeConjToTrans( EConj conj ) { 00244 switch(conj) { 00245 case NONCONJ_ELE: return TRANS; 00246 case CONJ_ELE: return CONJTRANS; 00247 default: TEST_FOR_EXCEPT(true); 00248 } 00249 return NOTRANS; // Will never be called! 00250 } 00251 00255 enum EViewType { 00256 VIEW_TYPE_DIRECT 00257 ,VIEW_TYPE_DETACHED 00258 }; 00259 00260 00262 enum EStrideType { 00263 STRIDE_TYPE_UNIT 00264 ,STRIDE_TYPE_NONUNIT 00265 }; 00266 00267 00269 00270 00271 namespace Exceptions { 00272 00273 00278 00279 00281 class UnInitialized : public std::logic_error 00282 {public: UnInitialized(const std::string& what_arg) : std::logic_error(what_arg) {}}; 00283 00284 00286 class IncompatibleVectorSpaces : public std::logic_error 00287 {public: 00288 IncompatibleVectorSpaces(const std::string& what_arg) : std::logic_error(what_arg) {} 00289 // IncompatibleVectorSpaces(const IncompatibleVectorSpaces& ivs) : std::logic_error(ivs.what()) {} 00290 }; 00291 00292 00294 class OpNotSupported : public std::logic_error 00295 {public: OpNotSupported(const std::string& what_arg) : std::logic_error(what_arg) {}}; 00296 00297 00299 00300 00301 } // namespace Exceptions 00302 00303 00304 // Fundamental ANA operator/vector interface classes 00305 00306 00307 template<class Scalar> class VectorSpaceFactoryBase; 00308 template<class Scalar> class VectorSpaceBase; 00309 template<class RangeScalar, class DomainScalar = RangeScalar> class LinearOpBase; 00310 template<class Scalar> class MultiVectorBase; 00311 template<class Scalar> class VectorBase; 00312 00313 00314 } // end namespace Thyra 00315 00316 00317 #endif // THYRA_OPERATOR_VECTOR_TYPES_HPP
1.4.7