diff options
31 files changed, 1894 insertions, 2 deletions
diff --git a/2.3-1/includes/sci2clib.h b/2.3-1/includes/sci2clib.h index 8f458f71..640606be 100644 --- a/2.3-1/includes/sci2clib.h +++ b/2.3-1/includes/sci2clib.h @@ -325,6 +325,9 @@ /*interfacing flipdim*/ #include "int_flipdim.h" #include "flipdim.h" +/*interfacing norm*/ +#include "int_norm.h" +#include "norm.h" /* SIGNAL PROCESSING */ /* interfacing convol */ @@ -391,6 +394,10 @@ #include "ode.h" #include "int_ode.h" +/*Diff function*/ +#include "diffc.h" +#include "int_diffc.h" + /*Functions related to file handling*/ #include "files.h" #include "int_files.h" diff --git a/2.3-1/macros/ASTManagement/AST_ExtractNameAndScope.bin b/2.3-1/macros/ASTManagement/AST_ExtractNameAndScope.bin Binary files differindex cd93132b..260f69a5 100644 --- a/2.3-1/macros/ASTManagement/AST_ExtractNameAndScope.bin +++ b/2.3-1/macros/ASTManagement/AST_ExtractNameAndScope.bin diff --git a/2.3-1/macros/ASTManagement/AST_ExtractNameAndScope.sci b/2.3-1/macros/ASTManagement/AST_ExtractNameAndScope.sci index 53830cfc..fe5dc05a 100644 --- a/2.3-1/macros/ASTManagement/AST_ExtractNameAndScope.sci +++ b/2.3-1/macros/ASTManagement/AST_ExtractNameAndScope.sci @@ -57,6 +57,7 @@ taglength(cnttag) = length(tagname(cnttag)); fieldlength = length(ASTField); + //NUT: il seguente codice e' poco elegante. if (SCI2Cstrncmps1size(tagname(1),ASTField)) // Here we can have: @@ -65,24 +66,36 @@ if (SCI2Cstrncmps1size(tagname(1),ASTField)) // Number_d: it means double real type. // Number_c: it means float complex type. // Number_z: it means double complex type. - ArgName = stripblanks(part(ASTField,taglength(1)+3:fieldlength)); - ArgScope = stripblanks(part(ASTField,1:taglength(1)+1)); + + // If ArgName is i, make it string + if(mtlb_strcmp(ASTField,"Number_x: i") == %T) + ArgName = stripblanks(part(ASTField,taglength(1)+3:fieldlength)); + ArgScope = 'String'; + else + ArgName = stripblanks(part(ASTField,taglength(1)+3:fieldlength)); + ArgScope = stripblanks(part(ASTField,1:taglength(1)+1)); + end elseif (SCI2Cstrncmps1size(tagname(2),ASTField)) ArgName = stripblanks(part(ASTField,taglength(2)+1:fieldlength)); ArgName = part(ArgName,2:length(ArgName)-1); // I remove also the first and the last " ArgScope = 'String'; + elseif (SCI2Cstrncmps1size(tagname(3),ASTField)) ArgName = stripblanks(part(ASTField,taglength(3)+1:fieldlength)); ArgScope = 'Variable'; + elseif (SCI2Cstrncmps1size(tagname(4),ASTField)) ArgName = stripblanks(part(ASTField,taglength(4)+1:fieldlength)); ArgScope = 'Global'; + elseif (SCI2Cstrncmps1size(tagname(5),ASTField)) ArgName = stripblanks(part(ASTField,taglength(5)+1:fieldlength)); ArgScope = 'Local'; + elseif (SCI2Cstrncmps1size(tagname(6),ASTField)) ArgName = stripblanks(part(ASTField,taglength(6)+1:fieldlength)); ArgScope = 'Temp'; + elseif (SCI2Cstrncmps1size(tagname(7),ASTField)) ArgName = '<empty>'; ArgScope = 'None'; diff --git a/2.3-1/macros/ASTManagement/AST_HandleEndGenFun.sci b/2.3-1/macros/ASTManagement/AST_HandleEndGenFun.sci index 0bc12992..eb1d1f42 100644 --- a/2.3-1/macros/ASTManagement/AST_HandleEndGenFun.sci +++ b/2.3-1/macros/ASTManagement/AST_HandleEndGenFun.sci @@ -1,3 +1,4 @@ + function [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,ASTFunType) // function [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,ASTFunType) // ----------------------------------------------------------------- diff --git a/2.3-1/macros/FunctionAnnotation/FA_SZ_DIFF.bin b/2.3-1/macros/FunctionAnnotation/FA_SZ_DIFF.bin Binary files differnew file mode 100644 index 00000000..5f169e6f --- /dev/null +++ b/2.3-1/macros/FunctionAnnotation/FA_SZ_DIFF.bin diff --git a/2.3-1/macros/FunctionAnnotation/FA_SZ_DIFF.sci b/2.3-1/macros/FunctionAnnotation/FA_SZ_DIFF.sci new file mode 100644 index 00000000..df183100 --- /dev/null +++ b/2.3-1/macros/FunctionAnnotation/FA_SZ_DIFF.sci @@ -0,0 +1,39 @@ +// Copyright (C) 2016 - 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//This fucntion calulates size of output depending upon input +function outsize = FA_SZ_DIFF(in1size, in2val, in3val) + in1size = string(in1size); + in1row = eval(in1size(1)); + in1col = eval(in1size(2)); + in2val = string(in2val); + in2num = eval(in2val); + in3num = eval(in3val); + +if(in3num == 0) + if((in1row == 1) & (in1col <> 1)) //input is row vector + outsize(1) = '1'; + outsize(2) = string (in1col - in2num); + elseif((in1col == 1) & (in1row <> 1)) //input is column vector + outsize(1) = string(in1row - in2num); + outsize(2) = '1'; + else // input is matrix. output is a column matrix + outsize(1) = string((in1row * in1col)- in2num); + outsize(2) = '1'; + end +elseif (in3num == 1) //Difference along rows + outsize(1) = string(in1row - in2num); + outsize(2) = string(in1col); +elseif (in3num == 2) //Difference along columns + outsize(1) = string(in1row); + outsize(2) = string(in1col - in2num); +end +endfunction
\ No newline at end of file diff --git a/2.3-1/macros/FunctionAnnotation/lib b/2.3-1/macros/FunctionAnnotation/lib Binary files differindex 81fa5d45..b8b2d41c 100644 --- a/2.3-1/macros/FunctionAnnotation/lib +++ b/2.3-1/macros/FunctionAnnotation/lib diff --git a/2.3-1/macros/FunctionAnnotation/names b/2.3-1/macros/FunctionAnnotation/names index 5658291f..3db59cc6 100644 --- a/2.3-1/macros/FunctionAnnotation/names +++ b/2.3-1/macros/FunctionAnnotation/names @@ -14,6 +14,7 @@ FA_SZ_1 FA_SZ_2 FA_SZ_COLUMN_DIAG FA_SZ_COL_DIAG_IN_EX +FA_SZ_DIFF FA_SZ_FROM_VAL FA_SZ_LINSPACE_ROW FA_SZ_OPAPEX diff --git a/2.3-1/macros/ToolInitialization/INIT_FillSCI2LibCDirs.bin b/2.3-1/macros/ToolInitialization/INIT_FillSCI2LibCDirs.bin Binary files differindex 8a5a3264..4cc5184f 100644 --- a/2.3-1/macros/ToolInitialization/INIT_FillSCI2LibCDirs.bin +++ b/2.3-1/macros/ToolInitialization/INIT_FillSCI2LibCDirs.bin diff --git a/2.3-1/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci b/2.3-1/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci index 6507e615..c67e9662 100644 --- a/2.3-1/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci +++ b/2.3-1/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci @@ -873,6 +873,11 @@ PrintStringInfo(' Adding Function: '+FunctionName+'.',GeneralReport,'file', INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCAnnFunDir,ClassName,GeneralReport,ExtensionCAnnFun);
INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCFLFunDir,ClassName,GeneralReport,ExtensionCFuncListFun);
+FunctionName = 'acot'; // BJ : Done AS : Float_Done
+PrintStringInfo(' Adding Function: '+FunctionName+'.',GeneralReport,'file','y');
+INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCAnnFunDir,ClassName,GeneralReport,ExtensionCAnnFun);
+INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCFLFunDir,ClassName,GeneralReport,ExtensionCFuncListFun);
+
FunctionName = 'sqrt'; // BJ : Done AS : Float_Done
PrintStringInfo(' Adding Function: '+FunctionName+'.',GeneralReport,'file','y');
INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCAnnFunDir,ClassName,GeneralReport,ExtensionCAnnFun);
@@ -5153,6 +5158,114 @@ INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCFLFunDir,ClassName,GeneralReport,Ex //INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCAnnFunDir,ClassName,GeneralReport,ExtensionCAnnFun);
//INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCFLFunDir,ClassName,GeneralReport,ExtensionCFuncListFun);
+//------------------------------------
+//---- Class DIFF -----------------
+//------------------------------------
+ClassName = 'DIFF';
+
+// --- Class Annotation. ---
+PrintStringInfo(' Adding Class: '+ClassName+'.',GeneralReport,'file','y');
+ClassFileName = fullfile(SCI2CLibCAnnClsDir,ClassName+ExtensionCAnnCls);
+
+//Arguements specified: initial value, start time, time vector, ode function
+PrintStringInfo('NIN= 1',ClassFileName,'file','y');
+PrintStringInfo('NOUT= 1',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).TP= IN(1).TP',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(1)= FA_SZ_1(FA_SZ_DIFF(IN(1).SZ,''1'',''0''))',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(2)= FA_SZ_2(FA_SZ_DIFF(IN(1).SZ,''1'',''0''))',ClassFileName,'file','y');
+
+PrintStringInfo('NIN= 2',ClassFileName,'file','y');
+PrintStringInfo('NOUT= 1',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).TP= IN(1).TP',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(1)= FA_SZ_1(FA_SZ_DIFF(IN(1).SZ,IN(2).VAL,''0''))',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(2)= FA_SZ_2(FA_SZ_DIFF(IN(1).SZ,IN(2).VAL,''0''))',ClassFileName,'file','y');
+
+PrintStringInfo('NIN= 3',ClassFileName,'file','y');
+PrintStringInfo('NOUT= 1',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).TP= IN(1).TP',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(1)= FA_SZ_1(FA_SZ_DIFF(IN(1).SZ,IN(2).VAL, IN(3).VAL))',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(2)= FA_SZ_2(FA_SZ_DIFF(IN(1).SZ,IN(2).VAL, IN(3).VAL))',ClassFileName,'file','y');
+
+ClassFileName = fullfile(SCI2CLibCFLClsDir,ClassName+ExtensionCFuncListCls);
+PrintStringInfo('d2'+ArgSeparator+'d2',ClassFileName,'file','y');
+PrintStringInfo('s2'+ArgSeparator+'s2',ClassFileName,'file','y');
+PrintStringInfo('u82'+ArgSeparator+'u82',ClassFileName,'file','y');
+PrintStringInfo('i82'+ArgSeparator+'i82',ClassFileName,'file','y');
+PrintStringInfo('u162'+ArgSeparator+'u162',ClassFileName,'file','y');
+PrintStringInfo('i162'+ArgSeparator+'i162',ClassFileName,'file','y');
+
+PrintStringInfo('d2d0'+ArgSeparator+'d2',ClassFileName,'file','y');
+PrintStringInfo('s2s0'+ArgSeparator+'s2',ClassFileName,'file','y');
+PrintStringInfo('s2d0'+ArgSeparator+'s2',ClassFileName,'file','y');
+PrintStringInfo('u82u80'+ArgSeparator+'u82',ClassFileName,'file','y');
+PrintStringInfo('u82d0'+ArgSeparator+'u82',ClassFileName,'file','y');
+PrintStringInfo('i82u80'+ArgSeparator+'i82',ClassFileName,'file','y');
+PrintStringInfo('i82d0'+ArgSeparator+'i82',ClassFileName,'file','y');
+PrintStringInfo('u162u160'+ArgSeparator+'u162',ClassFileName,'file','y');
+PrintStringInfo('u162d0'+ArgSeparator+'u162',ClassFileName,'file','y');
+PrintStringInfo('i162u160'+ArgSeparator+'i162',ClassFileName,'file','y');
+PrintStringInfo('i162d0'+ArgSeparator+'i162',ClassFileName,'file','y');
+
+PrintStringInfo('d2d0d0'+ArgSeparator+'d2',ClassFileName,'file','y');
+PrintStringInfo('s2d0d0'+ArgSeparator+'s2',ClassFileName,'file','y');
+PrintStringInfo('s2s0d0'+ArgSeparator+'d2',ClassFileName,'file','y');
+PrintStringInfo('u82d0d0'+ArgSeparator+'u82',ClassFileName,'file','y');
+PrintStringInfo('u82u80d0'+ArgSeparator+'u82',ClassFileName,'file','y');
+PrintStringInfo('i82d0d0'+ArgSeparator+'i82',ClassFileName,'file','y');
+PrintStringInfo('i82u80d0'+ArgSeparator+'i82',ClassFileName,'file','y');
+PrintStringInfo('u162d0d0'+ArgSeparator+'u162',ClassFileName,'file','y');
+PrintStringInfo('u162u160d0'+ArgSeparator+'u162',ClassFileName,'file','y');
+PrintStringInfo('i162d0d0'+ArgSeparator+'i162',ClassFileName,'file','y');
+PrintStringInfo('i162u160d0'+ArgSeparator+'i162',ClassFileName,'file','y');
+
+// --- Annotation Function And Function List Function. ---
+FunctionName = 'diff';
+PrintStringInfo(' Adding Function: '+FunctionName+'.',GeneralReport,'file','y');
+INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCAnnFunDir,ClassName,GeneralReport,ExtensionCAnnFun);
+INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCFLFunDir,ClassName,GeneralReport,ExtensionCFuncListFun);
+
+//------------------------------------
+//---- Class NORM --------------------
+//------------------------------------
+ClassName = 'NORM';
+
+// --- Class Annotation. ---
+PrintStringInfo(' Adding Class: '+ClassName+'.',GeneralReport,'file','y');
+ClassFileName = fullfile(SCI2CLibCAnnClsDir,ClassName+ExtensionCAnnCls);
+
+//Arguements specified: initial value, start time, time vector, ode function
+PrintStringInfo('NIN= 1',ClassFileName,'file','y');
+PrintStringInfo('NOUT= 1',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).TP= IN(1).TP',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(1)= ''1''',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(2)= ''1''',ClassFileName,'file','y');
+
+PrintStringInfo('NIN= 2',ClassFileName,'file','y');
+PrintStringInfo('NOUT= 1',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).TP= IN(1).TP',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(1)= ''1''',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(2)= ''1''',ClassFileName,'file','y');
+
+
+ClassFileName = fullfile(SCI2CLibCFLClsDir,ClassName+ExtensionCFuncListCls);
+PrintStringInfo('d0'+ArgSeparator+'d0',ClassFileName,'file','y');
+PrintStringInfo('d2'+ArgSeparator+'d0',ClassFileName,'file','y');
+PrintStringInfo('s0'+ArgSeparator+'s0',ClassFileName,'file','y');
+PrintStringInfo('s2'+ArgSeparator+'s0',ClassFileName,'file','y');
+
+PrintStringInfo('d2d0'+ArgSeparator+'d0',ClassFileName,'file','y');
+PrintStringInfo('s2s0'+ArgSeparator+'s0',ClassFileName,'file','y');
+PrintStringInfo('s2d0'+ArgSeparator+'s0',ClassFileName,'file','y');
+
+PrintStringInfo('d2g2'+ArgSeparator+'d0',ClassFileName,'file','y');
+PrintStringInfo('s2g2'+ArgSeparator+'s0',ClassFileName,'file','y');
+
+// --- Annotation Function And Function List Function. ---
+FunctionName = 'norm';
+PrintStringInfo(' Adding Function: '+FunctionName+'.',GeneralReport,'file','y');
+INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCAnnFunDir,ClassName,GeneralReport,ExtensionCAnnFun);
+INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCFLFunDir,ClassName,GeneralReport,ExtensionCFuncListFun);
+
// ////////////////////////////////////////////
// /////PARTE INTRODOTTA DA ALBERTO MOREA
// /////////////////////////////////////////////
diff --git a/2.3-1/macros/findDeps/getAllHeaders.bin b/2.3-1/macros/findDeps/getAllHeaders.bin Binary files differindex 34ef825a..2d5581b9 100644 --- a/2.3-1/macros/findDeps/getAllHeaders.bin +++ b/2.3-1/macros/findDeps/getAllHeaders.bin diff --git a/2.3-1/macros/findDeps/getAllHeaders.sci b/2.3-1/macros/findDeps/getAllHeaders.sci index b5ab4910..3fa1d4ee 100644 --- a/2.3-1/macros/findDeps/getAllHeaders.sci +++ b/2.3-1/macros/findDeps/getAllHeaders.sci @@ -70,6 +70,7 @@ function allHeaders = getAllHeaders(Target) "src/c/matrixOperations/includes/tril.h" "src/c/matrixOperations/includes/kron.h" "src/c/matrixOperations/includes/flipdim.h" + "src/c/matrixOperations/includes/norm.h" "src/c/elementaryFunctions/includes/cos.h" "src/c/elementaryFunctions/includes/fix.h" "src/c/elementaryFunctions/includes/exp.h" @@ -143,6 +144,7 @@ function allHeaders = getAllHeaders(Target) "src/c/implicitList/dynlib_implicitlist.h" "src/c/implicitList/implicitList.h" "src/c/differential_calculus/includes/ode.h" + "src/c/differential_calculus/includes/diffc.h" "src/c/Files/includes/files.h"]; //Header files required for "Arduino" output diff --git a/2.3-1/macros/findDeps/getAllInterfaces.bin b/2.3-1/macros/findDeps/getAllInterfaces.bin Binary files differindex d641e330..66ca5ee0 100644 --- a/2.3-1/macros/findDeps/getAllInterfaces.bin +++ b/2.3-1/macros/findDeps/getAllInterfaces.bin diff --git a/2.3-1/macros/findDeps/getAllInterfaces.sci b/2.3-1/macros/findDeps/getAllInterfaces.sci index d1da472f..37d43017 100644 --- a/2.3-1/macros/findDeps/getAllInterfaces.sci +++ b/2.3-1/macros/findDeps/getAllInterfaces.sci @@ -59,6 +59,7 @@ function allInterfaces = getAllInterfaces(Target) "src/c/matrixOperations/interfaces/int_kron.h" "src/c/matrixOperations/interfaces/int_flipdim.h" "src/c/matrixOperations/interfaces/int_permute.h" + "src/c/matrixOperations/interfaces/int_norm.h" "src/c/elementaryFunctions/interfaces/int_asinh.h" "src/c/elementaryFunctions/interfaces/int_atanh.h" "src/c/elementaryFunctions/interfaces/int_sinh.h" @@ -138,6 +139,7 @@ function allInterfaces = getAllInterfaces(Target) "src/c/signalProcessing/interfaces/int_lev.h" "src/c/implicitList/int_OpColon.h" "src/c/differential_calculus/interfaces/int_ode.h" + "src/c/differential_calculus/interfaces/int_diffc.h" "src/c/Files/interfaces/int_files.h"]; //Interface files required for "Arduino" output diff --git a/2.3-1/macros/findDeps/getAllSources.bin b/2.3-1/macros/findDeps/getAllSources.bin Binary files differindex 9dfae6f9..89de1afb 100644 --- a/2.3-1/macros/findDeps/getAllSources.bin +++ b/2.3-1/macros/findDeps/getAllSources.bin diff --git a/2.3-1/macros/findDeps/getAllSources.sci b/2.3-1/macros/findDeps/getAllSources.sci index 726d5ec7..4ef2f165 100644 --- a/2.3-1/macros/findDeps/getAllSources.sci +++ b/2.3-1/macros/findDeps/getAllSources.sci @@ -330,6 +330,8 @@ function allSources = getAllSources(Target) "src/c/matrixOperations/tril/i16trila.c" "src/c/matrixOperations/kron/dkrona.c" "src/c/matrixOperations/kron/skrona.c" + "src/c/matrixOperations/norm/dnormv.c" + "src/c/matrixOperations/norm/dnorma.c" "src/c/elementaryFunctions/cos/dcosa.c" "src/c/elementaryFunctions/cos/dcoss.c" "src/c/elementaryFunctions/cos/scosa.c" @@ -956,6 +958,9 @@ function allSources = getAllSources(Target) "src/c/implicitList/simplicitLists.c" "src/c/differential_calculus/ode/dodes.c" "src/c/differential_calculus/ode/dodea.c" + "src/c/differential_calculus/diff/ddiffca.c" + "src/c/differential_calculus/diff/sdiffca.c" + "src/c/differential_calculus/diff/u8diffca.c" "src/c/Files/mopen/mopen.c" "src/c/Files/mclose/mclose.c" "src/c/Files/mput/dmputs.c" diff --git a/2.3-1/src/c/differential_calculus/diff/ddiffca.c b/2.3-1/src/c/differential_calculus/diff/ddiffca.c new file mode 100644 index 00000000..92727da0 --- /dev/null +++ b/2.3-1/src/c/differential_calculus/diff/ddiffca.c @@ -0,0 +1,203 @@ +/* Copyright (C) 2016 - 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: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + /* This function calculates difference between adjacent members of given + input array/matrix */ + +#include "diffc.h" + + +void ddiffca(double *in, int row, int col, int depth, int dim, double *out) +{ + int counter, depth_count; + int row_count, col_count; + double *buffer; /*To store intermediate results*/ + + depth_count = 1; + + if(dim == 0) + { /*For dim = 0, we calculate difference between adjacent elements + in case of arrays. In case of matrices, we calculate difference along + first column, and then continue to second (diff between first element + of second column and last element of first column, then third etc.*/ + if(depth == 1) + {/*for depth=1, a buffer is not needed. Directly write result in + out buffer*/ + for(counter = 0; counter < row*col - depth_count; counter++) + { + out[counter] = in[counter+1] - in[counter]; + } + } + else + { /*define buffer for storing intermediate results*/ + + buffer = (double *) malloc (sizeof(double)*(row*col-1)); + + while(depth_count <= depth) + { + if(depth_count == 1) + { + /*calculate diff and store in buffer*/ + for(counter = 0; counter < row*col - depth_count; counter++) + { + buffer[counter] = in[counter+1] - in[counter]; + } + } + else if(depth_count < depth) + { + for(counter = 0; counter <= row*col - depth_count ; counter++) + { + buffer[counter] = buffer[counter+1] - buffer[counter]; + } + } + /*For last step use output buffer to store result*/ + else + { + for(counter = 0; counter < row*col - depth_count; counter++) + { + out[counter] = buffer[counter+1] - buffer[counter]; + } + } + depth_count += 1; + } + } + + } + else if(dim == 1) + { + /*For dim = 1, difference is calculated along rows. Each element of + first row is subtracted from corresponding element of second row and + result is stored in first row. Same thing is repeated till last row. */ + + if (depth == 1) + { + /*If depth is 1, store result directly in out buffer*/ + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - 1; row_count++) + { + out[col_count*(row-1)+row_count] = in[col_count*row + row_count+1] \ + - in[col_count*row + row_count]; + } + } + } + else + { + /*If depth is not 1, declare a buffer to store intermediate + results. At last step store result into out buffer*/ + buffer = (double *) malloc (sizeof(double)*((row-1)*col)); + + while(depth_count <= depth) + { + if(depth_count == 1) + { + /*For first step, use in buffer and store results in buffer*/ + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - 1; row_count++) + { + buffer[col_count*row+row_count] = in[col_count*row + row_count + 1] \ + - in[col_count*row + row_count]; + } + + } + } + else if(depth_count < depth) + { + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - depth_count; row_count++) + { + buffer[col_count*row+row_count] = buffer[col_count*row + row_count + 1] \ + - buffer[col_count*row + row_count]; + } + + } + } + else + { + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - depth_count; row_count++) + { + out[col_count*(row-depth_count)+row_count] = buffer[col_count*row + row_count+1] \ + - buffer[col_count*row + row_count]; + } + } + } + depth_count +=1; + } + } + } + else if(dim == 2) + { + /*For dim = 2, difference is calculated along columns. Each element of + first column is subtracted from corresponding element of second column + and result is stored in first column. Same thing is repeated till last + column. */ + if(depth == 1) + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - 1; col_count++) + { + out[col_count*row+row_count] = in[(col_count+1)*row + row_count] \ + - in[col_count*row + row_count]; + } + } + } + else + { + /*If depth is not 1, declare a buffer to store intermediate + results. At last step store result into out buffer*/ + buffer = (double *) malloc (sizeof(double)*(row*(col-1))); + + while(depth_count <= depth) + { + if(depth_count == 1) + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - 1; col_count++) + { + buffer[col_count*row+row_count] = in[(col_count+1)*row + row_count] \ + - in[col_count*row + row_count]; + } + } + } + else if(depth_count < depth) + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - depth_count; col_count++) + { + buffer[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \ + - buffer[col_count*row + row_count]; + } + } + } + else + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - depth_count; col_count++) + { + out[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \ + - buffer[col_count*row + row_count]; + } + } + } + depth_count += 1; + } + } + } +} diff --git a/2.3-1/src/c/differential_calculus/diff/i16diffca.c b/2.3-1/src/c/differential_calculus/diff/i16diffca.c new file mode 100644 index 00000000..d1c70a53 --- /dev/null +++ b/2.3-1/src/c/differential_calculus/diff/i16diffca.c @@ -0,0 +1,203 @@ +/* Copyright (C) 2016 - 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: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + /* This function calculates difference between adjacent members of given + input array/matrix */ + +#include "diffc.h" + + +void i16diffca(int16 *in, int row, int col, int depth, int dim, int16 *out) +{ + int counter, depth_count; + int row_count, col_count; + int16 *buffer; /*To store intermediate results*/ + + depth_count = 1; + + if(dim == 0) + { /*For dim = 0, we calculate difference between adjacent elements + in case of arrays. In case of matrices, we calculate difference along + first column, and then continue to second (diff between first element + of second column and last element of first column, then third etc.*/ + if(depth == 1) + {/*for depth=1, a buffer is not needed. Directly write result in + out buffer*/ + for(counter = 0; counter < row*col - depth_count; counter++) + { + out[counter] = in[counter+1] - in[counter]; + } + } + else + { /*define buffer for storing intermediate results*/ + + buffer = (int16 *) malloc (sizeof(int16)*(row*col-1)); + + while(depth_count <= depth) + { + if(depth_count == 1) + { + /*calculate diff and store in buffer*/ + for(counter = 0; counter < row*col - depth_count; counter++) + { + buffer[counter] = in[counter+1] - in[counter]; + } + } + else if(depth_count < depth) + { + for(counter = 0; counter <= row*col - depth_count ; counter++) + { + buffer[counter] = buffer[counter+1] - buffer[counter]; + } + } + /*For last step use output buffer to store result*/ + else + { + for(counter = 0; counter < row*col - depth_count; counter++) + { + out[counter] = buffer[counter+1] - buffer[counter]; + } + } + depth_count += 1; + } + } + + } + else if(dim == 1) + { + /*For dim = 1, difference is calculated along rows. Each element of + first row is subtracted from corresponding element of second row and + result is stored in first row. Same thing is repeated till last row. */ + + if (depth == 1) + { + /*If depth is 1, store result directly in out buffer*/ + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - 1; row_count++) + { + out[col_count*(row-1)+row_count] = in[col_count*row + row_count+1] \ + - in[col_count*row + row_count]; + } + } + } + else + { + /*If depth is not 1, declare a buffer to store intermediate + results. At last step store result into out buffer*/ + buffer = (int16 *) malloc (sizeof(int16)*((row-1)*col)); + + while(depth_count <= depth) + { + if(depth_count == 1) + { + /*For first step, use in buffer and store results in buffer*/ + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - 1; row_count++) + { + buffer[col_count*row+row_count] = in[col_count*row + row_count + 1] \ + - in[col_count*row + row_count]; + } + + } + } + else if(depth_count < depth) + { + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - depth_count; row_count++) + { + buffer[col_count*row+row_count] = buffer[col_count*row + row_count + 1] \ + - buffer[col_count*row + row_count]; + } + + } + } + else + { + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - depth_count; row_count++) + { + out[col_count*(row-depth_count)+row_count] = buffer[col_count*row + row_count+1] \ + - buffer[col_count*row + row_count]; + } + } + } + depth_count +=1; + } + } + } + else if(dim == 2) + { + /*For dim = 2, difference is calculated along columns. Each element of + first column is subtracted from corresponding element of second column + and result is stored in first column. Same thing is repeated till last + column. */ + if(depth == 1) + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - 1; col_count++) + { + out[col_count*row+row_count] = in[(col_count+1)*row + row_count] \ + - in[col_count*row + row_count]; + } + } + } + else + { + /*If depth is not 1, declare a buffer to store intermediate + results. At last step store result into out buffer*/ + buffer = (int16 *) malloc (sizeof(int16)*(row*(col-1))); + + while(depth_count <= depth) + { + if(depth_count == 1) + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - 1; col_count++) + { + buffer[col_count*row+row_count] = in[(col_count+1)*row + row_count] \ + - in[col_count*row + row_count]; + } + } + } + else if(depth_count < depth) + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - depth_count; col_count++) + { + buffer[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \ + - buffer[col_count*row + row_count]; + } + } + } + else + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - depth_count; col_count++) + { + out[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \ + - buffer[col_count*row + row_count]; + } + } + } + depth_count += 1; + } + } + } +} diff --git a/2.3-1/src/c/differential_calculus/diff/i8diffca.c b/2.3-1/src/c/differential_calculus/diff/i8diffca.c new file mode 100644 index 00000000..7b76f961 --- /dev/null +++ b/2.3-1/src/c/differential_calculus/diff/i8diffca.c @@ -0,0 +1,203 @@ +/* Copyright (C) 2016 - 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: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + /* This function calculates difference between adjacent members of given + input array/matrix */ + +#include "diffc.h" + + +void i8diffca(int8 *in, int row, int col, int depth, int dim, int8 *out) +{ + int counter, depth_count; + int row_count, col_count; + int8 *buffer; /*To store intermediate results*/ + + depth_count = 1; + + if(dim == 0) + { /*For dim = 0, we calculate difference between adjacent elements + in case of arrays. In case of matrices, we calculate difference along + first column, and then continue to second (diff between first element + of second column and last element of first column, then third etc.*/ + if(depth == 1) + {/*for depth=1, a buffer is not needed. Directly write result in + out buffer*/ + for(counter = 0; counter < row*col - depth_count; counter++) + { + out[counter] = in[counter+1] - in[counter]; + } + } + else + { /*define buffer for storing intermediate results*/ + + buffer = (int8 *) malloc (sizeof(int8)*(row*col-1)); + + while(depth_count <= depth) + { + if(depth_count == 1) + { + /*calculate diff and store in buffer*/ + for(counter = 0; counter < row*col - depth_count; counter++) + { + buffer[counter] = in[counter+1] - in[counter]; + } + } + else if(depth_count < depth) + { + for(counter = 0; counter <= row*col - depth_count ; counter++) + { + buffer[counter] = buffer[counter+1] - buffer[counter]; + } + } + /*For last step use output buffer to store result*/ + else + { + for(counter = 0; counter < row*col - depth_count; counter++) + { + out[counter] = buffer[counter+1] - buffer[counter]; + } + } + depth_count += 1; + } + } + + } + else if(dim == 1) + { + /*For dim = 1, difference is calculated along rows. Each element of + first row is subtracted from corresponding element of second row and + result is stored in first row. Same thing is repeated till last row. */ + + if (depth == 1) + { + /*If depth is 1, store result directly in out buffer*/ + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - 1; row_count++) + { + out[col_count*(row-1)+row_count] = in[col_count*row + row_count+1] \ + - in[col_count*row + row_count]; + } + } + } + else + { + /*If depth is not 1, declare a buffer to store intermediate + results. At last step store result into out buffer*/ + buffer = (int8 *) malloc (sizeof(int8)*((row-1)*col)); + + while(depth_count <= depth) + { + if(depth_count == 1) + { + /*For first step, use in buffer and store results in buffer*/ + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - 1; row_count++) + { + buffer[col_count*row+row_count] = in[col_count*row + row_count + 1] \ + - in[col_count*row + row_count]; + } + + } + } + else if(depth_count < depth) + { + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - depth_count; row_count++) + { + buffer[col_count*row+row_count] = buffer[col_count*row + row_count + 1] \ + - buffer[col_count*row + row_count]; + } + + } + } + else + { + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - depth_count; row_count++) + { + out[col_count*(row-depth_count)+row_count] = buffer[col_count*row + row_count+1] \ + - buffer[col_count*row + row_count]; + } + } + } + depth_count +=1; + } + } + } + else if(dim == 2) + { + /*For dim = 2, difference is calculated along columns. Each element of + first column is subtracted from corresponding element of second column + and result is stored in first column. Same thing is repeated till last + column. */ + if(depth == 1) + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - 1; col_count++) + { + out[col_count*row+row_count] = in[(col_count+1)*row + row_count] \ + - in[col_count*row + row_count]; + } + } + } + else + { + /*If depth is not 1, declare a buffer to store intermediate + results. At last step store result into out buffer*/ + buffer = (int8 *) malloc (sizeof(int8)*(row*(col-1))); + + while(depth_count <= depth) + { + if(depth_count == 1) + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - 1; col_count++) + { + buffer[col_count*row+row_count] = in[(col_count+1)*row + row_count] \ + - in[col_count*row + row_count]; + } + } + } + else if(depth_count < depth) + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - depth_count; col_count++) + { + buffer[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \ + - buffer[col_count*row + row_count]; + } + } + } + else + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - depth_count; col_count++) + { + out[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \ + - buffer[col_count*row + row_count]; + } + } + } + depth_count += 1; + } + } + } +} diff --git a/2.3-1/src/c/differential_calculus/diff/sdiffca.c b/2.3-1/src/c/differential_calculus/diff/sdiffca.c new file mode 100644 index 00000000..67526ad5 --- /dev/null +++ b/2.3-1/src/c/differential_calculus/diff/sdiffca.c @@ -0,0 +1,203 @@ +/* Copyright (C) 2016 - 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: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + /* This function calculates difference between adjacent members of given + input array/matrix */ + +#include "diffc.h" + + +void sdiffca(float *in, int row, int col, int depth, int dim, float *out) +{ + int counter, depth_count; + int row_count, col_count; + float *buffer; /*To store intermediate results*/ + + depth_count = 1; + + if(dim == 0) + { /*For dim = 0, we calculate difference between adjacent elements + in case of arrays. In case of matrices, we calculate difference along + first column, and then continue to second (diff between first element + of second column and last element of first column, then third etc.*/ + if(depth == 1) + {/*for depth=1, a buffer is not needed. Directly write result in + out buffer*/ + for(counter = 0; counter < row*col - depth_count; counter++) + { + out[counter] = in[counter+1] - in[counter]; + } + } + else + { /*define buffer for storing intermediate results*/ + + buffer = (float *) malloc (sizeof(float)*(row*col-1)); + + while(depth_count <= depth) + { + if(depth_count == 1) + { + /*calculate diff and store in buffer*/ + for(counter = 0; counter < row*col - depth_count; counter++) + { + buffer[counter] = in[counter+1] - in[counter]; + } + } + else if(depth_count < depth) + { + for(counter = 0; counter <= row*col - depth_count ; counter++) + { + buffer[counter] = buffer[counter+1] - buffer[counter]; + } + } + /*For last step use output buffer to store result*/ + else + { + for(counter = 0; counter < row*col - depth_count; counter++) + { + out[counter] = buffer[counter+1] - buffer[counter]; + } + } + depth_count += 1; + } + } + + } + else if(dim == 1) + { + /*For dim = 1, difference is calculated along rows. Each element of + first row is subtracted from corresponding element of second row and + result is stored in first row. Same thing is repeated till last row. */ + + if (depth == 1) + { + /*If depth is 1, store result directly in out buffer*/ + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - 1; row_count++) + { + out[col_count*(row-1)+row_count] = in[col_count*row + row_count+1] \ + - in[col_count*row + row_count]; + } + } + } + else + { + /*If depth is not 1, declare a buffer to store intermediate + results. At last step store result into out buffer*/ + buffer = (float *) malloc (sizeof(float)*((row-1)*col)); + + while(depth_count <= depth) + { + if(depth_count == 1) + { + /*For first step, use in buffer and store results in buffer*/ + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - 1; row_count++) + { + buffer[col_count*row+row_count] = in[col_count*row + row_count + 1] \ + - in[col_count*row + row_count]; + } + + } + } + else if(depth_count < depth) + { + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - depth_count; row_count++) + { + buffer[col_count*row+row_count] = buffer[col_count*row + row_count + 1] \ + - buffer[col_count*row + row_count]; + } + + } + } + else + { + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - depth_count; row_count++) + { + out[col_count*(row-depth_count)+row_count] = buffer[col_count*row + row_count+1] \ + - buffer[col_count*row + row_count]; + } + } + } + depth_count +=1; + } + } + } + else if(dim == 2) + { + /*For dim = 2, difference is calculated along columns. Each element of + first column is subtracted from corresponding element of second column + and result is stored in first column. Same thing is repeated till last + column. */ + if(depth == 1) + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - 1; col_count++) + { + out[col_count*row+row_count] = in[(col_count+1)*row + row_count] \ + - in[col_count*row + row_count]; + } + } + } + else + { + /*If depth is not 1, declare a buffer to store intermediate + results. At last step store result into out buffer*/ + buffer = (float *) malloc (sizeof(float)*(row*(col-1))); + + while(depth_count <= depth) + { + if(depth_count == 1) + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - 1; col_count++) + { + buffer[col_count*row+row_count] = in[(col_count+1)*row + row_count] \ + - in[col_count*row + row_count]; + } + } + } + else if(depth_count < depth) + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - depth_count; col_count++) + { + buffer[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \ + - buffer[col_count*row + row_count]; + } + } + } + else + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - depth_count; col_count++) + { + out[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \ + - buffer[col_count*row + row_count]; + } + } + } + depth_count += 1; + } + } + } +} diff --git a/2.3-1/src/c/differential_calculus/diff/u16dissca.c b/2.3-1/src/c/differential_calculus/diff/u16dissca.c new file mode 100644 index 00000000..d83a9e6e --- /dev/null +++ b/2.3-1/src/c/differential_calculus/diff/u16dissca.c @@ -0,0 +1,203 @@ +/* Copyright (C) 2016 - 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: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + /* This function calculates difference between adjacent members of given + input array/matrix */ + +#include "diffc.h" + + +void u16diffca(uint16 *in, int row, int col, int depth, int dim, uint16 *out) +{ + int counter, depth_count; + int row_count, col_count; + uint16 *buffer; /*To store intermediate results*/ + + depth_count = 1; + + if(dim == 0) + { /*For dim = 0, we calculate difference between adjacent elements + in case of arrays. In case of matrices, we calculate difference along + first column, and then continue to second (diff between first element + of second column and last element of first column, then third etc.*/ + if(depth == 1) + {/*for depth=1, a buffer is not needed. Directly write result in + out buffer*/ + for(counter = 0; counter < row*col - depth_count; counter++) + { + out[counter] = in[counter+1] - in[counter]; + } + } + else + { /*define buffer for storing intermediate results*/ + + buffer = (uint16 *) malloc (sizeof(uint16)*(row*col-1)); + + while(depth_count <= depth) + { + if(depth_count == 1) + { + /*calculate diff and store in buffer*/ + for(counter = 0; counter < row*col - depth_count; counter++) + { + buffer[counter] = in[counter+1] - in[counter]; + } + } + else if(depth_count < depth) + { + for(counter = 0; counter <= row*col - depth_count ; counter++) + { + buffer[counter] = buffer[counter+1] - buffer[counter]; + } + } + /*For last step use output buffer to store result*/ + else + { + for(counter = 0; counter < row*col - depth_count; counter++) + { + out[counter] = buffer[counter+1] - buffer[counter]; + } + } + depth_count += 1; + } + } + + } + else if(dim == 1) + { + /*For dim = 1, difference is calculated along rows. Each element of + first row is subtracted from corresponding element of second row and + result is stored in first row. Same thing is repeated till last row. */ + + if (depth == 1) + { + /*If depth is 1, store result directly in out buffer*/ + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - 1; row_count++) + { + out[col_count*(row-1)+row_count] = in[col_count*row + row_count+1] \ + - in[col_count*row + row_count]; + } + } + } + else + { + /*If depth is not 1, declare a buffer to store intermediate + results. At last step store result into out buffer*/ + buffer = (uint16 *) malloc (sizeof(uint16)*((row-1)*col)); + + while(depth_count <= depth) + { + if(depth_count == 1) + { + /*For first step, use in buffer and store results in buffer*/ + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - 1; row_count++) + { + buffer[col_count*row+row_count] = in[col_count*row + row_count + 1] \ + - in[col_count*row + row_count]; + } + + } + } + else if(depth_count < depth) + { + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - depth_count; row_count++) + { + buffer[col_count*row+row_count] = buffer[col_count*row + row_count + 1] \ + - buffer[col_count*row + row_count]; + } + + } + } + else + { + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - depth_count; row_count++) + { + out[col_count*(row-depth_count)+row_count] = buffer[col_count*row + row_count+1] \ + - buffer[col_count*row + row_count]; + } + } + } + depth_count +=1; + } + } + } + else if(dim == 2) + { + /*For dim = 2, difference is calculated along columns. Each element of + first column is subtracted from corresponding element of second column + and result is stored in first column. Same thing is repeated till last + column. */ + if(depth == 1) + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - 1; col_count++) + { + out[col_count*row+row_count] = in[(col_count+1)*row + row_count] \ + - in[col_count*row + row_count]; + } + } + } + else + { + /*If depth is not 1, declare a buffer to store intermediate + results. At last step store result into out buffer*/ + buffer = (uint16 *) malloc (sizeof(uint16)*(row*(col-1))); + + while(depth_count <= depth) + { + if(depth_count == 1) + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - 1; col_count++) + { + buffer[col_count*row+row_count] = in[(col_count+1)*row + row_count] \ + - in[col_count*row + row_count]; + } + } + } + else if(depth_count < depth) + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - depth_count; col_count++) + { + buffer[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \ + - buffer[col_count*row + row_count]; + } + } + } + else + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - depth_count; col_count++) + { + out[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \ + - buffer[col_count*row + row_count]; + } + } + } + depth_count += 1; + } + } + } +} diff --git a/2.3-1/src/c/differential_calculus/diff/u8diffca.c b/2.3-1/src/c/differential_calculus/diff/u8diffca.c new file mode 100644 index 00000000..567ff8e6 --- /dev/null +++ b/2.3-1/src/c/differential_calculus/diff/u8diffca.c @@ -0,0 +1,203 @@ +/* Copyright (C) 2016 - 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: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + /* This function calculates difference between adjacent members of given + input array/matrix */ + +#include "diffc.h" + + +void u8diffca(uint8 *in, int row, int col, int depth, int dim, uint8 *out) +{ + int counter, depth_count; + int row_count, col_count; + uint8 *buffer; /*To store intermediate results*/ + + depth_count = 1; + + if(dim == 0) + { /*For dim = 0, we calculate difference between adjacent elements + in case of arrays. In case of matrices, we calculate difference along + first column, and then continue to second (diff between first element + of second column and last element of first column, then third etc.*/ + if(depth == 1) + {/*for depth=1, a buffer is not needed. Directly write result in + out buffer*/ + for(counter = 0; counter < row*col - depth_count; counter++) + { + out[counter] = in[counter+1] - in[counter]; + } + } + else + { /*define buffer for storing intermediate results*/ + + buffer = (uint8 *) malloc (sizeof(uint8)*(row*col-1)); + + while(depth_count <= depth) + { + if(depth_count == 1) + { + /*calculate diff and store in buffer*/ + for(counter = 0; counter < row*col - depth_count; counter++) + { + buffer[counter] = in[counter+1] - in[counter]; + } + } + else if(depth_count < depth) + { + for(counter = 0; counter <= row*col - depth_count ; counter++) + { + buffer[counter] = buffer[counter+1] - buffer[counter]; + } + } + /*For last step use output buffer to store result*/ + else + { + for(counter = 0; counter < row*col - depth_count; counter++) + { + out[counter] = buffer[counter+1] - buffer[counter]; + } + } + depth_count += 1; + } + } + + } + else if(dim == 1) + { + /*For dim = 1, difference is calculated along rows. Each element of + first row is subtracted from corresponding element of second row and + result is stored in first row. Same thing is repeated till last row. */ + + if (depth == 1) + { + /*If depth is 1, store result directly in out buffer*/ + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - 1; row_count++) + { + out[col_count*(row-1)+row_count] = in[col_count*row + row_count+1] \ + - in[col_count*row + row_count]; + } + } + } + else + { + /*If depth is not 1, declare a buffer to store intermediate + results. At last step store result into out buffer*/ + buffer = (uint8 *) malloc (sizeof(uint8)*((row-1)*col)); + + while(depth_count <= depth) + { + if(depth_count == 1) + { + /*For first step, use in buffer and store results in buffer*/ + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - 1; row_count++) + { + buffer[col_count*row+row_count] = in[col_count*row + row_count + 1] \ + - in[col_count*row + row_count]; + } + + } + } + else if(depth_count < depth) + { + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - depth_count; row_count++) + { + buffer[col_count*row+row_count] = buffer[col_count*row + row_count + 1] \ + - buffer[col_count*row + row_count]; + } + + } + } + else + { + for(col_count = 0; col_count < col; col_count++) + { + for(row_count = 0; row_count < row - depth_count; row_count++) + { + out[col_count*(row-depth_count)+row_count] = buffer[col_count*row + row_count+1] \ + - buffer[col_count*row + row_count]; + } + } + } + depth_count +=1; + } + } + } + else if(dim == 2) + { + /*For dim = 2, difference is calculated along columns. Each element of + first column is subtracted from corresponding element of second column + and result is stored in first column. Same thing is repeated till last + column. */ + if(depth == 1) + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - 1; col_count++) + { + out[col_count*row+row_count] = in[(col_count+1)*row + row_count] \ + - in[col_count*row + row_count]; + } + } + } + else + { + /*If depth is not 1, declare a buffer to store intermediate + results. At last step store result into out buffer*/ + buffer = (uint8 *) malloc (sizeof(uint8)*(row*(col-1))); + + while(depth_count <= depth) + { + if(depth_count == 1) + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - 1; col_count++) + { + buffer[col_count*row+row_count] = in[(col_count+1)*row + row_count] \ + - in[col_count*row + row_count]; + } + } + } + else if(depth_count < depth) + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - depth_count; col_count++) + { + buffer[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \ + - buffer[col_count*row + row_count]; + } + } + } + else + { + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col - depth_count; col_count++) + { + out[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \ + - buffer[col_count*row + row_count]; + } + } + } + depth_count += 1; + } + } + } +} diff --git a/2.3-1/src/c/differential_calculus/includes/diffc.h b/2.3-1/src/c/differential_calculus/includes/diffc.h new file mode 100644 index 00000000..7d266f1e --- /dev/null +++ b/2.3-1/src/c/differential_calculus/includes/diffc.h @@ -0,0 +1,37 @@ + /* Copyright (C) 2016 - 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: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ +#ifndef __DIFFC_H__ +#define __DIFFC_H__ + +#include "types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void ddiffca(double *in, int row, int col, int depth, int dim, double *out); + +void sdiffca(float *in, int row, int col, int depth, int dim, float *out); + +void u8diffca(uint8 *in, int row, int col, int depth, int dim, uint8 *out); + +void i8diffca(int8 *in, int row, int col, int depth, int dim, int8 *out); + +void u16diffca(uint16 *in, int row, int col, int depth, int dim, uint16 *out); + +void i16diffca(int16 *in, int row, int col, int depth, int dim, int16 *out); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__DIFFC_H__*/ diff --git a/2.3-1/src/c/differential_calculus/interfaces/int_diffc.h b/2.3-1/src/c/differential_calculus/interfaces/int_diffc.h new file mode 100644 index 00000000..3c032426 --- /dev/null +++ b/2.3-1/src/c/differential_calculus/interfaces/int_diffc.h @@ -0,0 +1,105 @@ + /* Copyright (C) 2016 - 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: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ +#ifndef __INT_DIFFC_H__ +#define __INT_DIFFC_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define d2diffd2(in, size, out) ddiffca(in, size[0], size[1], 1, 0, out) + +#define d2d0diffd2(in, size, depth, out) ddiffca (in, size[0], size[1], \ + depth, 0, out) + +#define d2d0d0diffd2(in, size, depth, dim, out) ddiffca(in, size[0], size[1], \ + depth, dim, out) + +#define s2diffs2(in, size, out) sdiffca(in, size[0], size[1], 1, 0, out) + +#define s2d0diffs2(in, size, depth, out) sdiffca (in, size[0], size[1], \ + depth, 0, out) + +#define s2s0diffs2(in, size, depth, out) sdiffca (in, size[0], size[1], \ + depth, 0, out) + +#define s2s0d0diffs2(in, size, depth, dim, out) sdiffca(in, size[0], size[1], \ + depth, dim, out) + +#define s2d0d0diffs2(in, size, depth, dim, out) sdiffca(in, size[0], size[1], \ + depth, dim, out) + +#define u82diffu82(in, size, out) u8diffca(in, size[0], size[1], 1, 0, out) + +#define u82d0diffu82(in, size, depth, out) u8diffca (in, size[0], size[1], \ + depth, 0, out) + +#define u82u80diffu82(in, size, depth, out) u8diffca (in, size[0], size[1], \ + depth, 0, out) + +#define u82u80d0diffu82(in, size, depth, dim, out) u8diffca(in, size[0], size[1], \ + depth, dim, out) + + +#define u82d0d0diffu82(in, size, depth, dim, out) u8diffca(in, size[0], size[1], \ + depth, dim, out) + +#define i82diffi82(in, size, out) i8diffca(in, size[0], size[1], 1, 0, out) + +#define i82d0diffi82(in, size, depth, out) i8diffca (in, size[0], size[1], \ + depth, 0, out) + +#define i82u80diffi82(in, size, depth, out) i8diffca (in, size[0], size[1], \ + depth, 0, out) + +#define i82u80d0diffi82(in, size, depth, dim, out) i8diffca(in, size[0], size[1], \ + depth, dim, out) + + +#define i82d0d0diffi82(in, size, depth, dim, out) i8diffca(in, size[0], size[1], \ + depth, dim, out) + +#define u162diffu162(in, size, out) u16diffca(in, size[0], size[1], 1, 0, out) + +#define u162d0diffu162(in, size, depth, out) u16diffca (in, size[0], size[1], \ + depth, 0, out) + +#define u162u160diffu162(in, size, depth, out) u16diffca (in, size[0], size[1], \ + depth, 0, out) + +#define u162u160d0diffu162(in, size, depth, dim, out) u16diffca(in, size[0], size[1], \ + depth, dim, out) + + +#define u162d0d0diffu162(in, size, depth, dim, out) u16diffca(in, size[0], size[1], \ + depth, dim, out) + +#define i162diffi162(in, size, out) i16diffca(in, size[0], size[1], 1, 0, out) + +#define i162d0diffi162(in, size, depth, out) i16diffca (in, size[0], size[1], \ + depth, 0, out) + +#define i162u160diffi162(in, size, depth, out) i16diffca (in, size[0], size[1], \ + depth, 0, out) + +#define i162u160d0diffi162(in, size, depth, dim, out) i16diffca(in, size[0], size[1], \ + depth, dim, out) + + +#define i162d0d0diffi162(in, size, depth, dim, out) i16diffca(in, size[0], size[1], \ + depth, dim, out) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__INT_DIFFC_H__*/ diff --git a/2.3-1/src/c/elementaryFunctions/nthroot/dnthroot.c b/2.3-1/src/c/elementaryFunctions/nthroot/dnthroot.c new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/nthroot/dnthroot.c diff --git a/2.3-1/src/c/matrixOperations/includes/norm.h b/2.3-1/src/c/matrixOperations/includes/norm.h new file mode 100644 index 00000000..6ac4c06a --- /dev/null +++ b/2.3-1/src/c/matrixOperations/includes/norm.h @@ -0,0 +1,32 @@ + /* Copyright (C) 2016 - 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: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ +#ifndef __NORM_H__ +#define __NORM_H__ + + +#ifdef __cplusplus +extern "C" { +#endif + +double dnormv (double *in, int size, int norm); + +double dnorma (double *in, int row, int col, int norm); + +float dnormv (float *in, int size, int norm); + +float dnorma (float *in, int row, int col, int norm); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__NORM_H__*/ diff --git a/2.3-1/src/c/matrixOperations/interfaces/int_norm.h b/2.3-1/src/c/matrixOperations/interfaces/int_norm.h new file mode 100644 index 00000000..a42a6754 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/interfaces/int_norm.h @@ -0,0 +1,53 @@ + /* Copyright (C) 2016 - 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: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ + +#ifndef __INT_NORM_H__ +#define __INT_NORM_H__ + +#include "statMax.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define d0normd0(in) in +#define s0norms0(in) in + +#define d2normd0(in,size,out) ((size[0] == 1) || (size[1]==1))? \ + dnormv(in, size[0]*size[1], 2): \ + dnorma(in, size[0], size[1], 2) + +#define s2norms0(in,size,out) ((size[0] == 1) || (size[1]==1))? \ + snormv(in, size[0]*size[1], 2): \ + snorma(in, size[0], size[1], 2) + +#define d2d0normd0(in,size,norm) ((size[0] == 1) || (size[1]==1))? \ + dnormv(in,size[0]*size[1],norm) : \ + dnorma(in,size[0],size[1],norm) + +#define s2s0norms0(in,size,norm) ((size[0] == 1) || (size[1]==1))? \ + snormv(in,size[0]*size[1],norm) : \ + snorma(in,size[0],size[1],norm) + +#define d2g2normd0(in,size,norm,normsize) ((size[0] == 1) || (size[1]==1))? \ + (norm[0]=='i') ? dmaxa(in,size[0]*size[1]) : dnormv(in,size[0]*size[1],2) : \ + (norm[0]=='i') ? dnorma(in,size[0],size[1],3) : dnorma(in,size[0],size[1],4) + +#define s2g2norms0(in,size,norm,normsize) ((size[0] == 1) || (size[1]==1))? \ + (norm[0]=='i') ? smaxa(in,size[0]*size[1]) : snormv(in,size[0]*size[1],2) : \ + (norm[0]=='i') ? snorma(in,size[0],size[1],3) : snorma(in,size[0],size[1],4) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__INT_NORM_H__*/ diff --git a/2.3-1/src/c/matrixOperations/norm/dnorma.c b/2.3-1/src/c/matrixOperations/norm/dnorma.c new file mode 100644 index 00000000..c912f857 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/norm/dnorma.c @@ -0,0 +1,72 @@ + /* Copyright (C) 2016 - 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: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ + + /*This function calculates norms for matrices*/ + /*Acceptable norms are: 1, 2, 'inf', 'fro', */ + +#include "norm.h" +#include <math.h> + +double dnorma (double *in, int row, int col, int norm) +{ + double res = 0, sum = 0; + int col_count, row_count; + + switch (norm) + { + case 1: /*largest column sum*/ + for(col_count = 0; col_count < col; col_count++) + { + sum = 0; + for(row_count = 0; row_count < row; row_count++) + { + sum += in[col_count*row+row_count]; + } + if (sum >= res) + res = sum; + } + break; + + case 2: /*Largest singular value of the matrix*/ + break; + + case 3: /*inf: largest row sum*/ + + for(row_count = 0; row_count < row; row_count++) + { + sum = 0; + for(col_count = 0; col_count < col; col_count++) + { + sum += in[col_count*row + row_count]; + } + if(sum >= res) + res = sum; + } + break; + + case 4: /*Frobenius norm*/ + + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col; col_count++) + { + sum += in[col_count*row + row_count] * in[col_count*row + row_count]; + } + } + res = sqrt(sum); + + break; + } + + + return res; +}
\ No newline at end of file diff --git a/2.3-1/src/c/matrixOperations/norm/dnormv.c b/2.3-1/src/c/matrixOperations/norm/dnormv.c new file mode 100644 index 00000000..5d20d606 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/norm/dnormv.c @@ -0,0 +1,60 @@ + /* Copyright (C) 2016 - 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: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ + + /*This function calculates norms for vectors (row or column)*/ + +#include "norm.h" +#include <math.h> + +double dnormv (double *in, int size, int norm) +{ + double sum = 0; + double res = 0; + int counter = 0; + + switch (norm) + { + case 0: + res = INFINITY; + break; + case 1: /*Addition of all elements*/ + for (counter=0; counter < size; counter++) + { + sum += in[counter]; + } + res = sum; + break; + case 2: /*Square root of addition of squares of all elements*/ + for (counter=0; counter < size; counter++) + { + sum += in[counter]*in[counter]; + } + res = sqrt(sum); + break; + case 3: /*Cube root of addition of cubes of all elements*/ + for (counter=0; counter < size; counter++) + { + sum += pow(in[counter],3); + } + res = cbrt(sum); + break; + default : /*Nth root of addition of all elements raised to n*/ + for (counter=0; counter < size; counter++) + { + sum += pow(in[counter],norm); + } + res = pow(sum, 1./norm); + break; + } + + return res; +}
\ No newline at end of file diff --git a/2.3-1/src/c/matrixOperations/norm/snorma.c b/2.3-1/src/c/matrixOperations/norm/snorma.c new file mode 100644 index 00000000..4bf2ccda --- /dev/null +++ b/2.3-1/src/c/matrixOperations/norm/snorma.c @@ -0,0 +1,72 @@ + /* Copyright (C) 2016 - 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: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ + + /*This function calculates norms for matrices*/ + /*Acceptable norms are: 1, 2, 'inf', 'fro', */ + +#include "norm.h" +#include <math.h> + +float dnorma (float *in, int row, int col, int norm) +{ + float res = 0, sum = 0; + int col_count, row_count; + + switch (norm) + { + case 1: /*largest column sum*/ + for(col_count = 0; col_count < col; col_count++) + { + sum = 0; + for(row_count = 0; row_count < row; row_count++) + { + sum += in[col_count*row+row_count]; + } + if (sum >= res) + res = sum; + } + break; + + case 2: /*Largest singular value of the matrix*/ + break; + + case 3: /*inf: largest row sum*/ + + for(row_count = 0; row_count < row; row_count++) + { + sum = 0; + for(col_count = 0; col_count < col; col_count++) + { + sum += in[col_count*row + row_count]; + } + if(sum >= res) + res = sum; + } + break; + + case 4: /*Frobenius norm*/ + + for(row_count = 0; row_count < row; row_count++) + { + for(col_count = 0; col_count < col; col_count++) + { + sum += in[col_count*row + row_count] * in[col_count*row + row_count]; + } + } + res = sqrt(sum); + + break; + } + + + return res; +}
\ No newline at end of file diff --git a/2.3-1/src/c/matrixOperations/norm/snormv.c b/2.3-1/src/c/matrixOperations/norm/snormv.c new file mode 100644 index 00000000..03e9ed66 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/norm/snormv.c @@ -0,0 +1,60 @@ + /* Copyright (C) 2016 - 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: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ + + /*This function calculates norms for vectors (row or column)*/ + +#include "norm.h" +#include <math.h> + +float dnormv (float *in, int size, int norm) +{ + float sum = 0; + float res = 0; + int counter = 0; + + switch (norm) + { + case 0: + res = INFINITY; + break; + case 1: /*Addition of all elements*/ + for (counter=0; counter < size; counter++) + { + sum += in[counter]; + } + res = sum; + break; + case 2: /*Square root of addition of squares of all elements*/ + for (counter=0; counter < size; counter++) + { + sum += in[counter]*in[counter]; + } + res = sqrt(sum); + break; + case 3: /*Cube root of addition of cubes of all elements*/ + for (counter=0; counter < size; counter++) + { + sum += pow(in[counter],3); + } + res = cbrt(sum); + break; + default : /*Nth root of addition of all elements raised to n*/ + for (counter=0; counter < size; counter++) + { + sum += pow(in[counter],norm); + } + res = pow(sum, 1./norm); + break; + } + + return res; +}
\ No newline at end of file |