diff options
Diffstat (limited to '2.3-1/src/c/linearAlgebra/sva/dsvaa.c')
-rw-r--r-- | 2.3-1/src/c/linearAlgebra/sva/dsvaa.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/2.3-1/src/c/linearAlgebra/sva/dsvaa.c b/2.3-1/src/c/linearAlgebra/sva/dsvaa.c index b7d07d8c..691694e4 100644 --- a/2.3-1/src/c/linearAlgebra/sva/dsvaa.c +++ b/2.3-1/src/c/linearAlgebra/sva/dsvaa.c @@ -20,6 +20,7 @@ #define eps 2.22044604925e-16 +/* Ref: Scilab source code */ void dsvaa(int ninp,double *in1,int row,int col,double in2,double *out1, \ double *out2,double *out3){ @@ -33,14 +34,14 @@ void dsvaa(int ninp,double *in1,int row,int col,double in2,double *out1, \ /* Calculation of svd of a given matrix */ double *U,*S,*V; - U = (double *)malloc((double)row*min(row,col)*sizeof(double)); - S = (double *)malloc((double)min(row,col)*min(row,col)*sizeof(double)); - V = (double *)malloc((double)col*min(row,col)*sizeof(double)); + U = (double *)malloc((double)row*Min(row,col)*sizeof(double)); + S = (double *)malloc((double)Min(row,col)*Min(row,col)*sizeof(double)); + V = (double *)malloc((double)col*Min(row,col)*sizeof(double)); dsvda(0,in1,M,N,1,3,U,S,V); if (ninp == 1){ /* [u,s,v] = sva(A) when input is only matrix */ - tol = max(row,col)*S[0]*eps; + tol = Max(row,col)*S[0]*eps; rk = 0; for(i=0;i<col;i++){ if(S[i+i*row] > tol){ @@ -52,7 +53,7 @@ void dsvaa(int ninp,double *in1,int row,int col,double in2,double *out1, \ tol = in2; if(tol > 1){ rk = tol; - if(rk > min(row,col)){ + if(rk > Min(row,col)){ printf("ERROR: Wrong value for input argument !"); out1 = NULL; out2 = NULL; @@ -70,21 +71,21 @@ void dsvaa(int ninp,double *in1,int row,int col,double in2,double *out1, \ } } arow = M; - acol = min(M,N); + acol = Min(M,N); /* Copying, the output in required format */ for(i=0;i<arow;i++){ for(j=0;j<rk;j++){ out1[i+j*row]=U[i+j*arow]; } } - arow = min(M,N); - for(i=0;i<rk;i++){ + arow = Min(M,N); + for(i=0;i<rk;i++){ /* Copying, the output in required format */ for(j=0;j<rk;j++){ out2[i+j*(int)rk] = S[i+j*arow]; } } arow = N; - acol = min(M,N); - for(i=0;i<arow;i++){ + acol = Min(M,N); + for(i=0;i<arow;i++){ /* Copying, the output in required format */ for(j=0;j<rk;j++){ out3[i+j*arow] = V[i+j*arow]; } |