73std::unique_ptr<SparseMtrx>
74SkylineUnsym :: clone()
const
76 return std::make_unique<SkylineUnsym>(*
this);
87 for (
int i = start; i <= j; i++ ) {
88 answer.
at(i, j) = this->
at(i, j);
89 answer.
at(j, i) = this->
at(j, i);
96SkylineUnsym :: at(
int i,
int j)
102 }
else if ( i > j ) {
111SkylineUnsym :: at(
int i,
int j)
const
115 }
else if ( i > j ) {
130 OOFEM_ERROR(
"dimension of 'k' and 'loc' mismatch");
139 for (
int j = 1; j <= dim; j++ ) {
142 for (
int i = 1; i <= dim; i++ ) {
145 this->
at(ii, jj) += mat.
at(i, j);
164 for (
int i = 1; i <= dim1; i++ ) {
167 for (
int j = 1; j <= dim2; j++ ) {
170 this->
at(ii, jj) += mat.
at(i, j);
187 for (
auto r : rloc ) {
188 maxCol =
max( maxCol, r );
191 for (
auto c : cloc ) {
192 maxCol =
max( maxCol, c );
199 for (
auto ii : rloc ) {
205 for (
auto jj : cloc ) {
231 for (
int i = 1; i <= neq; i++ ) {
232 firstIndex.
at(i) = i;
235 for (
int n = 1; n <= nelem; n++ ) {
240 elem->giveLocationArray(loc, s);
244 elem->giveLocationArray(loc, s);
249 for (
int i = 1; i <= loc.
giveSize(); i++ ) {
251 if ( ii && ii < first ) {
257 for (
int i = 1; i <= loc.
giveSize(); i++ ) {
259 if ( ii && ( first < firstIndex.
at(ii) ) ) {
260 firstIndex.
at(ii) = first;
267 std :: vector< IntArray >r_locs;
268 std :: vector< IntArray >c_locs;
270 for (
int i = 1; i <= nbc; ++i ) {
274 for ( std :: size_t j = 0; j < r_locs.size(); j++ ) {
278 for (
int k = 1; k <= kcloc.
giveSize(); k++ ) {
279 int kk = kcloc.
at(k);
281 first =
min(first, kk);
284 for (
int k = 1; k <= krloc.
giveSize(); k++ ) {
285 int kk = krloc.
at(k);
286 if ( kk && ( first < firstIndex.
at(kk) ) ) {
287 firstIndex.
at(kk) = first;
297 for (
auto &in: eModel->giveIntegralList()) {
299 for (
auto &elem: in->set->giveElementList()) {
301 in->getElementTermCodeNumbers (locr, locc, domain->
giveElement(elem), *in->term, s) ;
303 for (
int k = 1; k <= locc.
giveSize(); k++ ) {
306 first =
min(first, kk);
309 for (
int k = 1; k <= locr.
giveSize(); k++ ) {
311 if ( kk && ( first < firstIndex.
at(kk) ) ) {
312 firstIndex.
at(kk) = first;
319 for (
int i = 1; i <= neq; i++ ) {
332int SkylineUnsym :: setInternalStructure(
IntArray &adr1)
346 for (
int i = 1; i <= n - 1; i++ ) {
347 mht.
at(i) = adr1.
at(i + 1) - adr1.
at(i);
348 firstIndex.
at(i) = i - mht.
at(i) + 1;
352 for (
int i = 1; i <= n - 1; i++ ) {
368SkylineUnsym :: checkSizeTowards(
const IntArray &loc)
371 for (
auto c: loc ) {
372 maxCol =
max( maxCol, c );
375 if ( maxCol > (
int)this->
rowColumns.size() ) {
379 for (
auto ii: loc ) {
388SkylineUnsym :: factorized()
410 int startK = rowColumnK.giveStart();
417 for (
int p = startK; p < k; p++ ) {
419 r.
at(p) =
diag * rowColumnK.atU(p);
420 w.
at(p) =
diag * rowColumnK.atL(p);
424 rowColumnK.atDiag() -= rowColumnK.dot(r,
'R', startK, k - 1);
425 double diag = rowColumnK.atDiag();
430 OOFEM_LOG_DEBUG(
"SkylineUnsym :: factorized: zero pivot %d artificially set to a small value", k);
436 int startI = rowColumnI.giveStart();
438 int start =
max(startI, startK);
439 rowColumnI.atL(k) -= rowColumnI.dot(r,
'R', start, k - 1);
440 rowColumnI.atL(k) /=
diag;
441 rowColumnI.atU(k) -= rowColumnI.dot(w,
'C', start, k - 1);
442 rowColumnI.atU(k) /=
diag;
464 if ( y.
giveSize() != this->giveNumberOfColumns() ) {
470 int start = rowColumnK.giveStart();
471 y.
at(k) -= rowColumnK.dot(y,
'R', start, k - 1);
490 int start = rowColumnK.giveStart();
491 for (
int i = start; i < k; i++ ) {
492 y.
at(i) -= rowColumnK.atU(i) * yK;
512 int starti = rowColumni.giveStart();
513 answer.
at(i) += rowColumni.dot(x,
'R', starti, i - 1);
514 answer.
at(i) += rowColumni.atDiag() * x.
at(i);
516 for (
int j = starti; j <= i - 1; j++ ) {
517 answer.
at(j) += rowColumni.atU(j) * x.
at(i);
523void SkylineUnsym :: times(
double x)
527 int starti = rowColumni.giveStart();
528 for (
int j = starti; j <= i - 1; j++ ) {
529 rowColumni.atU(j) *= x;
530 rowColumni.atL(j) *= x;
533 rowColumni.atDiag() *= x;
541SkylineUnsym :: growTo(
int n)
544 for (
int i = 1; i <= n; ++i ) {
552SkylineUnsym :: printStatistics()
const
556 nelem += rc.giveSize();
564SkylineUnsym :: writeToFile(
const char *fname)
const
566 FILE *file = fopen(fname,
"w");
569 for (
int i = 1; i <=
nRows; ++i ) {
570 for (
int j = 1; j <=
nColumns; ++j ) {
571 fprintf( file,
"%.16e ", copy.
at(i, j) );
580SkylineUnsym :: printYourself()
const
591SkylineUnsym :: zero()
614 int starti = rowColumni.giveStart();
615 answer.
at(i) += rowColumni.dot(x,
'C', starti, i - 1);
616 answer.
at(i) += rowColumni.atDiag() * x.
at(i);
618 for (
int j = starti; j <= i - 1; j++ ) {
619 answer.
at(j) += rowColumni.atL(j) * x.
at(i);
#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)
int giveNumberOfBoundaryConditions() const
Returns number of boundary conditions in domain.
int giveNumberOfElements() const
Returns number of elements in domain.
Element * giveElement(int n)
GeneralBoundaryCondition * giveBc(int n)
virtual int giveNumberOfDomainEquations(int di, const UnknownNumberingScheme &num)
Domain * giveDomain(int n)
virtual int useNonlocalStiffnessOption()
Returns nonzero if nonlocal stiffness option activated.
Index giveSize() const
Returns the size of receiver.
void zero()
Zeroes all coefficients of receiver.
void resize(Index rows, Index cols)
void zero()
Zeroes all coefficient of receiver.
*Prints matrix to stdout Useful for debugging void printYourself() const
int giveNumberOfRows() const
Returns number of rows of receiver.
double at(std::size_t i, std::size_t j) const
void zero()
Sets all component to zero.
std::vector< RowColumn > rowColumns
Row column segments.
void printStatistics() const override
Prints the receiver statistics (one-line) to stdout.
void checkSizeTowards(const IntArray &)
int isFactorized
Factorization flag.
void toFloatMatrix(FloatMatrix &answer) const override
Converts receiving sparse matrix to a dense float matrix.
double & at(int i, int j) override
Returns coefficient at position (i,j).
int nColumns
Number of columns.
SparseMtrxVersionType version
int giveNumberOfRows() const
Returns number of rows of receiver.
int giveNumberOfColumns() const
Returns number of columns of receiver.
SparseMtrx(int n=0, int m=0)
double getUtime()
Returns total user time elapsed in seconds.
#define OOFEM_WARNING(...)
#define OOFEM_LOG_INFO(...)
#define OOFEM_LOG_DEBUG(...)
FloatArrayF< N > min(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
FloatArrayF< N > max(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
FloatMatrixF< N, N > diag(const FloatArrayF< N > &v)
@ SMT_SkylineU
Unsymmetric skyline.
#define SkylineUnsym_TINY_PIVOT
"zero" pivot for SkylineUnsym class