MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / SolveBanded

Method SolveBanded

src/Mod/Mesh/App/WildMagic4/Wm4LinearSystem.cpp:614–648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

612//----------------------------------------------------------------------------
613template <class Real>
614bool LinearSystem<Real>::SolveBanded (const BandedMatrix<Real>& rkA,
615 const Real* afB, Real* afX)
616{
617 BandedMatrix<Real> kTmp = rkA;
618 int iSize = rkA.GetSize();
619 size_t uiSize = iSize*sizeof(Real);
620 System::Memcpy(afX,uiSize,afB,uiSize);
621
622 // forward elimination
623 int iRow;
624 for (iRow = 0; iRow < iSize; iRow++)
625 {
626 if (!ForwardEliminate(iRow,kTmp,afX))
627 {
628 return false;
629 }
630 }
631
632 // backward substitution
633 for (iRow = iSize-2; iRow >= 0; iRow--)
634 {
635 int iColMin = iRow + 1;
636 int iColMax = iColMin + kTmp.GetUBands();
637 if (iColMax > iSize)
638 {
639 iColMax = iSize;
640 }
641 for (int iCol = iColMin; iCol < iColMax; iCol++)
642 {
643 afX[iRow] -= kTmp(iRow,iCol)*afX[iCol];
644 }
645 }
646
647 return true;
648}
649//----------------------------------------------------------------------------
650template <class Real>
651bool LinearSystem<Real>::ForwardEliminate (int iReduceRow,

Callers

nothing calls this directly

Calls 1

GetSizeMethod · 0.45

Tested by

no test coverage detected