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/sqroot/dsqroota.c | 130 ++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 src/c/linearAlgebra/sqroot/dsqroota.c (limited to 'src/c/linearAlgebra/sqroot/dsqroota.c') diff --git a/src/c/linearAlgebra/sqroot/dsqroota.c b/src/c/linearAlgebra/sqroot/dsqroota.c new file mode 100644 index 0000000..038afc9 --- /dev/null +++ b/src/c/linearAlgebra/sqroot/dsqroota.c @@ -0,0 +1,130 @@ +/* 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 + */ + +/* Function - sqroot of scilab, W*W' hermitian factorization */ + +#include +#include "stdlib.h" +#include "string.h" +#include +#include "matrixTranspose.h" +#include "svd.h" +#include "matrixMultiplication.h" + +#define eps 2.22044604925e-16 + +/*It would be good, if you are doing conversoins for only valid inputs before + running the program, check all the conditions before hand. +*/ + +void dsqroota(double *inp,int row,int col, double *out){ + if(row != col){ + printf("Enter valid inputs only - matrix should be symetric\n"); + return; + } + 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)); + 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)); + + dtransposea(inp,row,col,Q1); + + double *Q2; + Q2 = (double *)malloc(col*row*sizeof(double)); + + /* Q2 = (inp+inp1')/2; */ + for(i=0;i 100*%eps then */ + if(maxi > 100*eps){ + printf("Warning: Wrong size for input argument and Symmetric expected\n"); + } + maxi = 0; + for(i=0;i -#include "stdlib.h" -#include "string.h" -#include -#include "matrixTranspose.h" -#include "svd.h" -#include "matrixMultiplication.h" - -#define eps 2.22044604925e-16 - -/*It would be good, if you are doing conversoins for only valid inputs before - running the program, check all the conditions before hand. -*/ - -void dsqroota(double *inp,int row,int col, double *out){ - if(row != col){ - printf("Enter valid inputs only - matrix should be symetric\n"); - return; - } - 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)); - 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)); - - dtransposea(inp,row,col,Q1); - - double *Q2; - Q2 = (double *)malloc(col*row*sizeof(double)); - - /* Q2 = (inp+inp1')/2; */ - for(i=0;i 100*%eps then */ - if(maxi > 100*eps){ - printf("Warning: Wrong size for input argument and Symmetric expected\n"); - } - maxi = 0; - for(i=0;i +#include "stdlib.h" +#include "string.h" +#include +#include "matrixTranspose.h" +#include "svd.h" +#include "matrixMultiplication.h" + +#define eps 2.22044604925e-16 + +/*It would be good, if you are doing conversoins for only valid inputs before + running the program, check all the conditions before hand. +*/ + +void dsqroota(double *inp,int row,int col, double *out){ + if(row != col){ + printf("Enter valid inputs only - matrix should be symetric\n"); + return; + } + 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)); + 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)); + + dtransposea(inp,row,col,Q1); + + double *Q2; + Q2 = (double *)malloc(col*row*sizeof(double)); + + /* Q2 = (inp+inp1')/2; */ + for(i=0;i 100*%eps then */ + if(maxi > 100*eps){ + printf("Warning: Wrong size for input argument and Symmetric expected\n"); + } + maxi = 0; + for(i=0;i