Teuchos - Trilinos Tools Package
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
numerics
src
Teuchos_MatrixMarket_SymmetrizingGraphAdder.hpp
1
// @HEADER
2
// *****************************************************************************
3
// Tpetra: Templated Linear Algebra Services Package
4
//
5
// Copyright 2008 NTESS and the Tpetra contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#ifndef __Teuchos_MatrixMarket_SymmetrizingGraphAdder_hpp
11
#define __Teuchos_MatrixMarket_SymmetrizingGraphAdder_hpp
12
13
#include <
Teuchos_as.hpp
>
14
#include <
Teuchos_ScalarTraits.hpp
>
15
#include <string>
16
17
18
// Macro that marks a function as "possibly unused," in order to
19
// suppress build warnings.
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__))
26
# else
27
# define TRILINOS_UNUSED_FUNCTION
28
# endif
// Clang has 'unused' attribute
29
# elif defined(__IBMCPP__)
30
// IBM's C++ compiler for Blue Gene/Q (V12.1) implements 'used' but not 'unused'.
31
//
32
// http://pic.dhe.ibm.com/infocenter/compbg/v121v141/index.jsp
33
# define TRILINOS_UNUSED_FUNCTION
34
# else
// some other compiler
35
# define TRILINOS_UNUSED_FUNCTION
36
# endif
37
#endif
// ! defined(TRILINOS_UNUSED_FUNCTION)
38
39
40
namespace
Teuchos
{
41
namespace
MatrixMarket {
42
62
template
<
class
AdderType>
63
class
SymmetrizingGraphAdder
{
64
public
:
66
typedef
typename
AdderType::index_type
index_type
;
67
74
SymmetrizingGraphAdder
(
const
Teuchos::RCP<AdderType>
& adder,
75
const
std::string& symmType) :
76
adder_ (adder),
77
symmetrize_ (needsSymmetrization (symmType)),
78
skew_ (isSkew (symmType))
79
{}
80
82
void
83
operator()
(
const
index_type
i,
84
const
index_type
j)
85
{
86
AdderType& theAdder = *adder_;
87
88
theAdder (i, j);
89
if
(symmetrize_ && i != j) {
90
// The optional third argument (which defaults to true)
91
// specifies whether or not to count the entry against the
92
// total expected number of entries. We don't want to count
93
// this entry because it wasn't part of the original data;
94
// we inserted it because the caller doesn't want symmetric
95
// storage. The original data's total expected number of
96
// entries only counts the entries that are in the original
97
// data, not those that we insert.
98
theAdder (j, i,
false
);
99
}
100
}
101
105
Teuchos::RCP<AdderType>
getAdder
()
const
{
106
return
adder_;
107
}
108
109
private
:
111
Teuchos::RCP<AdderType>
adder_;
113
bool
symmetrize_;
115
bool
skew_;
116
};
117
118
}
// namespace MatrixMarket
119
}
// namespace Teuchos
120
121
#endif
// __Teuchos_MatrixMarket_SymmetrizingGraphAdder_hpp
Teuchos_ScalarTraits.hpp
Defines basic traits for the scalar field type.
Teuchos_as.hpp
Definition of Teuchos::as, for conversions between types.
Teuchos::MatrixMarket::SymmetrizingGraphAdder::operator()
void operator()(const index_type i, const index_type j)
Add entry (i,j), and optionally symmetrize.
Definition
Teuchos_MatrixMarket_SymmetrizingGraphAdder.hpp:83
Teuchos::MatrixMarket::SymmetrizingGraphAdder::SymmetrizingGraphAdder
SymmetrizingGraphAdder(const Teuchos::RCP< AdderType > &adder, const std::string &symmType)
Constructor.
Definition
Teuchos_MatrixMarket_SymmetrizingGraphAdder.hpp:74
Teuchos::MatrixMarket::SymmetrizingGraphAdder::index_type
AdderType::index_type index_type
The type of indices of the sparse graph.
Definition
Teuchos_MatrixMarket_SymmetrizingGraphAdder.hpp:66
Teuchos::MatrixMarket::SymmetrizingGraphAdder::getAdder
Teuchos::RCP< AdderType > getAdder() const
Persisting non-const view of the underlying adder object.
Definition
Teuchos_MatrixMarket_SymmetrizingGraphAdder.hpp:105
Teuchos::RCP
Smart reference counting pointer class for automatic garbage collection.
Definition
Teuchos_RCPDecl.hpp:397
Teuchos
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
Generated by
1.17.0