25 setNumRHSsCalled_(false),
26 rhsCoefsAllocated_(false),
40 setNumRHSsCalled_(false),
41 rhsCoefsAllocated_(false),
57 for(i=0; i<len; i++) {
69 std::vector<double>* rhsCoefs = src.
rhsCoefs_[i];
71 rhsCoefs_.push_back(
new std::vector<double>(*rhsCoefs) );
114 if (n <= 0) {
return;}
121 std::vector<double>* rhsCoefs =
rhsCoefs_[i];
133 fei::console_out() <<
"(deep in FEI) EqnBuffer::addRHS: ERROR, eqnNumber " << eqnNumber
134 <<
" not found in send eqns." <<
FEI_ENDL;
138 std::vector<double>* rhsCoefs =
rhsCoefs_[index];
140 if ( (
int)rhsCoefs->size() <= rhsIndex)
setNumRHSs(rhsIndex+1);
142 if (accumulate==
true) (*rhsCoefs)[rhsIndex] += value;
143 else (*rhsCoefs)[rhsIndex] = value;
157 if (index < 0)
return(-1);
162 for(
int i=0; i<numEqns; i++) {
163 std::vector<int>& indices = eqnsPtr[i]->
indices();
165 if (index > -1)
return(i);
173 int len,
bool accumulate,
bool create_indices_union)
175 if (len <= 0)
return(0);
177 int err, insertPoint = -1;
184 if (err) {
return(err);}
191 if (create_indices_union) {
192 for(
int i=0; i<len; ++i) {
204 if (eqnLoc < 0)
return(-1);
207 if (colLoc < 0)
return(-1);
209 coef =
eqns_[eqnLoc]->coefs()[colLoc];
217 if (eqnLoc < 0)
return(-1);
220 if (colLoc < 0)
return(0);
222 std::vector<int>& indices =
eqns_[eqnLoc]->indices();
223 std::vector<double>& coefs=
eqns_[eqnLoc]->coefs();
225 int len = indices.size();
227 int* indPtr = &indices[0];
228 double* coefPtr = &coefs[0];
230 for(
int i=len-1; i>colLoc; --i) {
231 indPtr[i-1] = indPtr[i];
232 coefPtr[i-1] = coefPtr[i];
235 indices.resize(len-1);
245 if (eqnLoc < 0)
return(-1);
248 if (colLoc < 0)
return(-1);
250 std::vector<int>& indices =
eqns_[eqnLoc]->indices();
251 std::vector<double>& coefs=
eqns_[eqnLoc]->coefs();
253 coef = coefs[colLoc];
254 int len = indices.size();
256 int* indPtr = &indices[0];
257 double* coefPtr = &coefs[0];
259 for(
int i=len-1; i>colLoc; --i) {
260 indPtr[i-1] = indPtr[i];
261 coefPtr[i-1] = coefPtr[i];
264 indices.resize(len-1);
281 std::vector<double>** rhsCoefs = &((*(inputEqns.
rhsCoefsPtr()))[0]);
284 std::vector<int>& indices_i = eqs[i]->
indices();
285 std::vector<double>& coefs_i = eqs[i]->
coefs();
287 int err =
addEqn(eqnNums[i], &coefs_i[0], &indices_i[0],
288 eqs[i]->size(), accumulate);
289 if (err)
return(err);
292 for(
int j=0; j<numRHSs; ++j) {
293 addRHS(eqnNums[i], j, (*(rhsCoefs[i]))[j], accumulate);
310 eqns_.insert(
eqns_.begin()+insertPoint, newEqn);
314 std::vector<double>* newRhsCoefRow =
new std::vector<double>(
numRHSs_, 0.0);
317 catch (std::runtime_error& exc) {
327 const int* indices,
int len,
bool accumulate)
337 for(
int i=0; i<len; ++i) {
342 for(
int i=0; i<len; ++i) {
361 int err = 0, insertPoint = -1;
375 if (err) {
return(err);}
388 std::vector<std::vector<double>*>& rhsCoefs = *(eq.
rhsCoefsPtr());
390 os <<
"#ereb num-eqns: " << eqnNums.size() <<
FEI_ENDL;
391 for(
size_t i=0; i<eqnNums.size(); i++) {
392 os <<
"#ereb eqn " << eqnNums[i] <<
": ";
394 std::vector<int>& inds = eq.
eqns()[i]->indices();
395 std::vector<double>& cfs = eq.
eqns()[i]->coefs();
397 for(
size_t j=0; j<inds.size(); j++) {
398 os <<
"("<<inds[j] <<
"," << cfs[j] <<
") ";
402 std::vector<double>& rhs = *(rhsCoefs[i]);
403 for(
size_t k=0; k<rhs.size(); k++) {
404 os << rhs[k] <<
", ";
int sortedListInsert(const T &item, std::vector< T > &list)
int addEqn(int eqnNumber, const double *coefs, const int *indices, int len, bool accumulate, bool create_indices_union=false)
std::vector< fei::CSVec * > & eqns()
FEI_OSTREAM & operator<<(FEI_OSTREAM &os, EqnBuffer &eq)
std::vector< int > & indices()
EqnBuffer & operator=(const EqnBuffer &src)
std::vector< int > & eqnNumbers()
void set_values(CSVec &vec, double scalar)
int addRHS(int eqnNumber, int rhsIndex, double value, bool accumulate=true)
std::vector< double > dummyCoefs_
std::vector< std::vector< double > * > * rhsCoefsPtr()
void put_entry(CSVec &vec, int eqn, double coef)
int binarySearch(const T &item, const T *list, int len)
std::vector< int > eqnNumbers_
int getCoefAndRemoveIndex(int eqnNumber, int colIndex, double &coef)
std::vector< std::vector< double > * > rhsCoefs_
int addEqns(EqnBuffer &inputEqns, bool accumulate)
std::vector< fei::CSVec * > eqns_
int internalAddEqn(int index, const double *coefs, const int *indices, int len, bool accumulate)
std::vector< int > indices_union_
int addIndices(int eqnNumber, const int *indices, int len)
std::ostream & console_out()
int removeIndex(int eqnNumber, int colIndex)
int getCoef(int eqnNumber, int colIndex, double &coef)
void add_entry(CSVec &vec, int eqn, double coef)
int insertNewEqn(int eqn, int insertPoint)
std::vector< double > & coefs()