/* 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