FEI
Version of the Day
base
fei_SparseRowGraph.hpp
1
2
/*--------------------------------------------------------------------*/
3
/* Copyright 2005 Sandia Corporation. */
4
/* Under the terms of Contract DE-AC04-94AL85000, there is a */
5
/* non-exclusive license for use of this work by or on behalf */
6
/* of the U.S. Government. Export of this program may require */
7
/* a license from the United States Government. */
8
/*--------------------------------------------------------------------*/
9
10
#ifndef _fei_SparseRowGraph_hpp_
11
#define _fei_SparseRowGraph_hpp_
12
13
#include <fei_macros.hpp>
14
#include <vector>
15
#include <algorithm>
16
17
namespace
fei
{
23
class
SparseRowGraph
{
24
public
:
26
SparseRowGraph
()
27
:
rowNumbers
(),
rowOffsets
(),
packedColumnIndices
(),
blockEntries
(false)
28
{}
29
31
SparseRowGraph
(
const
SparseRowGraph
& src)
32
:
rowNumbers
(src.
rowNumbers
),
rowOffsets
(src.
rowOffsets
),
33
packedColumnIndices
(src.
packedColumnIndices
),
blockEntries
(src.
blockEntries
)
34
{}
35
37
virtual
~SparseRowGraph
() {}
38
40
bool
operator==
(
const
fei::SparseRowGraph
& othergraph)
const
;
41
43
bool
operator!=
(
const
fei::SparseRowGraph
& othergraph)
const
;
44
46
std::vector<int>
rowNumbers
;
47
54
std::vector<int>
rowOffsets
;
55
59
std::vector<int>
packedColumnIndices
;
60
62
bool
blockEntries
;
63
};
//class SparseRowGraph
64
65
inline
bool
SparseRowGraph::operator==
(
const
fei::SparseRowGraph
& othergraph)
const
66
{
67
if
(
rowNumbers
!= othergraph.
rowNumbers
)
return
(
false
);
68
if
(
rowOffsets
!= othergraph.
rowOffsets
)
return
(
false
);
69
if
(
packedColumnIndices
!= othergraph.
packedColumnIndices
)
return
(
false
);
70
return
(
true
);
71
}
72
73
inline
bool
SparseRowGraph::operator!=
(
const
fei::SparseRowGraph
& othergraph)
const
74
{
75
return
( !(*
this
== othergraph) );
76
}
77
85
inline
86
int
find_row_start
(
int
row,
const
SparseRowGraph
& srg)
87
{
88
std::vector<int>::const_iterator rowNumbers_iter =
89
std::lower_bound(srg.
rowNumbers
.begin(), srg.
rowNumbers
.end(), row);
90
if
(rowNumbers_iter == srg.
rowNumbers
.end() || *rowNumbers_iter != row) {
91
return
-1;
92
}
93
94
size_t
offset = rowNumbers_iter - srg.
rowNumbers
.begin();
95
return
srg.
rowOffsets
[offset];
96
}
97
98
}
//namespace fei
99
100
#endif
101
fei::SparseRowGraph::rowOffsets
std::vector< int > rowOffsets
Definition:
fei_SparseRowGraph.hpp:54
fei::SparseRowGraph::SparseRowGraph
SparseRowGraph(const SparseRowGraph &src)
Definition:
fei_SparseRowGraph.hpp:31
fei::find_row_start
int find_row_start(int row, const SparseRowGraph &srg)
Definition:
fei_SparseRowGraph.hpp:86
fei::SparseRowGraph::rowNumbers
std::vector< int > rowNumbers
Definition:
fei_SparseRowGraph.hpp:46
fei::SparseRowGraph::blockEntries
bool blockEntries
Definition:
fei_SparseRowGraph.hpp:62
fei::SparseRowGraph::SparseRowGraph
SparseRowGraph()
Definition:
fei_SparseRowGraph.hpp:26
fei::SparseRowGraph::operator!=
bool operator!=(const fei::SparseRowGraph &othergraph) const
Definition:
fei_SparseRowGraph.hpp:73
fei::SparseRowGraph::packedColumnIndices
std::vector< int > packedColumnIndices
Definition:
fei_SparseRowGraph.hpp:59
fei::SparseRowGraph::operator==
bool operator==(const fei::SparseRowGraph &othergraph) const
Definition:
fei_SparseRowGraph.hpp:65
fei::SparseRowGraph
Definition:
fei_SparseRowGraph.hpp:23
fei
Definition:
fei_ArrayUtils.hpp:16
fei::SparseRowGraph::~SparseRowGraph
virtual ~SparseRowGraph()
Definition:
fei_SparseRowGraph.hpp:37
Generated by
1.8.16