diff --git a/vcg/math/lin_algebra.h b/vcg/math/lin_algebra.h index ce5cc2c6..b5ddda04 100644 --- a/vcg/math/lin_algebra.h +++ b/vcg/math/lin_algebra.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.13 2006/07/28 12:39:05 zifnab1974 +added some typename directives + Revision 1.12 2006/07/24 07:26:47 fiorin Changed the template argument in JacobiRotate and added method for sorting eigenvalues and eigenvectors (SortEigenvaluesAndEigenvectors) @@ -79,33 +82,33 @@ namespace vcg for (ip=0;ip4 && (float)(fabs(d[ip])+g) == (float)fabs(d[ip]) && (float)(fabs(d[iq])+g) == (float)fabs(d[iq])) - w[ip][iq]=0.0; + w[ip][iq]=ScalarType(0.0); else if (fabs(w[ip][iq]) > tresh) { h=d[iq]-d[ip]; @@ -113,19 +116,19 @@ namespace vcg t=(w[ip][iq])/h; //t =1/(2#) else { - theta=0.5*h/(w[ip][iq]); //Equation (11.1.10). - t=1.0/(fabs(theta)+sqrt(1.0+theta*theta)); - if (theta < 0.0) t = -t; + theta=ScalarType(0.5)*h/(w[ip][iq]); //Equation (11.1.10). + t=ScalarType(1.0)/(fabs(theta)+sqrt(ScalarType(1.0)+theta*theta)); + if (theta < ScalarType(0.0)) t = -t; } - c=1.0/sqrt(1+t*t); + c=ScalarType(1.0)/sqrt(ScalarType(1.0)+t*t); s=t*c; - tau=s/(1.0+c); + tau=s/(ScalarType(1.0)+c); h=t*w[ip][iq]; z[ip] -= h; z[iq] += h; d[ip] -= h; d[iq] += h; - w[ip][iq]=0.0; + w[ip][iq]=ScalarType(0.0); for (j=0;j<=ip-1;j++) { //Case of rotations 1 <= j < p. JacobiRotate(w,s,tau,j,ip,j,iq) ; } @@ -156,7 +159,7 @@ namespace vcg * Given the eigenvectors and the eigenvalues as output from JacobiRotate, sorts the eigenvalues * into descending order, and rearranges the columns of v correspondinlgy. /param eigenvalues - /param eigenvector + /param eigenvector (in columns) */ template < typename MATRIX_TYPE, typename POINT_TYPE > void SortEigenvaluesAndEigenvectors(POINT_TYPE &eigenvalues, MATRIX_TYPE &eigenvectors)