diff options
Diffstat (limited to 'src/c/linearAlgebra')
-rw-r--r-- | src/c/linearAlgebra/givens/dgivensa.c | 1 | ||||
-rw-r--r-- | src/c/linearAlgebra/hess/dhessa.c | 2 | ||||
-rw-r--r-- | src/c/linearAlgebra/householder/dhouseholdera.c | 2 | ||||
-rw-r--r-- | src/c/linearAlgebra/lu/dlua.c | 9 | ||||
-rw-r--r-- | src/c/linearAlgebra/qr/dqra.c | 4 | ||||
-rw-r--r-- | src/c/linearAlgebra/rank/zranka.c | 1 | ||||
-rw-r--r-- | src/c/linearAlgebra/rowcomp/drowcompa.c | 2 | ||||
-rw-r--r-- | src/c/linearAlgebra/sqroot/dsqroota.c | 10 | ||||
-rw-r--r-- | src/c/linearAlgebra/sva/dsvaa.c | 17 |
9 files changed, 24 insertions, 24 deletions
diff --git a/src/c/linearAlgebra/givens/dgivensa.c b/src/c/linearAlgebra/givens/dgivensa.c index 9bf0637b..dbdbf7b5 100644 --- a/src/c/linearAlgebra/givens/dgivensa.c +++ b/src/c/linearAlgebra/givens/dgivensa.c @@ -19,6 +19,7 @@ givens(x,y)=givens([x;y]) */ +#include <stdlib.h> #include "givens.h" #include <stdio.h> #include <math.h> diff --git a/src/c/linearAlgebra/hess/dhessa.c b/src/c/linearAlgebra/hess/dhessa.c index e1f2e2d1..5c881d9d 100644 --- a/src/c/linearAlgebra/hess/dhessa.c +++ b/src/c/linearAlgebra/hess/dhessa.c @@ -27,7 +27,7 @@ extern int dorghr_(int *, int *,int *,double *,int *,double *,double *,int *,int /* All the vairbale names are given exactly the same name as scilab source code */ void dhessa(double *in1,int size,int nout,double *out1, double *out2){ /* Variables names are done through, Lapack library. */ - int i,j,k; + int i,j; int N = size; int ILO=1; int IHI=N; diff --git a/src/c/linearAlgebra/householder/dhouseholdera.c b/src/c/linearAlgebra/householder/dhouseholdera.c index 5a98bfae..d1bf8465 100644 --- a/src/c/linearAlgebra/householder/dhouseholdera.c +++ b/src/c/linearAlgebra/householder/dhouseholdera.c @@ -34,7 +34,7 @@ Syntax :- void dhouseholdera(int ninp,double *inp1,int row,double *inp2,double *out1){ - int i,j; + int i; double *x; x = (double *)malloc(row*sizeof(double)); diff --git a/src/c/linearAlgebra/lu/dlua.c b/src/c/linearAlgebra/lu/dlua.c index d3cf6d11..a5c4f5ff 100644 --- a/src/c/linearAlgebra/lu/dlua.c +++ b/src/c/linearAlgebra/lu/dlua.c @@ -21,12 +21,9 @@ extern double dgetrf_ (int* , int* , double* , int* , int* , int* ); void dlua(double*inp1, int size, double* out1, double* out2) { - char TRANS = 'N'; int INFO=3; int LDA = 3; - int LDB = 3; int N = 3; - int NRHS = 1; int IPIV[2] ; /*double A[9] = @@ -37,15 +34,13 @@ void dlua(double*inp1, int size, double* out1, double* out2) };*/ //void LAPACK_dgetrf( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, lapack_int* ipiv, lapack_int *info ); -// dgetrf_(&N,&N,inp1,&LDA,IPIV,&INFO); + dgetrf_(&N,&N,inp1,&LDA,IPIV,&INFO); - dgetrf_(6,2,inp1,6,IPIV,&INFO); - // checks INFO, if INFO != 0 something goes wrong, for more information see the MAN page of dgetrf. for(int i = 0; i < 3*3; i++) printf("%lf \n ", inp1[i]); - printf("PIVOTTTTTT \n "); + printf("PIVOTTTTTT \n "); for(int i = 0; i < 2; i++) printf("%d \n ", IPIV[i]); diff --git a/src/c/linearAlgebra/qr/dqra.c b/src/c/linearAlgebra/qr/dqra.c index bae4bc27..42912a90 100644 --- a/src/c/linearAlgebra/qr/dqra.c +++ b/src/c/linearAlgebra/qr/dqra.c @@ -19,6 +19,8 @@ #include "lapack.h" #include "string.h" #include "matrixTranspose.h" +#include "max.h" +#include "min.h" /*For reference check Scilab source code & lapack library websites Names of variable are almost same for convience. @@ -153,8 +155,6 @@ double dqra(int ninp,int nout,double *inp1,int M,int N,double tol,double *out1,d [Q,R]=qr(A) [Q,R,E]=qr(A) */ - int LDA = M; - double *TAU; TAU = (double *)malloc(min(M,N)*sizeof(double)); diff --git a/src/c/linearAlgebra/rank/zranka.c b/src/c/linearAlgebra/rank/zranka.c index 0efad251..3f04bb1d 100644 --- a/src/c/linearAlgebra/rank/zranka.c +++ b/src/c/linearAlgebra/rank/zranka.c @@ -20,6 +20,7 @@ #include "svd.h" #include "doubleComplex.h" #include "addition.h" +#include "max.h" #define eps 2.22044604925e-16 diff --git a/src/c/linearAlgebra/rowcomp/drowcompa.c b/src/c/linearAlgebra/rowcomp/drowcompa.c index 3161a2d6..f622849d 100644 --- a/src/c/linearAlgebra/rowcomp/drowcompa.c +++ b/src/c/linearAlgebra/rowcomp/drowcompa.c @@ -16,11 +16,13 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <string.h> #include "svd.h" #include "norm.h" #include "eye.h" #include "matrixTranspose.h" #include "qr.h" +#include "min.h" /* All variable names, are in consideration of scilab documentation. for reference please check the scilab code.*/ diff --git a/src/c/linearAlgebra/sqroot/dsqroota.c b/src/c/linearAlgebra/sqroot/dsqroota.c index 1ba97268..d31d7cf2 100644 --- a/src/c/linearAlgebra/sqroot/dsqroota.c +++ b/src/c/linearAlgebra/sqroot/dsqroota.c @@ -19,6 +19,7 @@ #include "matrixTranspose.h" #include "svd.h" #include "matrixMultiplication.h" +#include "min.h" #define eps 2.22044604925e-16 @@ -33,14 +34,11 @@ void dsqroota(double *inp,int row,int col, double *out){ } int i,j; double *U,*S,*V; - double *A,*B; int rk; U = (double *)malloc((double)row*row*sizeof(double)); - S = (double *)malloc((double)Min(row,col)*Min(row,col)*sizeof(double)); + S = (double *)malloc((double)min(row,col)*min(row,col)*sizeof(double)); V = (double *)malloc((double)col*col*sizeof(double)); - A = (double *)malloc(rk*rk*sizeof(double)); - B = (double *)malloc(rk*row*sizeof(double)); double *Q1; Q1 = (double *)malloc(row*col*sizeof(double)); @@ -88,6 +86,10 @@ void dsqroota(double *inp,int row,int col, double *out){ } else{ rk = dsvda(0,inp,row,col,0,4,U,S,V); + + double *A,*B; + A = (double *)malloc(rk*rk*sizeof(double)); + B = (double *)malloc(rk*row*sizeof(double)); /*Will be used in complex numbers*/ //C = (double *)malloc(rk*row*sizeof(double)); diff --git a/src/c/linearAlgebra/sva/dsvaa.c b/src/c/linearAlgebra/sva/dsvaa.c index 691694e4..6c9d95e1 100644 --- a/src/c/linearAlgebra/sva/dsvaa.c +++ b/src/c/linearAlgebra/sva/dsvaa.c @@ -17,6 +17,8 @@ #include <stdlib.h> #include "string.h" #include "matrixTranspose.h" +#include "max.h" +#include "min.h" #define eps 2.22044604925e-16 @@ -30,18 +32,17 @@ void dsvaa(int ninp,double *in1,int row,int col,double in2,double *out1, \ if(row == 0 && col == 0) return; int i,j; int arow; /*Actual row of given matrix*/ - int acol; /*Actual col of given matrix*/ /* 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){ @@ -53,7 +54,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; @@ -71,20 +72,18 @@ void dsvaa(int ninp,double *in1,int row,int col,double in2,double *out1, \ } } arow = M; - 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); + 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++){ /* Copying, the output in required format */ for(j=0;j<rk;j++){ out3[i+j*arow] = V[i+j*arow]; |