void LDLDecomposition<T>::backSub(const VectorT& b, VectorT& x) const { //LDLt*x=b //DLt*x=L^-1*b=y //Lt*x=D^-1*y=y' //x=(Lt^-1)y VectorT y; LBackSub(b,y); DBackSub(y,y); LTBackSub(y,x); }
bool LDLDecomposition<T>::backSub(const VectorT& b, VectorT& x) const { //LDLt*x=b //DLt*x=L^-1*b=y //Lt*x=D^-1*y=y' //x=(Lt^-1)y VectorT y; LBackSub(b,y); bool res=DBackSub(y,y); LTBackSub(y,x); return res; }
bool LDLDecomposition<T>::backSub(const MatrixT& B, MatrixT& X) const { X.resize(B.m,B.n); MatrixT temp(B.m,B.n); L1BackSubstitute(LDL,B,temp); VectorT tempi; bool res=true; for(int i=0;i<temp.n;i++) { temp.getColRef(i,tempi); if(!DBackSub(tempi,tempi)) res=false; } Lt1BackSubstitute(LDL,temp,X); return res; }
void LDLDecomposition<T>::getInverse(MatrixT& Ainv) const { Ainv.resize(LDL.n,LDL.n); VectorT temp(LDL.n,Zero),y,x; for(int i=0;i<LDL.n;i++) { temp(i)=One; LBackSub(temp,y); DBackSub(y,y); LTBackSub(y,x); //fill in a column for(int j=0;j<LDL.n;j++) Ainv(j,i)=x(j); temp(i)=Zero; } }
bool LDLDecomposition<T>::getInverse(MatrixT& Ainv) const { Ainv.resize(LDL.n,LDL.n); bool res=true; VectorT temp(LDL.n,Zero),y,x; for(int i=0;i<LDL.n;i++) { temp(i)=One; LBackSub(temp,y); if(!DBackSub(y,y)) res=false; LTBackSub(y,x); //fill in a column for(int j=0;j<LDL.n;j++) Ainv(j,i)=x(j); temp(i)=Zero; } return true; }