42 #ifndef __Teuchos_MatrixMarket_SymmetrizingAdder_hpp 43 #define __Teuchos_MatrixMarket_SymmetrizingAdder_hpp 52 #if ! defined(TRILINOS_UNUSED_FUNCTION) 53 # if defined(__GNUC__) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) 54 # define TRILINOS_UNUSED_FUNCTION __attribute__((__unused__)) 55 # elif defined(__clang__) 56 # if __has_attribute(unused) 57 # define TRILINOS_UNUSED_FUNCTION __attribute__((__unused__)) 59 # define TRILINOS_UNUSED_FUNCTION 60 # endif // Clang has 'unused' attribute 61 # elif defined(__IBMCPP__) 65 # define TRILINOS_UNUSED_FUNCTION 66 # else // some other compiler 67 # define TRILINOS_UNUSED_FUNCTION 69 #endif // ! defined(TRILINOS_UNUSED_FUNCTION) 76 TRILINOS_UNUSED_FUNCTION
bool 77 isSkew (
const std::string& symmType) {
78 return symmType.size() >= 4 && symmType.substr(0,4) ==
"skew";
81 TRILINOS_UNUSED_FUNCTION
bool 82 isConj (
const std::string& symmType) {
83 return std::string::npos != symmType.find (
"hermitian");
86 TRILINOS_UNUSED_FUNCTION
bool 87 needsSymmetrization (
const std::string& symmType) {
88 return symmType !=
"general";
111 template<
class AdderType>
126 const std::string& symmType) :
128 symmetrize_ (needsSymmetrization (symmType)),
129 conjugate_ (isConj (symmType)),
130 skew_ (isSkew (symmType))
137 const value_type& Aij)
139 AdderType& theAdder = *adder_;
141 theAdder (i, j, Aij);
142 if (symmetrize_ && i != j) {
144 const value_type Aji = skew_ ?
145 value_type(-(conjugate_ ? STS::conjugate(Aij) : Aij)) :
146 (conjugate_ ? STS::conjugate(Aij) : Aij);
155 theAdder (j, i, Aji,
false);
180 #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.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos, as well as a number of utility routines.
Defines basic traits for the scalar field type.
Definition of Teuchos::as, for conversions between types.
Matrix Market file utilities.