Exemple #1
0
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);
}
Exemple #2
0
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;
}
Exemple #3
0
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;
}
Exemple #4
0
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;
  }
}
Exemple #5
0
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;
}