FEI Version of the Day
Loading...
Searching...
No Matches
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
17namespace fei {
24 public:
29
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
63 };//class SparseRowGraph
64
65inline 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
73inline bool SparseRowGraph::operator!=(const fei::SparseRowGraph& othergraph) const
74{
75 return( !(*this == othergraph) );
76}
77
85inline
86int 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
bool operator!=(const fei::SparseRowGraph &othergraph) const
std::vector< int > rowNumbers
std::vector< int > packedColumnIndices
SparseRowGraph(const SparseRowGraph &src)
bool operator==(const fei::SparseRowGraph &othergraph) const
std::vector< int > rowOffsets
int find_row_start(int row, const SparseRowGraph &srg)