Exemple #1
0
void NRQRDecomposition<T>::QBackSub(const VectorT& x,VectorT& b) const
{
  b.copy(x);
  int i,j;
  int n=QR.n;
  T sum,tau;
  for (j=0;j<n-1;j++) { //Form QT*b. 
    for (sum=0,i=j;i<n;i++) 
      sum += QR(i,j)*b(i);
    tau=sum/c(j);
    for (i=j;i<n;i++)
      b(i) -= tau*QR(i,j);
  }
}
Exemple #2
0
void MatrixTemplate<T>::copyCols(const VectorT* cols)
{
  CHECKEMPTY();
  for(int j=0; j<n; j++)
  {
    if(cols[j].n != m)
    {
      RaiseErrorFmt(WHERE_AM_I,MatrixError_IncompatibleDimensions,m,n,cols[j].n,-1);
    }
    VectorT tempcol;
    getColRef(j,tempcol);
    tempcol.copy(cols[j]);
  }
}
Exemple #3
0
void QRDecomposition<T>::QMul(const VectorT& b, VectorT& v) const
{
  Assert (tau.n == Min(QR.m,QR.n));
  Assert(b.n == QR.m);
  v.copy(b);

  for (int i = Min(QR.m,QR.n); i > 0 && i--;) {
    VectorT c,h,w;
    QR.getColRef(i,c);
    h.setRef(c,i);
    w.setRef(v,i);
    HouseholderApply (tau(i),h,w);
  }
}
Exemple #4
0
void MatrixTemplate<T>::copyRows(const VectorT* rows)
{
  CHECKEMPTY();
  for(int i=0; i<m; i++)
  {
    if(rows[i].n != n)
    {
      RaiseErrorFmt(WHERE_AM_I,MatrixError_IncompatibleDimensions,m,n,-1,rows[i].n);
    }
    VectorT temprow;
    getRowRef(i,temprow);
    temprow.copy(rows[i]);
  }
}