MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / ComposeOperators

Function ComposeOperators

linalg/basematrix.cpp:606–648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

604
605
606 shared_ptr<BaseMatrix> ComposeOperators (shared_ptr<BaseMatrix> a,
607 shared_ptr<BaseMatrix> b)
608 {
609 if (auto embb = dynamic_pointer_cast<EmbeddingTranspose> (b))
610 {
611 // cout << "embeddingT optimization" << endl;
612 return make_shared<EmbeddedTransposeMatrix> (embb->Width(), embb->GetRange(), a);
613 }
614
615 if (auto emba = dynamic_pointer_cast<Embedding> (a))
616 {
617 // cout << "embedding optimization" << endl;
618 return make_shared<EmbeddedMatrix> (emba->Height(), emba->GetRange(), b);
619 }
620
621 auto para = dynamic_pointer_cast<ParallelMatrix> (a);
622 auto parb = dynamic_pointer_cast<ParallelMatrix> (b);
623
624 if (para && parb)
625 {
626 if (RowType(para->GetOpType()) == ColType(parb->GetOpType()))
627 {
628 // cout << "combining parallel matrices" << endl;
629 auto localprod = ComposeOperators (para->GetMatrix(), parb->GetMatrix());
630 return make_shared<ParallelMatrix> (localprod,
631 parb->GetRowParallelDofs(),
632 para->GetColParallelDofs(),
633 ParallelOp(RowType(parb->GetOpType()), ColType(para->GetOpType())));
634 }
635 else
636 {
637 cerr << "illegal operator composition" << endl;
638 cerr << "optyp A = " << int(para->GetOpType()) << endl;
639 cerr << "optyp B = " << int(parb->GetOpType()) << endl;
640 auto & locmata = *para->GetMatrix();
641 auto & locmatb = *parb->GetMatrix();
642 cerr << "type a parallelmat of = " << typeid(locmata).name()
643 << ", type b = " <<typeid(locmatb).name() << endl;
644 }
645 }
646
647 return make_shared<ProductMatrix> (a, b);
648 }
649
650 shared_ptr<BaseMatrix> AddOperators (shared_ptr<BaseMatrix> a,
651 shared_ptr<BaseMatrix> b,

Callers 4

GetTraceOperatorMethod · 0.85
FinalizeMethod · 0.85
operator*Function · 0.85

Calls 10

RowTypeFunction · 0.85
ColTypeFunction · 0.85
ParallelOpFunction · 0.85
WidthMethod · 0.45
GetRangeMethod · 0.45
HeightMethod · 0.45
GetOpTypeMethod · 0.45
GetMatrixMethod · 0.45
GetRowParallelDofsMethod · 0.45
GetColParallelDofsMethod · 0.45

Tested by

no test coverage detected