bug fixed in SingularValueBacksubstitution

This commit is contained in:
Paolo Cignoni 2004-10-18 12:18:10 +00:00
parent 1422c15f6f
commit 77dc6537fa
1 changed files with 11 additions and 10 deletions

View File

@ -382,24 +382,25 @@ namespace vcg
typename MATRIX_TYPE::ScalarType *x,
const typename MATRIX_TYPE::ScalarType *b)
{
typedef typename MATRIX_TYPE::ScalarType ScalarType;
unsigned int jj, j, i;
ScalarType s;
ScalarType tmp = new ScalarType[U._columns];
for (j=0; j<U._columns; j++) //Calculate U^T * B.
ScalarType *tmp = new ScalarType[U.ColumnsNumber()];
for (j=0; j<U.ColumnsNumber(); j++) //Calculate U^T * B.
{
s = 0;
if (W[j]!=0) //Nonzero result only if wj is nonzero.
{
for (i=0; i<U._rows; i++)
for (i=0; i<U.RowsNumber(); i++)
s += U[i][j]*b[i];
s /= w[j]; //This is the divide by wj .
s /= W[j]; //This is the divide by wj .
}
tmp[j]=s;
}
for (j=0;j<U._columns;j++) //Matrix multiply by V to get answer.
for (j=0;j<U.ColumnsNumber();j++) //Matrix multiply by V to get answer.
{
s = 0;
for (jj=0; jj<U._columns; jj++)
for (jj=0; jj<U.ColumnsNumber(); jj++)
s += V[j][jj]*tmp[jj];
x[j]=s;
}