From 06337f0dc8114c70fd0c7767083971a0d091750a Mon Sep 17 00:00:00 2001 From: Sandeep Gupta Date: Wed, 5 Jul 2017 12:41:25 +0530 Subject: LinearAlgebra and MatrixOperation Update --- src/c/linearAlgebra/givens/dgivensa.c | 76 +++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/c/linearAlgebra/givens/dgivensa.c (limited to 'src/c/linearAlgebra/givens/dgivensa.c') diff --git a/src/c/linearAlgebra/givens/dgivensa.c b/src/c/linearAlgebra/givens/dgivensa.c new file mode 100644 index 0000000..9bf0637 --- /dev/null +++ b/src/c/linearAlgebra/givens/dgivensa.c @@ -0,0 +1,76 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Sandeep Gupta + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ + +/* GIVENS scilab function + Syntax : u=givens(xy) + u=givens(x,y) + xy = [x;y], u=givens(xy) + returns a 2*2 matrix u such that u*xy=[r;0]. + c is equal to u*xy + givens(x,y)=givens([x;y]) +*/ + +#include "givens.h" +#include +#include +#include "norm.h" + +/* All variable names are according to scilab code */ + +void dgivensa(int ninp,double *inp1,int row,int col,double *inp2,int row1,int col1,int nout,double *out1,double *out2){ + double *x; + double r; + x = (double *)malloc((double)2*sizeof(double)); + if(ninp == 2){ + if(row != 1 || col != 1 || row1 != 1 || col1 != 1){ + printf("Wrong size for input argument: A column vector expected.\n"); + return; + } + *(x) = *(inp1); + *(x+1) = *(inp2); + } + else{ + //printf("(%d %d)",row,col); + if(row != 2 || col != 1){ + printf("Wrong size for input argument: A column vector expected.\n"); + return; + } + //printf("(%lf %lf)",inp1[0],inp1[1]); + x[0] = inp1[0]; + x[1] = inp1[1]; + } + if(*(x+1) != 0){ + //printf("(%lf %lf)",x[0],x[1]); + /*Norm of type 2 - find the maximum singular value*/ + r = dnorma(x,2,1,2); + //printf("%lf \n",r); + *(out1) = (*(x))/r; + *(out1+1) = -(*(x+1))/r; + *(out1+2) = (*(x+1))/r; + *(out1+3) = (*(x))/r; + if(nout == 2){ + *(out2) = r; + *(out2+1) = 0; + } + + } + else{ + *(out1) = 1; + *(out1+1) = 0; + *(out1+2) = 1; + *(out1+3) = 0; + if(nout == 2){ + *(out2) = *(x); + *(out2+1) = *(x+1); + } + } +} -- cgit From ea958d3c401761dcc24865d9639b2fab31038db8 Mon Sep 17 00:00:00 2001 From: Brijeshcr Date: Thu, 6 Jul 2017 15:48:47 +0530 Subject: Revert "LinearAlgebra Function Added" --- src/c/linearAlgebra/givens/dgivensa.c | 76 ----------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 src/c/linearAlgebra/givens/dgivensa.c (limited to 'src/c/linearAlgebra/givens/dgivensa.c') diff --git a/src/c/linearAlgebra/givens/dgivensa.c b/src/c/linearAlgebra/givens/dgivensa.c deleted file mode 100644 index 9bf0637..0000000 --- a/src/c/linearAlgebra/givens/dgivensa.c +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (C) 2017 - IIT Bombay - FOSSEE - - This file must be used under the terms of the CeCILL. - This source file is licensed as described in the file COPYING, which - you should have received as part of this distribution. The terms - are also available at - http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt - Author: Sandeep Gupta - Organization: FOSSEE, IIT Bombay - Email: toolbox@scilab.in - */ - -/* GIVENS scilab function - Syntax : u=givens(xy) - u=givens(x,y) - xy = [x;y], u=givens(xy) - returns a 2*2 matrix u such that u*xy=[r;0]. - c is equal to u*xy - givens(x,y)=givens([x;y]) -*/ - -#include "givens.h" -#include -#include -#include "norm.h" - -/* All variable names are according to scilab code */ - -void dgivensa(int ninp,double *inp1,int row,int col,double *inp2,int row1,int col1,int nout,double *out1,double *out2){ - double *x; - double r; - x = (double *)malloc((double)2*sizeof(double)); - if(ninp == 2){ - if(row != 1 || col != 1 || row1 != 1 || col1 != 1){ - printf("Wrong size for input argument: A column vector expected.\n"); - return; - } - *(x) = *(inp1); - *(x+1) = *(inp2); - } - else{ - //printf("(%d %d)",row,col); - if(row != 2 || col != 1){ - printf("Wrong size for input argument: A column vector expected.\n"); - return; - } - //printf("(%lf %lf)",inp1[0],inp1[1]); - x[0] = inp1[0]; - x[1] = inp1[1]; - } - if(*(x+1) != 0){ - //printf("(%lf %lf)",x[0],x[1]); - /*Norm of type 2 - find the maximum singular value*/ - r = dnorma(x,2,1,2); - //printf("%lf \n",r); - *(out1) = (*(x))/r; - *(out1+1) = -(*(x+1))/r; - *(out1+2) = (*(x+1))/r; - *(out1+3) = (*(x))/r; - if(nout == 2){ - *(out2) = r; - *(out2+1) = 0; - } - - } - else{ - *(out1) = 1; - *(out1+1) = 0; - *(out1+2) = 1; - *(out1+3) = 0; - if(nout == 2){ - *(out2) = *(x); - *(out2+1) = *(x+1); - } - } -} -- cgit From 7a7f685a8436b456b246c49baf76bb8af930b214 Mon Sep 17 00:00:00 2001 From: Sandeep Gupta Date: Fri, 7 Jul 2017 00:29:35 +0530 Subject: NORM --- src/c/linearAlgebra/givens/dgivensa.c | 76 +++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/c/linearAlgebra/givens/dgivensa.c (limited to 'src/c/linearAlgebra/givens/dgivensa.c') diff --git a/src/c/linearAlgebra/givens/dgivensa.c b/src/c/linearAlgebra/givens/dgivensa.c new file mode 100644 index 0000000..9bf0637 --- /dev/null +++ b/src/c/linearAlgebra/givens/dgivensa.c @@ -0,0 +1,76 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Sandeep Gupta + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ + +/* GIVENS scilab function + Syntax : u=givens(xy) + u=givens(x,y) + xy = [x;y], u=givens(xy) + returns a 2*2 matrix u such that u*xy=[r;0]. + c is equal to u*xy + givens(x,y)=givens([x;y]) +*/ + +#include "givens.h" +#include +#include +#include "norm.h" + +/* All variable names are according to scilab code */ + +void dgivensa(int ninp,double *inp1,int row,int col,double *inp2,int row1,int col1,int nout,double *out1,double *out2){ + double *x; + double r; + x = (double *)malloc((double)2*sizeof(double)); + if(ninp == 2){ + if(row != 1 || col != 1 || row1 != 1 || col1 != 1){ + printf("Wrong size for input argument: A column vector expected.\n"); + return; + } + *(x) = *(inp1); + *(x+1) = *(inp2); + } + else{ + //printf("(%d %d)",row,col); + if(row != 2 || col != 1){ + printf("Wrong size for input argument: A column vector expected.\n"); + return; + } + //printf("(%lf %lf)",inp1[0],inp1[1]); + x[0] = inp1[0]; + x[1] = inp1[1]; + } + if(*(x+1) != 0){ + //printf("(%lf %lf)",x[0],x[1]); + /*Norm of type 2 - find the maximum singular value*/ + r = dnorma(x,2,1,2); + //printf("%lf \n",r); + *(out1) = (*(x))/r; + *(out1+1) = -(*(x+1))/r; + *(out1+2) = (*(x+1))/r; + *(out1+3) = (*(x))/r; + if(nout == 2){ + *(out2) = r; + *(out2+1) = 0; + } + + } + else{ + *(out1) = 1; + *(out1+1) = 0; + *(out1+2) = 1; + *(out1+3) = 0; + if(nout == 2){ + *(out2) = *(x); + *(out2+1) = *(x+1); + } + } +} -- cgit