10#ifndef __Teuchos_MatrixMarket_SymmetrizingAdder_hpp
11#define __Teuchos_MatrixMarket_SymmetrizingAdder_hpp
20#if ! defined(TRILINOS_UNUSED_FUNCTION)
21# if defined(__GNUC__) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
22# define TRILINOS_UNUSED_FUNCTION __attribute__((__unused__))
23# elif defined(__clang__)
24# if __has_attribute(unused)
25# define TRILINOS_UNUSED_FUNCTION __attribute__((__unused__))
27# define TRILINOS_UNUSED_FUNCTION
29# elif defined(__IBMCPP__)
33# define TRILINOS_UNUSED_FUNCTION
35# define TRILINOS_UNUSED_FUNCTION
41 namespace MatrixMarket {
44 TRILINOS_UNUSED_FUNCTION
bool
45 isSkew (
const std::string& symmType) {
46 return symmType.size() >= 4 && symmType.substr(0,4) ==
"skew";
49 TRILINOS_UNUSED_FUNCTION
bool
50 isConj (
const std::string& symmType) {
51 return std::string::npos != symmType.find (
"hermitian");
54 TRILINOS_UNUSED_FUNCTION
bool
55 needsSymmetrization (
const std::string& symmType) {
56 return symmType !=
"general";
79 template<
class AdderType>
94 const std::string& symmType) :
96 symmetrize_ (needsSymmetrization (symmType)),
97 conjugate_ (isConj (symmType)),
98 skew_ (isSkew (symmType))
107 AdderType& theAdder = *adder_;
109 theAdder (i, j, Aij);
110 if (symmetrize_ && i != j) {
113 value_type(-(conjugate_ ? STS::conjugate(Aij) : Aij)) :
114 (conjugate_ ? STS::conjugate(Aij) : Aij);
123 theAdder (j, i, Aji,
false);
Defines basic traits for the scalar field type.
Definition of Teuchos::as, for conversions between types.
AdderType::value_type value_type
The type of entries of the sparse matrix.
AdderType::index_type index_type
The type of indices of the sparse matrix.
SymmetrizingAdder(const Teuchos::RCP< AdderType > &adder, const std::string &symmType)
Constructor.
Teuchos::RCP< AdderType > getAdder() const
Persisting non-const view of the underlying adder object.
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.
Smart reference counting pointer class for automatic garbage collection.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
This structure defines some basic traits for a scalar field type.