10 #ifndef TPETRA_LINEARPROBLEM_DEF_HPP
11 #define TPETRA_LINEARPROBLEM_DEF_HPP
21 #include "Teuchos_DataAccess.hpp"
22 #include "Teuchos_TestForException.hpp"
24 #include "Tpetra_MultiVector.hpp"
29 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
39 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
42 const Teuchos::RCP<multivector_type>& X,
43 const Teuchos::RCP<multivector_type>& B)
51 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
61 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
63 leftScale(
const Teuchos::RCP<const vector_type> & D, Teuchos::ETransp mode)
65 const Scalar ST0 = Teuchos::ScalarTraits<Scalar>::zero();
66 const Scalar ST1 = Teuchos::ScalarTraits<Scalar>::one();
67 if (mode == Teuchos::NO_TRANS) {
69 B_->elementWiseMultiply(ST1, *D, *B_, ST0);
75 X_->elementWiseMultiply(ST1, R, *X_, ST0);
81 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
83 rightScale(
const Teuchos::RCP<const vector_type> & D, Teuchos::ETransp mode)
85 const Scalar ST0 = Teuchos::ScalarTraits<Scalar>::zero();
86 const Scalar ST1 = Teuchos::ScalarTraits<Scalar>::one();
87 if (mode == Teuchos::NO_TRANS) {
91 X_->elementWiseMultiply(ST1, R, *X_, ST0);
95 B_->elementWiseMultiply(ST1, *D, *B_, ST0);
100 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
104 const char tfecfFuncName[] =
"checkInput: ";
106 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(A_==Teuchos::null, std::runtime_error,
107 "Linear problem does not have a matrix (A_).");
109 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(X_==Teuchos::null,
110 std::logic_error,
"Solution vector (X_) is unset.");
112 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(B_==Teuchos::null,
113 std::logic_error,
"RHS vector (B_) is unset.");
115 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!A_->getRowMap()->isSameAs(*(X_->getMap())),
116 std::logic_error,
"Domain map of matrix is not the 'same as' the solution map.");
118 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!A_->getRowMap()->isSameAs(*(B_->getMap())),
119 std::logic_error,
"Range map of matrix is not the 'same as' the RHS map.");
124 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
131 const LP* src =
dynamic_cast<const LP*
> (&sourceObj);
132 if (src ==
nullptr) {
139 return ((this->A_->getDomainMap() == src->getMatrix()->getDomainMap()) and
140 (this->A_->getRangeMap() == src->getMatrix()->getRangeMap()));
152 #define TPETRA_LINEARPROBLEM_INSTANT(SCALAR,LO,GO,NODE) \
153 template class LinearProblem< SCALAR , LO , GO , NODE >;
156 #endif // TPETRA_LINEARPROBLEM_DEF_HPP
Class that encapulates linear problem (Ax = b).
void checkInput() const
Check input parameters for existence and size consistency.
void rightScale(const Teuchos::RCP< const vector_type > &D, Teuchos::ETransp mode=Teuchos::NO_TRANS)
Perform right scaling of a linear problem.
Declaration of the Tpetra::MultiVector class.
LinearProblem()
Default Constructor.
virtual bool checkSizes(const SrcDistObject &source) override
Compare the source and target (this) objects for compatibility.
Abstract base class for objects that can be the source of an Import or Export operation.
A parallel distribution of indices over processes.
A distributed dense vector.
void leftScale(const Teuchos::RCP< const vector_type > &D, Teuchos::ETransp mode=Teuchos::NO_TRANS)
Perform left scaling of a linear problem.
void reciprocal(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise reciprocal values of input Multi-vector in target, this(i,j) = 1/A(i,j).
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.