12 #ifndef RTOPPACK_TYPES_HPP
13 #define RTOPPACK_TYPES_HPP
69 {
public:
UnknownError(
const std::string& what_arg) : std::logic_error(what_arg) {}};
72 {
public:
InvalidUsage(
const std::string& what_arg) : std::logic_error(what_arg) {}};
75 {
public:
InvalidNumVecs(
const std::string& what_arg) : std::logic_error(what_arg) {}};
81 {
public:
IncompatibleVecs(
const std::string& what_arg) : std::logic_error(what_arg) {}};
111 template<
class Scalar>
124 {
initialize(globalOffset_in, subDim_in, values_in, stride_in); }
140 subDim_in*std::abs(Teuchos::as<int>(stride_in)) - 1 <= values_in.
upperOffset());
214 template<
class Scalar>
255 template<
class Scalar>
262 for(
int i = 0; i < sv.
subDim(); ++i ) {
272 template<
class Scalar>
273 std::ostream& operator<<(std::ostream &out, const ConstSubVectorView<Scalar> &sv)
277 <<
"globalOffset="<<sv.globalOffset()
278 <<
",subDim="<<sv.subDim()
279 <<
",values="<<sv.values()
280 <<
",stride="<<sv.stride()
312 template<
class Scalar>
329 initialize(globalOffset_in, subDim_in, colOffset_in, numSubCols_in, values_in,
440 template<
class Scalar>
450 Teuchos::arcp<Scalar>(numRows_in*numCols_in), numRows_in)
459 colOffset_in, numSubCols_in, values_in, leadingDim_in)
473 subDim_in, colOffset_in, numSubCols_in, values_in, leadingDim_in);
478 return Teuchos::arcp_const_cast<Scalar>(
502 template<
class Scalar>
512 (*msmv)(i,j) = smv(i,j);
533 template <
class Scalar,
class ConcreteObj>
540 {
return Scalar::this_type_is_missing_a_specialization(); }
543 {
return Scalar::this_type_is_missing_a_specialization(); }
546 {
return Scalar::this_type_is_missing_a_specialization(); }
555 Scalar::this_type_is_missing_a_specialization(obj);
565 *obj = Scalar::this_type_is_missing_a_specialization();
574 template <
class Scalar>
593 assertInput(primitiveObjs, indexObjs, charObjs);
594 primitiveObjs[0] = obj;
604 assertInput(primitiveObjs, indexObjs, charObjs);
605 *obj = primitiveObjs[0];
616 || charObjs.
size()!=0 );
627 template <
class Scalar>
648 assertInput(primitiveObjs, indexObjs, charObjs);
659 assertInput(primitiveObjs, indexObjs, charObjs);
671 || charObjs.
size()!=0 );
677 #if defined(HAVE_COMPLEX) && defined(HAVE_TEUCHOS_COMPLEX)
683 template <
class Scalar>
684 class PrimitiveTypeTraits<std::complex<Scalar>, std::complex<Scalar> > {
687 typedef PrimitiveTypeTraits<Scalar,Scalar> ScalarPrimitiveTypeTraits;
689 typedef typename ScalarPrimitiveTypeTraits::primitiveType
primitiveType;
692 {
return 2*ScalarPrimitiveTypeTraits::numPrimitiveObjs(); }
699 const std::complex<Scalar> &obj,
700 const ArrayView<primitiveType> &primitiveObjs,
701 const ArrayView<index_type> &indexObjs,
702 const ArrayView<char> &charObjs
706 const int numScalarPrimitiveObjs =
707 ScalarPrimitiveTypeTraits::numPrimitiveObjs();
708 assertInput(primitiveObjs, indexObjs, charObjs);
709 ScalarPrimitiveTypeTraits::extractPrimitiveObjs(
710 obj.real(), primitiveObjs(0,numScalarPrimitiveObjs),
null,
null );
711 ScalarPrimitiveTypeTraits::extractPrimitiveObjs(
712 obj.imag(), primitiveObjs(numScalarPrimitiveObjs,numScalarPrimitiveObjs),
null,
null );
716 const ArrayView<const primitiveType> &primitiveObjs,
717 const ArrayView<const index_type> &indexObjs,
718 const ArrayView<const char> &charObjs,
719 const Ptr<std::complex<Scalar> > &obj
723 using Teuchos::outArg;
724 assertInput(primitiveObjs, indexObjs, charObjs);
725 const int numScalarPrimitiveObjs =
726 ScalarPrimitiveTypeTraits::numPrimitiveObjs();
728 ScalarPrimitiveTypeTraits::loadPrimitiveObjs(
729 primitiveObjs(0,numScalarPrimitiveObjs), null, null,
731 ScalarPrimitiveTypeTraits::loadPrimitiveObjs(
732 primitiveObjs(numScalarPrimitiveObjs,numScalarPrimitiveObjs), null, null,
734 *obj = std::complex<Scalar>( real, imag );
737 static void assertInput(
738 const ArrayView<const primitiveType> &primitiveObjs,
739 const ArrayView<const index_type> &indexObjs,
740 const ArrayView<const char> &charObjs
745 primitiveObjs.size()!=2*ScalarPrimitiveTypeTraits::numPrimitiveObjs()
746 || indexObjs.size()!=0
747 || charObjs.size()!=0 );
756 template <
class Scalar>
757 class PrimitiveTypeTraits<std::complex<Scalar>, Scalar> {
760 typedef PrimitiveTypeTraits<Scalar,Scalar> ScalarPrimitiveTypeTraits;
762 typedef typename ScalarPrimitiveTypeTraits::primitiveType
primitiveType;
765 {
return ScalarPrimitiveTypeTraits::numPrimitiveObjs(); }
773 const ArrayView<primitiveType> &primitiveObjs,
774 const ArrayView<index_type> &indexObjs,
775 const ArrayView<char> &charObjs
779 assertInput(primitiveObjs, indexObjs, charObjs);
780 ScalarPrimitiveTypeTraits::extractPrimitiveObjs(
781 obj, primitiveObjs, null, null );
785 const ArrayView<const primitiveType> &primitiveObjs,
786 const ArrayView<const index_type> &indexObjs,
787 const ArrayView<const char> &charObjs,
788 const Ptr<Scalar > &obj
792 assertInput(primitiveObjs, indexObjs, charObjs);
793 ScalarPrimitiveTypeTraits::loadPrimitiveObjs(
794 primitiveObjs, null, null, obj );
797 static void assertInput(
798 const ArrayView<const primitiveType> &primitiveObjs,
799 const ArrayView<const index_type> &indexObjs,
800 const ArrayView<const char> &charObjs
805 primitiveObjs.size()!=ScalarPrimitiveTypeTraits::numPrimitiveObjs()
806 || indexObjs.size()!=0
807 || charObjs.size()!=0 );
813 #endif // defined(HAVE_COMPLEX) && defined(HAVE_TEUCHOS_COMPLEX)
823 template<
class Scalar>
class RTOpT;
829 #endif // RTOPPACK_TYPES_HPP
ConstSubMultiVectorView(Ordinal globalOffset_in, Ordinal subDim_in, Ordinal colOffset_in, Ordinal numSubCols_in, const ArrayRCP< const Scalar > &values_in, Ordinal leadingDim_in)
ArrayRCP< const Scalar > values_
Ordinal colOffset() const
Ordinal numSubCols() const
bool is_null(const boost::shared_ptr< T > &p)
ConstSubMultiVectorView()
ArrayRCP< T > persistingView(size_type lowerOffset, size_type size) const
static int numPrimitiveObjs()
static void extractPrimitiveObjs(const Scalar &obj, const ArrayView< primitiveType > &primitiveObjs, const ArrayView< index_type > &indexObjs, const ArrayView< char > &charObjs)
Class for a changeable sub-vector.
SubMultiVectorView(const SubMultiVectorView< Scalar > &smv)
void assign_entries(const Ptr< const SubVectorView< Scalar > > &msv, const ConstSubVectorView< Scalar > &sv)
static void loadPrimitiveObjs(const ArrayView< const primitiveType > &primitiveObjs, const ArrayView< const index_type > &indexObjs, const ArrayView< const char > &charObjs, const Ptr< Scalar > &obj)
size_type upperOffset() const
Teuchos_Ordinal index_type
IncompatibleVecs(const std::string &what_arg)
const ArrayRCP< Scalar > values() const
const ArrayRCP< const Scalar >::iterator valuesBegin() const
ConstSubVectorView(Ordinal globalOffset_in, Ordinal subDim_in, const ArrayRCP< const Scalar > &values_in, ptrdiff_t stride_in)
static int numIndexObjs()
SubMultiVectorView(Ordinal globalOffset_in, Ordinal subDim_in, Ordinal colOffset_in, Ordinal numSubCols_in, const ArrayRCP< Scalar > &values_in, Ordinal leadingDim_in)
Class for a non-changeable sub-vector.
Ordinal globalOffset() const
SubVectorView(const ArrayRCP< Scalar > &values_in)
InvalidNumVecs(const std::string &what_arg)
SubMultiVectorView(Ordinal numRows_in, Ordinal numCols_in)
#define TEUCHOS_ASSERT_IN_RANGE_UPPER_EXCLUSIVE(index, lower_inclusive, upper_exclusive)
Scalar & operator()(Ordinal i) const
Zero-based indexing (Preconditions: values()!=NULL && (0 <= i < subDim())).
static int numIndexObjs()
const ArrayRCP< Scalar > values() const
SubVectorView(Ordinal subDim_in)
TEUCHOS_ORDINAL_TYPE Teuchos_Ordinal
Specialization where the scalar type is the same as the concrete object type.
static void assertInput(const ArrayView< const primitiveType > &primitiveObjs, const ArrayView< const index_type > &indexObjs, const ArrayView< const char > &charObjs)
A templated traits class for decomposing object into an array of primitive objects.
Ordinal leadingDim() const
UnknownError(const std::string &what_arg)
static int numPrimitiveObjs()
SubVectorView(const SubVectorView< Scalar > &sv)
Class for a changeable sub-vector.
static void assertInput(const ArrayView< const primitiveType > &primitiveObjs, const ArrayView< const index_type > &indexObjs, const ArrayView< const char > &charObjs)
SubVectorView< Scalar > col(const Ordinal j) const
Return a SubVectorView view of the jth sub-column (Preconditions: values()!=NULL && && (0<=j<numSubCo...
SubVectorView(Ordinal globalOffset_in, Ordinal subDim_in, const ArrayRCP< Scalar > &values_in, ptrdiff_t stride_in)
void initialize(Ordinal globalOffset_in, Ordinal subDim_in, Ordinal colOffset_in, Ordinal numSubCols_in, const ArrayRCP< Scalar > &values_in, Ordinal leadingDim_in)
void initialize(Ordinal globalOffset_in, Ordinal subDim_in, const ArrayRCP< Scalar > &values_in, ptrdiff_t stride_in)
size_type lowerOffset() const
const Scalar & operator[](Ordinal i) const
Zero-based indexing (Preconditions: values()!=NULL && (0 <= i < subDim())).
static void extractPrimitiveObjs(const Scalar &obj, const ArrayView< primitiveType > &primitiveObjs, const ArrayView< index_type > &indexObjs, const ArrayView< char > &charObjs)
void setGlobalOffset(Ordinal globalOffset_in)
ArrayRCP< const Scalar > values_
InvalidNumTargVecs(const std::string &what_arg)
ConstSubVectorView(const ConstSubVectorView< Scalar > &sv)
Ordinal globalOffset() const
static int numIndexObjs()
void setGlobalOffset(Ordinal globalOffset_in)
ConstSubVectorView(const ArrayRCP< const Scalar > &values_in)
const ArrayRCP< const Scalar > values() const
basic_FancyOStream< char > FancyOStream
static int numPrimitiveObjs()
InvalidUsage(const std::string &what_arg)
Class for a non-changeable sub-multi-vector (submatrix).
ScalarPrimitiveTypeTraits::primitiveType primitiveType
void initialize(Ordinal globalOffset_in, Ordinal subDim_in, Ordinal colOffset_in, Ordinal numSubCols_in, const ArrayRCP< const Scalar > &values_in, Ordinal leadingDim_in)
static void loadPrimitiveObjs(const ArrayView< const primitiveType > &primitiveObjs, const ArrayView< const index_type > &indexObjs, const ArrayView< const char > &charObjs, const Ptr< index_type > &obj)
static void loadPrimitiveObjs(const ArrayView< const primitiveType > &primitiveObjs, const ArrayView< const index_type > &indexObjs, const ArrayView< const char > &charObjs, const Ptr< Scalar > &obj)
const Scalar & operator()(Ordinal i) const
Zero-based indexing (Preconditions: values()!=NULL && (0 <= i < subDim())).
ConstSubVectorView< Scalar > col(const Ordinal j) const
Return a ConstSubVectorView view of the jth sub-column (Preconditions: values()!=NULL && (0<=j<numSub...
PrimitiveTypeTraits< Scalar, Scalar > ScalarPrimitiveTypeTraits
#define TEUCHOS_ASSERT(assertion_test)
#define TEUCHOS_ASSERT_EQUALITY(val1, val2)
static void extractPrimitiveObjs(const index_type &obj, const ArrayView< primitiveType > &primitiveObjs, const ArrayView< index_type > &indexObjs, const ArrayView< char > &charObjs)
IncompatibleReductObj(const std::string &what_arg)
Scalar & operator[](Ordinal i) const
Zero-based indexing (Preconditions: values()!=NULL && (0 <= i < subDim())).
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
ConstSubMultiVectorView(const ConstSubMultiVectorView< Scalar > &smv)
const ArrayRCP< const Scalar > values() const
Scalar & operator()(Ordinal i, Ordinal j) const
Zero-based indexing (Preconditions: values()!=NULL && (0<=i< subDim()) && (0<=j<numSubCols()).
const Scalar & operator()(Ordinal i, Ordinal j) const
Zero-based indexing (Preconditions: values()!=NULL && (0<=i<subDim()) && (0<=j< numSubCols()).
void initialize(Ordinal globalOffset_in, Ordinal subDim_in, const ArrayRCP< const Scalar > &values_in, ptrdiff_t stride_in)