27 std::vector<int>& eqnNums = eqnbuf.
eqnNumbers();
28 int numEqns = eqnNums.size();
29 std::vector<fei::CSVec*>& eqns = eqnbuf.
eqns();
31 for(
int i=0; i<numEqns; ++i) {
34 int rowlen = row_vec->
size();
35 int* indices = &(row_vec->
indices()[0]);
36 double* coefs = &(row_vec->
coefs()[0]);
38 for(
int j=0; j<rowlen; ++j) {
39 putCoef(row, indices[j], coefs[j]);
49 for(; iter!=iter_end; ++iter) {
51 vecpool_.deallocate(iter->second, 1);
65 for(; s_iter != s_end; ++s_iter) {
66 int row = s_iter->first;
67 const CSVec* srow = s_iter->second;
68 const std::vector<int>& s_ind = srow->
indices();
69 const std::vector<double>& s_coef = srow->
coefs();
71 for(
size_t i=0; i<s_ind.size(); ++i) {
73 double coef = s_coef[i];
89 for(; iter != iter_end; ++iter) {
102 FillableMat::feipoolmat::iterator
104 FillableMat::feipoolmat::iterator iter,
113 if (vptr->
indices().capacity() == 0) {
115 vptr->
coefs().reserve(16);
118 return matdata.insert(iter, std::make_pair(row, vptr));
146 for(
unsigned i=0; i<len; ++i) {
158 for(
unsigned i=0; i<len; ++i) {
174 feipoolmat::const_iterator iter =
matdata_.find(row);
182 feipoolmat::const_iterator iter =
matdata_.lower_bound(row);
184 if (iter ==
matdata_.end() || iter->first != row) {
185 throw std::runtime_error(
"fei::FillableMat: row not found.");
195 feipoolmat::iterator iter =
matdata_.lower_bound(row);
197 if (iter ==
matdata_.end() || iter->first != row) {
210 for(; iter!=iter_end; ++iter) {
212 vecpool_.deallocate(iter->second, 1);
230 for(; this_it != this_end; ++this_it, ++rhs_it) {
231 int this_row = this_it->first;
232 int rhs_row = rhs_it->first;
233 if (this_row != rhs_row)
return false;
235 const CSVec* this_row_vec = this_it->second;
236 const CSVec* rhs_row_vec = rhs_it->second;
238 if (*this_row_vec != *rhs_row_vec)
return false;
248 return !(*
this == rhs);
255 irow = mat.
begin(), irowend = mat.
end();
256 for(; irow!=irowend; ++irow) {
257 int row = irow->first;
258 const CSVec* vec = irow->second;
259 const std::vector<int>& v_ind = vec->
indices();
260 const std::vector<double>& v_coef = vec->
coefs();
261 os <<
"row " << row <<
": ";
262 for(
size_t i=0; i<v_ind.size(); ++i) {
263 os <<
"("<<v_ind[i]<<
","<<v_coef[i]<<
") ";
275 r_iter = mat.
begin(),
278 for(; r_iter != r_end; ++r_iter) {
279 CSVec* row = r_iter->second;
292 m_iter = mat.
begin(),
296 for(; m_iter!=m_end; ++m_iter) {
297 rows[offset++] = m_iter->first;
bool operator==(const FillableMat &rhs) const
std::vector< fei::CSVec * > & eqns()
CSVec * create_or_getRow(int row)
std::vector< int > & indices()
const CSVec * getRow(int row) const
bool hasRow(int row) const
void construct(U *p, const U &val)
std::vector< int > & eqnNumbers()
void set_values(CSVec &vec, double scalar)
bool operator!=(const FillableMat &rhs) const
void createPosition(int row, int col)
void get_row_numbers(const FillableMat &mat, std::vector< int > &rows)
void put_entry(CSVec &vec, int eqn, double coef)
FillableMat & operator=(const FillableMat &src)
pointer allocate(size_type n, const void *hint=NULL)
void putCoef(int row, int col, double coef)
void putRow(int row, const int *cols, const double *coefs, unsigned len)
fei_Pool_alloc< CSVec > vecpool_
feipoolmat::const_iterator const_iterator
void setValues(double value)
void sumInRow(int row, const int *cols, const double *coefs, unsigned len)
FillableMat::feipoolmat::iterator insert_row(FillableMat::feipoolmat &matdata, FillableMat::feipoolmat::iterator iter, int row, fei_Pool_alloc< CSVec > &vecpool)
void sumInCoef(int row, int col, double coef)
void add_entry(CSVec &vec, int eqn, double coef)
unsigned getNumRows() const
int count_nnz(const FillableMat &mat)
std::vector< double > & coefs()
std::map< int, CSVec *, std::less< int >, fei_Pool_alloc< std::pair< const int, CSVec * > > > feipoolmat
void print(std::ostream &os, const FillableMat &mat)