Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_SerialVectorSpaceConverterBase.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
4 //
5 // Copyright 2004 NTESS and the Thyra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef THYRA_SERIAL_VECTOR_SPACE_CONVERTED_BASE_HPP
11 #define THYRA_SERIAL_VECTOR_SPACE_CONVERTED_BASE_HPP
12 
13 #include "Thyra_VectorSpaceConverterBase.hpp"
14 #include "Thyra_DetachedMultiVectorView.hpp"
15 
16 
17 namespace Thyra {
18 
19 
29 template<class ScalarFrom, class ScalarTo>
31  : virtual public VectorSpaceConverterBase<ScalarFrom,ScalarTo>
32 {
33 public:
34 
37 
39  virtual void convert(
40  const MultiVectorBase<ScalarFrom> &mv_from,
42  ) const;
43 
45 
46 };
47 
48 
49 // Implementation
50 
51 
52 template<class ScalarFrom, class ScalarTo>
54  const MultiVectorBase<ScalarFrom> &mv_from,
56  ) const
57 {
58 #ifdef TEUCHOS_DEBUG
59  TEUCHOS_TEST_FOR_EXCEPT(mv_to==NULL);
60 #endif
62  DetachedMultiVectorView<ScalarTo> emv_to(*mv_to);
63 #ifdef TEUCHOS_DEBUG
64  TEUCHOS_TEST_FOR_EXCEPT(emv_from.subDim() != emv_to.subDim());
65  TEUCHOS_TEST_FOR_EXCEPT(emv_from.numSubCols() != emv_to.numSubCols());
66 #endif
67  for( Ordinal j = 0; j < emv_from.numSubCols(); ++j ) {
68  for( Ordinal i = 0; i < emv_from.subDim(); ++i ) {
69  emv_to(i,j) = emv_from(i,j); // ToDo: Make this faster using optimized copy functions?
70  }
71  }
72 }
73 
74 
75 } // namespace Thyra
76 
77 
78 #endif // THYRA_SERIAL_VECTOR_SPACE_CONVERTED_BASE_HPP
Create an explicit non-mutable (const) view of a MultiVectorBase object.
Node base class for converting serial multi-vectors (and vectors) from one scalar type to another...
Create an explicit mutable (non-const) view of a MultiVectorBase object.
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
Interface for a collection of column vectors called a multi-vector.
virtual void convert(const MultiVectorBase< ScalarFrom > &mv_from, MultiVectorBase< ScalarTo > *mv_to) const
Base interface for a factory that converts vector space types and vectors and multi-vectors from one ...
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)