Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_OperatorVectorTypes.hpp
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef THYRA_OPERATOR_VECTOR_TYPES_HPP
43 #define THYRA_OPERATOR_VECTOR_TYPES_HPP
44 
45 #include "Thyra_ConfigDefs.hpp"
46 #include "RTOpPack_Types.hpp"
47 #include "Teuchos_Range1D.hpp"
48 #include "Teuchos_RCP.hpp"
49 #include "Teuchos_FancyOStream.hpp"
50 #include "Teuchos_Array.hpp"
51 #include "Teuchos_ArrayRCP.hpp"
52 #include "Teuchos_ArrayView.hpp"
53 #include "Teuchos_Tuple.hpp"
54 #include "Teuchos_ParameterList.hpp"
55 #include "Teuchos_ScalarTraits.hpp"
56 #include "Teuchos_TypeNameTraits.hpp"
57 
58 
59 namespace Thyra {
60 
61 // Using declarations from Teuchos
62 
67 using Teuchos::Ptr;
72 using Teuchos::RCP;
77 using Teuchos::Array;
82 using Teuchos::ArrayView;
87 using Teuchos::ArrayRCP;
92 using Teuchos::Tuple;
117 using Teuchos::typeName;
128 
129 
134 enum EConj {
137 };
138 
139 
144 inline
145 const char* toString(EConj conj)
146 {
147  switch(conj) {
148  case NONCONJ_ELE: return "NONCONJ_ELE";
149  case CONJ_ELE: return "CONJ_ELE";
150  default: TEUCHOS_TEST_FOR_EXCEPT(true);
151  }
152  // return "BAD"; // Should never be called!
153 }
154 
155 
160 enum EOpTransp {
173 };
174 
175 
180 inline
181 const char* toString(EOpTransp transp)
182 {
183  switch(transp) {
184  case NOTRANS: return "NOTRANS";
185  case CONJ: return "CONJ";
186  case TRANS: return "TRANS";
187  case CONJTRANS: return "CONJTRANS";
188  default: TEUCHOS_TEST_FOR_EXCEPT(true);
189  }
190  // return "BAD"; // Should never be called!
191 }
192 
193 
199 inline
201 {
202  switch(transp) {
203  case NOTRANS: return NOTRANS;
204  case CONJ: return NOTRANS;
205  case TRANS: return TRANS;
206  case CONJTRANS: return TRANS;
207  default: TEUCHOS_TEST_FOR_EXCEPT(true);
208  }
209  // return NOTRANS; // Will never be called!
210 }
211 
212 
217 inline
219 {
220  switch(transp) {
221  case NOTRANS: return TRANS;
222  case CONJ: return CONJTRANS;
223  case TRANS: return CONJ;
224  case CONJTRANS: return NOTRANS;
225  default: TEUCHOS_TEST_FOR_EXCEPT(true);
226  }
227  // return NOTRANS; // Will never be called!
228 }
229 
230 
235 inline
237 {
238  if( trans1 == trans2 )
239  return NOTRANS;
240  if( trans1 == NOTRANS )
241  return trans2;
242  if( trans2 == NOTRANS )
243  return trans1;
244  if( ( trans1 == CONJ && trans2 == TRANS ) || ( trans2 == CONJ && trans1 == TRANS ) )
245  return CONJTRANS;
246  if( ( trans1 == TRANS && trans2 == CONJTRANS ) || ( trans2 == TRANS && trans1 == CONJTRANS ) )
247  return CONJ;
248  if( ( trans1 == CONJ && trans2 == CONJTRANS ) || ( trans2 == CONJ && trans1 == CONJTRANS ) )
249  return TRANS;
250  else
252  // return NOTRANS; // Will never be executed!
253 }
254 
255 
260 inline
262 {
263  switch(trans) {
264  case NOTRANS: return NONCONJ_ELE;
265  case CONJ: return CONJ_ELE;
266  case TRANS: return NONCONJ_ELE;
267  case CONJTRANS: return CONJ_ELE;
268  default: TEUCHOS_TEST_FOR_EXCEPT(true);
269  }
270  // return NONCONJ_ELE; // Will never be called!
271 }
272 
277 inline
279 {
280  switch(conj) {
281  case NONCONJ_ELE: return NOTRANS;
282  case CONJ_ELE: return CONJ;
283  default: TEUCHOS_TEST_FOR_EXCEPT(true);
284  }
285  // return NOTRANS; // Will never be called!
286 }
287 
288 
293 inline
295 {
296  switch(conj) {
297  case NONCONJ_ELE: return TRANS;
298  case CONJ_ELE: return CONJTRANS;
299  default: TEUCHOS_TEST_FOR_EXCEPT(true);
300  }
301  // return NOTRANS; // Will never be called!
302 }
303 
309 enum EViewType {
312 };
313 
314 
324 };
325 
326 
327 namespace Exceptions {
328 
329 
335 class UnInitialized : public std::logic_error
336 {public: UnInitialized(const std::string& what_arg)
337  : std::logic_error(what_arg) {}};
338 
339 
344 class IncompatibleVectorSpaces : public std::logic_error
345 {public:
346  IncompatibleVectorSpaces(const std::string& what_arg)
347  : std::logic_error(what_arg) {}
348 };
349 
350 
355 class OpNotSupported : public std::logic_error
356 {public: OpNotSupported(const std::string& what_arg)
357  : std::logic_error(what_arg) {}};
358 
359 
360 } // namespace Exceptions
361 
362 
363 // Fundamental ANA operator/vector interface classes
364 
365 
366 template<class Scalar> class VectorSpaceFactoryBase;
367 template<class Scalar> class VectorSpaceBase;
368 template<class Scalar> class LinearOpBase;
369 template<class Scalar> class MultiVectorBase;
370 template<class Scalar> class VectorBase;
371 
372 
373 } // end namespace Thyra
374 
375 
376 #endif // THYRA_OPERATOR_VECTOR_TYPES_HPP
Use the linear operator with conjugate elements.
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
Thrown if vector spaces are incompatible.
The view is a direct view of data and no copies are made.
The stride between elements in an array is greater than or equal to one.
basic_FancyOStream< char > FancyOStream
Use the non-transposed operator.
EOpTransp real_trans(EOpTransp transp)
Return NOTRANS or TRANS for real scalar valued operators and this also is used for determining struct...
Use the transposed operator with complex-conjugate clements (same as TRANS for real scalar types)...
EOpTransp not_trans(EOpTransp transp)
Perform a not operation on an EOpTransp value.
Abstract interface for objects that represent a space for vectors.
EViewType
Determines if a view is a direct view of data or a detached copy of data.
EConj transToConj(EOpTransp trans)
Convert from EOpTransp to EConj.
Use the non-transposed operator with complex-conjugate elements (same as NOTRANS for real scalar type...
The view is a detached copy of the data.
Abstract interface for objects that can create vector spaces of a specified dimension.
Use the transposed operator.
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
Interface for a collection of column vectors called a multi-vector.
Thrown if any member functions are called before initialize() has been called.
EOpTransp trans_trans(EOpTransp trans1, EOpTransp trans2)
Combine two transpose arguments.
Abstract interface for finite-dimensional dense vectors.
TEUCHOSCORE_LIB_DLL_EXPORT std::string toString(const EVerbosityLevel verbLevel)
EOpTransp applyConjToTrans(EConj conj)
Convert from EConj to EOpTransp for forward apply.
The stride between elements in an array is one.
Base class for all linear operators.
Use the linear operator with non-conjugate elements.
EStrideType
Determine if data is unit stride or non-unit stride.
EOpTransp applyTransposeConjToTrans(EConj conj)
Convert from EConj to EOpTransp for forward apply.
EConj
Enumeration for determining how a linear operator is applied. `*.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
std::string typeName(const T &t)
Teuchos::Range1D Range1D