FEI Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
base
fei_CSVec.hpp
Go to the documentation of this file.
1
#ifndef _fei_CSVec_hpp_
2
#define _fei_CSVec_hpp_
3
4
/*--------------------------------------------------------------------*/
5
/* Copyright 2005 Sandia Corporation. */
6
/* Under the terms of Contract DE-AC04-94AL85000, there is a */
7
/* non-exclusive license for use of this work by or on behalf */
8
/* of the U.S. Government. Export of this program may require */
9
/* a license from the United States Government. */
10
/*--------------------------------------------------------------------*/
11
12
#include <
fei_macros.hpp
>
13
#include <vector>
14
#include <algorithm>
15
16
namespace
fei
{
17
24
class
CSVec
{
25
public
:
26
CSVec
(
unsigned
sz=0);
27
virtual
~CSVec
();
28
29
CSVec
&
operator=
(
const
CSVec
& invec);
30
31
std::vector<int>&
indices
() {
return
indices_
;}
32
const
std::vector<int>&
indices
()
const
{
return
indices_
;}
33
std::vector<double>&
coefs
() {
return
coefs_
;}
34
const
std::vector<double>&
coefs
()
const
{
return
coefs_
;}
35
36
size_t
size
()
const
{
return
indices_
.size();}
37
38
void
clear
() {
indices_
.clear();
coefs_
.clear(); }
39
40
bool
operator==
(
const
CSVec
& rhs)
const
{
41
return
indices_
==rhs.
indices_
&&
coefs_
==rhs.
coefs_
;
42
}
43
44
bool
operator!=
(
const
CSVec
& rhs)
const
{
45
return
indices_
!=rhs.
indices_
||
coefs_
!=rhs.
coefs_
;
46
}
47
48
void
subtract
(
const
CSVec
& rhs);
49
50
private
:
51
std::vector<int>
indices_
;
52
std::vector<double>
coefs_
;
53
};
//class CSVec
54
55
inline
56
void
add_entry
(
CSVec
& vec,
int
eqn,
double
coef)
57
{
58
std::vector<int>& v_ind = vec.
indices
();
59
std::vector<double>& v_coef = vec.
coefs
();
60
61
std::vector<int>::iterator
62
iter = std::lower_bound(v_ind.begin(), v_ind.end(), eqn);
63
64
size_t
offset = iter - v_ind.begin();
65
66
if
(iter == v_ind.end() || *iter != eqn) {
67
v_ind.insert(iter, eqn);
68
v_coef.insert(v_coef.begin()+offset, coef);
69
}
70
else
{
71
v_coef[offset] += coef;
72
}
73
}
74
75
76
void
add_entries
(CSVec& vec,
int
num,
const
int
* eqns,
const
double
* coefs);
77
78
void
put_entry
(CSVec& vec,
int
eqn,
double
coef);
79
80
double
get_entry
(
const
CSVec& vec,
int
eqn);
81
82
void
remove_entry
(CSVec& vec,
int
eqn);
83
84
void
set_values
(CSVec& vec,
double
scalar);
85
88
void
add_CSVec_CSVec
(
const
CSVec& u, CSVec& v);
89
90
}
//namespace fei
91
92
#endif
93
fei::CSVec
Definition
fei_CSVec.hpp:24
fei::CSVec::indices_
std::vector< int > indices_
Definition
fei_CSVec.hpp:51
fei::CSVec::indices
std::vector< int > & indices()
Definition
fei_CSVec.hpp:31
fei::CSVec::operator!=
bool operator!=(const CSVec &rhs) const
Definition
fei_CSVec.hpp:44
fei::CSVec::size
size_t size() const
Definition
fei_CSVec.hpp:36
fei::CSVec::indices
const std::vector< int > & indices() const
Definition
fei_CSVec.hpp:32
fei::CSVec::coefs_
std::vector< double > coefs_
Definition
fei_CSVec.hpp:52
fei::CSVec::clear
void clear()
Definition
fei_CSVec.hpp:38
fei::CSVec::coefs
const std::vector< double > & coefs() const
Definition
fei_CSVec.hpp:34
fei::CSVec::CSVec
CSVec(unsigned sz=0)
Definition
fei_CSVec.cpp:15
fei::CSVec::operator=
CSVec & operator=(const CSVec &invec)
Definition
fei_CSVec.cpp:26
fei::CSVec::subtract
void subtract(const CSVec &rhs)
Definition
fei_CSVec.cpp:94
fei::CSVec::coefs
std::vector< double > & coefs()
Definition
fei_CSVec.hpp:33
fei::CSVec::operator==
bool operator==(const CSVec &rhs) const
Definition
fei_CSVec.hpp:40
fei::CSVec::~CSVec
virtual ~CSVec()
Definition
fei_CSVec.cpp:21
fei_macros.hpp
fei
Definition
fei_ArrayUtils.hpp:16
fei::put_entry
void put_entry(CSVec &vec, int eqn, double coef)
Definition
fei_CSVec.cpp:39
fei::add_CSVec_CSVec
void add_CSVec_CSVec(const CSVec &u, CSVec &v)
Definition
fei_CSVec.cpp:106
fei::get_entry
double get_entry(const CSVec &vec, int eqn)
Definition
fei_CSVec.cpp:58
fei::add_entries
void add_entries(CSVec &vec, int num, const int *eqns, const double *coefs)
Definition
fei_CSVec.cpp:34
fei::remove_entry
void remove_entry(CSVec &vec, int eqn)
Definition
fei_CSVec.cpp:77
fei::add_entry
void add_entry(CSVec &vec, int eqn, double coef)
Definition
fei_CSVec.hpp:56
fei::set_values
void set_values(CSVec &vec, double scalar)
Definition
fei_CSVec.cpp:101
Generated by
1.17.0