81std::unique_ptr<SparseMtrx> DynCompCol :: clone()
const
83 return std::make_unique<DynCompCol>(*
this);
95 for (
int j = 0; j <
nColumns; j++ ) {
97 for (
int t = 1; t <=
columns[ j ].giveSize(); t++ ) {
103void DynCompCol :: times(
double x)
126 elem->giveLocationArray(loc, s);
128 for (
int ii : loc ) {
130 for (
int jj : loc ) {
140 std :: vector< IntArray >r_locs;
141 std :: vector< IntArray >c_locs;
143 for (
auto &gbc : domain->
giveBcs() ) {
147 for ( std :: size_t k = 0; k < r_locs.size(); k++ ) {
150 for (
int ii : krloc ) {
152 for (
int jj : kcloc ) {
166 for (
auto &in: eModel->giveIntegralList()) {
168 for (
auto &elem: in->set->giveElementList()) {
170 in->getElementTermCodeNumbers (locr, locc, domain->
giveElement(elem), *in->term, s) ;
171 for (
int ii : locr ) {
173 for (
int jj : locc ) {
185 for (
int j = 0; j < neq; j++ ) {
186 nz_ += this->
rowind[ j ].giveSize();
189 OOFEM_LOG_DEBUG(
"DynCompCol info: neq is %d, nelem is %d\n", neq, nz_);
203 OOFEM_ERROR(
"dimension of 'k' and 'loc' mismatch");
207 for (
int j = 1; j <= dim; j++ ) {
210 for (
int i = 1; i <= dim; i++ ) {
213 this->
at(ii, jj) += mat.
at(i, j);
231 for (
int i = 1 ; i <= dim1; i++) {
234 for (j=1 ; j<= dim2; j++) {
236 if (jj) this->
at(ii,jj) += mat.
at(i,j);
250 for (
int i = 0; i < rsize; i++) maxid =
max(maxid, rloc[i]);
251 for (
int i = 0; i < csize; i++) maxid =
max(maxid, cloc[i]);
255 for (
int i = 0; i < csize; i++ ) {
259 for (
int j = 0; j < rsize; j++ ) {
265 columns[ ii1 ].at(rowindx) += mat(j, i);
277void DynCompCol :: zero()
287void DynCompCol :: printStatistics()
const
290 for (
auto &row :
rowind ) {
291 nz_ += row.giveSize();
298double &DynCompCol :: at(
int i,
int j)
304 return columns[ j - 1 ].at(rowIndx);
307 OOFEM_ERROR(
"Array accessing exception -- (%d,%d) out of bounds", i, j);
312double DynCompCol :: at(
int i,
int j)
const
316 return columns[ j - 1 ].at(rowIndx);
322 OOFEM_ERROR(
"Array accessing exception -- (%d,%d) out of bounds", i, j);
327double DynCompCol :: operator() (
int i,
int j)
const
331 return columns[ j ].at(rowIndx);
337 OOFEM_ERROR(
"Array accessing exception -- (%d,%d) out of bounds", i, j);
342double &DynCompCol :: operator() (
int i,
int j)
348 return columns[ j ].at(rowIndx);
351 OOFEM_ERROR(
"Array element (%d,%d) not in sparse structure -- cannot assign", i, j);
359 OOFEM_ERROR(
"Error in CompCol -- incompatible dimensions");
364 for (
int i = 0; i <
nColumns; i++ ) {
366 for (
int t = 1; t <=
columns[ i ].giveSize(); t++ ) {
380 for (
int i = 0; i < size; i++ ) {
381 maxid =
max( maxid, loc[i] );
386 for (
int i = 0; i < size; i++ ) {
389 for (
int j = 0; j < size; j++ ) {
407 for (
int i = 0; i < rsize; i++ ) {
408 maxid =
max( maxid, rloc[i] );
411 for (
int i = 0; i < csize; i++ ) {
412 maxid =
max( maxid, cloc[i] );
419 for (
int i = 0; i < csize; i++ ) {
422 for (
int j = 0; j < rsize; j++ ) {
434void DynCompCol :: growTo(
int ns)
444int DynCompCol :: giveRowIndx(
int col,
int row)
const
447 int left = 1, right = this->
rowind[ col ].giveSize();
448 int middle = ( left + right ) / 2;
455 if ( this->
rowind[ col ].
at(right) == row ) {
459 while ( !( ( ( middleVal = this->
rowind[ col ].
at(middle) ) == row ) || ( middle == left ) ) ) {
460 if ( row > middleVal ) {
466 middle = ( left + right ) / 2;
469 if ( middleVal == row ) {
478DynCompCol :: insertRowInColumn(
int col,
int row)
481 int oldsize = this->
rowind[ col ].giveSize();
482 int left = 1, right = oldsize;
483 int middle = ( left + right ) / 2;
486 if ( oldsize == 0 ) {
490 rowind[ col ].at(1) = row;
494 if ( this->
rowind[ col ].
at(right) == row ) {
498 while ( !( ( ( middleVal = this->
rowind[ col ].
at(middle) ) == row ) || ( middle == left ) ) ) {
499 if ( row > middleVal ) {
505 middle = ( left + right ) / 2;
508 if ( middleVal == row ) {
513 if ( row > this->
rowind[ col ].
at(oldsize) ) {
515 }
else if ( row < this->
rowind[ col ].
at(1) ) {
523 for (
int i = oldsize; i >= right; i-- ) {
528 columns[ col ].at(right) = 0.0;
529 rowind[ col ].at(right) = row;
#define REGISTER_SparseMtrx(class, type)
virtual void giveLocationArrays(std ::vector< IntArray > &rows, std ::vector< IntArray > &cols, CharType type, const UnknownNumberingScheme &r_s, const UnknownNumberingScheme &c_s)
std ::vector< std ::unique_ptr< GeneralBoundaryCondition > > & giveBcs()
Element * giveElement(int n)
std ::vector< std ::unique_ptr< Element > > & giveElements()
std::vector< IntArray > rowind
std::vector< FloatArray > columns
int insertRowInColumn(int col, int row)
Insert row entry into column, preserving order of row indexes, returns the index of new row.
int giveRowIndx(int col, int row) const
Returns the row index of given row at given column, else returns zero.
double & at(int i, int j) override
Returns coefficient at position (i,j).
void checkSizeTowards(IntArray &)
const FloatArray & column(int i) const
Returns column values.
virtual int giveNumberOfDomainEquations(int di, const UnknownNumberingScheme &num)
Domain * giveDomain(int n)
Index giveSize() const
Returns the size of receiver.
void zero()
Zeroes all coefficients of receiver.
int giveNumberOfColumns() const
Returns number of columns of receiver.
int giveNumberOfRows() const
Returns number of rows of receiver.
double at(std::size_t i, std::size_t j) const
int nColumns
Number of columns.
SparseMtrxVersionType version
SparseMtrx(int n=0, int m=0)
#define OOFEM_LOG_DEBUG(...)
FloatArrayF< N > max(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
@ SMT_DynCompCol
Dynamically growing compressed column.