42 #ifndef __Teuchos_MatrixMarket_SymmetrizingAdder_hpp
43 #define __Teuchos_MatrixMarket_SymmetrizingAdder_hpp
51 namespace MatrixMarket {
54 bool isSkew (
const std::string& symmType) {
55 return symmType.size() >= 4 && symmType.substr(0,4) ==
"skew";
58 bool isConj (
const std::string& symmType) {
59 return std::string::npos != symmType.find (
"hermitian");
62 bool needsSymmetrization (
const std::string& symmType) {
63 return symmType !=
"general";
86 template<
class AdderType>
101 const std::string& symmType) :
103 symmetrize_ (needsSymmetrization (symmType)),
104 conjugate_ (isConj (symmType)),
105 skew_ (isSkew (symmType))
114 AdderType& theAdder = *adder_;
116 theAdder (i, j, Aij);
117 if (symmetrize_ && i != j) {
120 -(conjugate_ ? STS::conjugate(Aij) : Aij) :
121 (conjugate_ ? STS::conjugate(Aij) : Aij);
130 theAdder (j, i, Aji,
false);
155 #endif // __Teuchos_MatrixMarket_SymmetrizingAdder_hpp
Adds entries with optional symmetry to a sparse matrix.
Teuchos::RCP< AdderType > getAdder() const
Persisting non-const view of the underlying adder object.
This structure defines some basic traits for a scalar field type.
void operator()(const index_type i, const index_type j, const value_type &Aij)
Add value A_ij to entry (i,j), and optionally symmetrize.
SymmetrizingAdder(const Teuchos::RCP< AdderType > &adder, const std::string &symmType)
Constructor.
AdderType::index_type index_type
The type of indices of the sparse matrix.
AdderType::value_type value_type
The type of entries of the sparse matrix.
Defines basic traits for the scalar field type.
Definition of Teuchos::as, for conversions between types.