9 #include <fei_macros.hpp>
12 #include <fei_TemplateUtils.hpp>
13 #include <fei_ProcEqns.hpp>
37 int len = procs_.size();
39 dest->procs_.resize(len);
40 dest->eqnsPerProc_.resize(len);
42 dest->procEqnNumbers_.resize(len);
43 dest->procEqnLengths_.resize(len);
45 for(
int i=0; i<len; i++) {
46 dest->procs_[i] = procs_[i];
47 dest->eqnsPerProc_[i] = eqnsPerProc_[i];
49 dest->procEqnNumbers_[i] =
new std::vector<int>(*(procEqnNumbers_[i]));
50 dest->procEqnLengths_[i] =
new std::vector<int>(*(procEqnLengths_[i]));
57 void ProcEqns::deleteMemory() {
58 for(
unsigned i=0; i<procEqnNumbers_.size(); i++) {
59 delete procEqnNumbers_[i];
60 delete procEqnLengths_[i];
67 internalAddEqn(eqnNumber, 0, proc);
72 internalAddEqn(eqnNumber, eqnLength, proc);
76 void ProcEqns::internalAddEqn(
int eqnNumber,
int eqnLength,
int proc) {
84 std::vector<int>::iterator
85 p_iter = std::lower_bound(procs_.begin(),procs_.end(), proc);
87 unsigned offset = p_iter - procs_.begin();
89 if (p_iter == procs_.end() || proc != *p_iter) {
94 procs_.insert(p_iter, proc);
96 procEqnNumbers_.insert(procEqnNumbers_.begin()+offset,
new std::vector<int>(1));
97 (*(procEqnNumbers_[offset]))[0] = eqnNumber;
99 procEqnLengths_.insert(procEqnLengths_.begin()+offset,
new std::vector<int>(1));
100 (*(procEqnLengths_[offset]))[0] = eqnLength;
102 eqnsPerProc_.insert(eqnsPerProc_.begin()+offset, 1);
109 std::vector<int>& procEqnNums = *(procEqnNumbers_[offset]);
110 std::vector<int>::iterator pe_iter =
111 std::lower_bound(procEqnNums.begin(),procEqnNums.end(), eqnNumber);
113 unsigned offset2 = pe_iter - procEqnNums.begin();
115 if (pe_iter == procEqnNums.end() || eqnNumber != *pe_iter) {
116 procEqnNumbers_[offset]->insert(procEqnNumbers_[offset]->begin()+offset2,eqnNumber);
117 procEqnLengths_[offset]->insert(procEqnLengths_[offset]->begin()+offset2,eqnLength);
118 eqnsPerProc_[offset] = procEqnNumbers_[offset]->size();
121 (*(procEqnLengths_[offset]))[offset2] = eqnLength;
129 if (len == 0)
return;
131 int numProcs = procs_.size();
133 for(
int i=0; i<numProcs; i++) {
134 for(
int j=0; j<eqnsPerProc_[i]; j++) {
135 int eqn_j = (*(procEqnNumbers_[i]))[j];
138 eqnNumbers, len, ins);
142 << eqn_j <<
" not found." << FEI_ENDL;
146 (*(procEqnLengths_[i]))[j] = eqnLengths[index];
void setProcEqnLengths(int *eqnNumbers, int *eqnLengths, int len)
void addEqn(int eqnNumber, int proc)
int binarySearch(const T &item, const T *list, int len)
std::ostream & console_out()