Thyra Version of the Day
Loading...
Searching...
No Matches
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"
57
58
59namespace Thyra {
60
61// Using declarations from Teuchos
62
67using Teuchos::Ptr;
72using Teuchos::RCP;
77using Teuchos::Array;
92using Teuchos::Tuple;
127typedef Teuchos::Ordinal Ordinal;
128
129
138
139
144inline
145const 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
174
175
180inline
181const 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
199inline
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
217inline
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
235inline
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
260inline
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
277inline
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
293inline
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
313
314
325
326
327namespace Exceptions {
328
329
335class UnInitialized : public std::logic_error
336{public: UnInitialized(const std::string& what_arg)
337 : std::logic_error(what_arg) {}};
338
339
344class IncompatibleVectorSpaces : public std::logic_error
345{public:
346 IncompatibleVectorSpaces(const std::string& what_arg)
347 : std::logic_error(what_arg) {}
348};
349
350
355class 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
366template<class Scalar> class VectorSpaceFactoryBase;
367template<class Scalar> class VectorSpaceBase;
368template<class Scalar> class LinearOpBase;
369template<class Scalar> class MultiVectorBase;
370template<class Scalar> class VectorBase;
371
372
373} // end namespace Thyra
374
375
376#endif // THYRA_OPERATOR_VECTOR_TYPES_HPP
Thrown if vector spaces are incompatible.
Thrown if any member functions are called before initialize() has been called.
Base class for all linear operators.
Interface for a collection of column vectors called a multi-vector.
Abstract interface for finite-dimensional dense vectors.
Abstract interface for objects that represent a space for vectors.
Abstract interface for objects that can create vector spaces of a specified dimension.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
EConj
Enumeration for determining how a linear operator is applied. `*.
EStrideType
Determine if data is unit stride or non-unit stride.
EOpTransp applyTransposeConjToTrans(EConj conj)
Convert from EConj to EOpTransp for forward apply.
EConj transToConj(EOpTransp trans)
Convert from EOpTransp to EConj.
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
EViewType
Determines if a view is a direct view of data or a detached copy of data.
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
EOpTransp applyConjToTrans(EConj conj)
Convert from EConj to EOpTransp for forward apply.
Teuchos::Range1D Range1D
const char * toString(EConj conj)
Return a string name for a EOpTransp value. `*.
EOpTransp not_trans(EOpTransp transp)
Perform a not operation on an EOpTransp value.
EOpTransp real_trans(EOpTransp transp)
Return NOTRANS or TRANS for real scalar valued operators and this also is used for determining struct...
EOpTransp trans_trans(EOpTransp trans1, EOpTransp trans2)
Combine two transpose arguments.
@ CONJ_ELE
Use the linear operator with conjugate elements.
@ NONCONJ_ELE
Use the linear operator with non-conjugate elements.
@ STRIDE_TYPE_UNIT
The stride between elements in an array is one.
@ STRIDE_TYPE_NONUNIT
The stride between elements in an array is greater than or equal to one.
@ TRANS
Use the transposed operator.
@ NOTRANS
Use the non-transposed operator.
@ CONJTRANS
Use the transposed operator with complex-conjugate clements (same as TRANS for real scalar types).
@ CONJ
Use the non-transposed operator with complex-conjugate elements (same as NOTRANS for real scalar type...
@ VIEW_TYPE_DIRECT
The view is a direct view of data and no copies are made.
@ VIEW_TYPE_DETACHED
The view is a detached copy of the data.
std::string typeName(const T &t)