diff options
41 files changed, 494 insertions, 0 deletions
diff --git a/demos/ffilt.dem.sce b/demos/ffilt.dem.sce new file mode 100644 index 0000000..0268041 --- /dev/null +++ b/demos/ffilt.dem.sce @@ -0,0 +1,16 @@ +// 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: Ankit Raj +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in +// + +lines(0); + +global SCI2CHOME + +scilab2c(SCI2CHOME+"/tests/unit_tests/test_ffilt/scilabcode/main.sci",TMPDIR,SCI2CHOME+"/tests/unit_tests/test_ffilt/scilabcode"); diff --git a/demos/filt_sinc.dem.sce b/demos/filt_sinc.dem.sce new file mode 100644 index 0000000..001ceb8 --- /dev/null +++ b/demos/filt_sinc.dem.sce @@ -0,0 +1,18 @@ +// 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: Ankit Raj +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in +// + + + +lines(0); + +global SCI2CHOME + +scilab2c(SCI2CHOME+"/tests/unit_tests/test_filtsinc/scilabcode/filt_sinctest.sci",TMPDIR,SCI2CHOME+"/tests/unit_tests/test_filtsinc/scilabcode"); diff --git a/demos/fsfirlin.dem.sce b/demos/fsfirlin.dem.sce new file mode 100644 index 0000000..278252a --- /dev/null +++ b/demos/fsfirlin.dem.sce @@ -0,0 +1,16 @@ +// 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: Ankit Raj +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in +// + +lines(0); + +global SCI2CHOME + +scilab2c(SCI2CHOME+"/tests/unit_tests/test_fsfirlin/scilabcode/main.sci",TMPDIR,SCI2CHOME+"/tests/unit_tests/test_fsfirlin/scilabcode"); diff --git a/demos/scilab2c.dem.gateway.sce b/demos/scilab2c.dem.gateway.sce index b572166..bc158bf 100644 --- a/demos/scilab2c.dem.gateway.sce +++ b/demos/scilab2c.dem.gateway.sce @@ -39,6 +39,9 @@ subdemolist = ["Trigonometric Identity" , "TrigonometricIdentity.dem.sce"; "Arduino analog output", "analog_out.dem.sce"; "Arduino DC motor", "dc_motor.dem.sce"; "Arduino Master write", "master_write.dem.sce"; + "Ffilt coeff. of FIR low pass filter","ffilt.dem.sce"; + "Design of FIR linear phase filters using freq. samping technique","fsfirlin.dem.sce"; + "Samples of sinc function","filt_sinc.dem.sce"; ]; subdemolist(:,2) = demopath + subdemolist(:,2); diff --git a/includes/sci2clib.h b/includes/sci2clib.h index 0a15a4f..b070a90 100644 --- a/includes/sci2clib.h +++ b/includes/sci2clib.h @@ -475,6 +475,11 @@ extern "C" { #include "int_toeplitz.h" +/*interface Cross */ +#include "cross.h" +#include "int_cross.h" + + /* SIGNAL PROCESSING */ diff --git a/jar/scilab_en_US_help.jar b/jar/scilab_en_US_help.jar Binary files differdeleted file mode 100644 index fa8e6eb..0000000 --- a/jar/scilab_en_US_help.jar +++ /dev/null diff --git a/macros/ASTManagement/lib b/macros/ASTManagement/lib Binary files differindex e9d351a..5978ea7 100644 --- a/macros/ASTManagement/lib +++ b/macros/ASTManagement/lib diff --git a/macros/CCodeGeneration/lib b/macros/CCodeGeneration/lib Binary files differindex f2696fe..3181979 100644 --- a/macros/CCodeGeneration/lib +++ b/macros/CCodeGeneration/lib diff --git a/macros/ErrorMessages/lib b/macros/ErrorMessages/lib Binary files differindex 1500b1f..794d4c0 100644 --- a/macros/ErrorMessages/lib +++ b/macros/ErrorMessages/lib diff --git a/macros/FunctionAnnotation/lib b/macros/FunctionAnnotation/lib Binary files differindex 5eb9bc2..bb1f47c 100644 --- a/macros/FunctionAnnotation/lib +++ b/macros/FunctionAnnotation/lib diff --git a/macros/FunctionList/lib b/macros/FunctionList/lib Binary files differindex e101853..c3274f1 100644 --- a/macros/FunctionList/lib +++ b/macros/FunctionList/lib diff --git a/macros/GeneralFunctions/lib b/macros/GeneralFunctions/lib Binary files differindex 846ca1b..1cf5c1f 100644 --- a/macros/GeneralFunctions/lib +++ b/macros/GeneralFunctions/lib diff --git a/macros/Hardware/AVR/lib b/macros/Hardware/AVR/lib Binary files differindex 53e5659..069c520 100644 --- a/macros/Hardware/AVR/lib +++ b/macros/Hardware/AVR/lib diff --git a/macros/Hardware/RasberryPi/lib b/macros/Hardware/RasberryPi/lib Binary files differindex dc759fe..4c85475 100644 --- a/macros/Hardware/RasberryPi/lib +++ b/macros/Hardware/RasberryPi/lib diff --git a/macros/ImageProcessing/core/lib b/macros/ImageProcessing/core/lib Binary files differindex 7f003c8..d80305c 100644 --- a/macros/ImageProcessing/core/lib +++ b/macros/ImageProcessing/core/lib diff --git a/macros/ImageProcessing/highgui/lib b/macros/ImageProcessing/highgui/lib Binary files differindex 787c25f..1e7f750 100644 --- a/macros/ImageProcessing/highgui/lib +++ b/macros/ImageProcessing/highgui/lib diff --git a/macros/ImageProcessing/imgproc/lib b/macros/ImageProcessing/imgproc/lib Binary files differindex 93c8390..a83978b 100644 --- a/macros/ImageProcessing/imgproc/lib +++ b/macros/ImageProcessing/imgproc/lib diff --git a/macros/Scilab-Arduino/lib b/macros/Scilab-Arduino/lib Binary files differindex 5b7beab..f3d5b2f 100644 --- a/macros/Scilab-Arduino/lib +++ b/macros/Scilab-Arduino/lib diff --git a/macros/SymbolTable/lib b/macros/SymbolTable/lib Binary files differindex c42cf1a..e66158d 100644 --- a/macros/SymbolTable/lib +++ b/macros/SymbolTable/lib diff --git a/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci b/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci index ea84c6a..7dcae8a 100644 --- a/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci +++ b/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci @@ -4803,6 +4803,39 @@ INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCAnnFunDir,ClassName,GeneralReport,E INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCFLFunDir,ClassName,GeneralReport,ExtensionCFuncListFun);
+//------------------------------------
+//---- Class CROSS ----------------
+//------------------------------------
+ClassName = 'cross';
+
+// --- Class Annotation. ---
+PrintStringInfo(' Adding Class: '+ClassName+'.',GeneralReport,'file','y');
+ClassFileName = fullfile(SCI2CLibCAnnClsDir,ClassName+ExtensionCAnnCls);
+
+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)= IN(1).SZ(1)',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(2)= IN(1).SZ(2)',ClassFileName,'file','y');
+
+
+ClassFileName = fullfile(SCI2CLibCFLClsDir,ClassName+ExtensionCFuncListCls);
+PrintStringInfo('d2d2'+ArgSeparator+'d2',ClassFileName,'file','y');
+PrintStringInfo('z2z2'+ArgSeparator+'z2',ClassFileName,'file','y');
+PrintStringInfo('c2c2'+ArgSeparator+'c2',ClassFileName,'file','y');
+PrintStringInfo('s2s2'+ArgSeparator+'s2',ClassFileName,'file','y');
+PrintStringInfo('u82u82'+ArgSeparator+'u82',ClassFileName,'file','y');
+PrintStringInfo('i82i82'+ArgSeparator+'i82',ClassFileName,'file','y');
+PrintStringInfo('u162u162'+ArgSeparator+'u162',ClassFileName,'file','y');
+PrintStringInfo('i162i162'+ArgSeparator+'i162',ClassFileName,'file','y');
+
+// --- Annotation Function And Function List Function. ---
+FunctionName = 'cross';
+PrintStringInfo(' Adding Function: '+FunctionName+'.',GeneralReport,'file','y');
+INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCAnnFunDir,ClassName,GeneralReport,ExtensionCAnnFun);
+INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCFLFunDir,ClassName,GeneralReport,ExtensionCFuncListFun);
+
+
// -------------------
// --- Class Spec. ---
// -------------------
diff --git a/macros/ToolInitialization/lib b/macros/ToolInitialization/lib Binary files differindex 267c9c9..670a52e 100644 --- a/macros/ToolInitialization/lib +++ b/macros/ToolInitialization/lib diff --git a/macros/findDeps/getAllHeaders.sci b/macros/findDeps/getAllHeaders.sci index 38f84f5..67444f9 100644 --- a/macros/findDeps/getAllHeaders.sci +++ b/macros/findDeps/getAllHeaders.sci @@ -73,6 +73,7 @@ function allHeaders = getAllHeaders(SharedInfo) "src/c/matrixOperations/includes/flipdim.h" "src/c/matrixOperations/includes/norm.h" "src/c/matrixOperations/includes/toeplitz.h" + "src/c/matrixOperations/includes/cross.h" "src/c/interpolation/includes/interp1.h" "src/c/elementaryFunctions/includes/nextpow2.h" "src/c/elementaryFunctions/includes/gcd.h" diff --git a/macros/findDeps/getAllInterfaces.sci b/macros/findDeps/getAllInterfaces.sci index c7924a3..da910a0 100644 --- a/macros/findDeps/getAllInterfaces.sci +++ b/macros/findDeps/getAllInterfaces.sci @@ -62,6 +62,7 @@ function allInterfaces = getAllInterfaces(SharedInfo) "src/c/matrixOperations/interfaces/int_permute.h" "src/c/matrixOperations/interfaces/int_norm.h" "src/c/matrixOperations/interfaces/int_toeplitz.h" + "src/c/matrixOperations/interfaces/int_cross.h" "src/c/interpolation/interfaces/int_interp1.h" "src/c/elementaryFunctions/interfaces/int_nextpow2.h" "src/c/elementaryFunctions/interfaces/int_gcd.h" diff --git a/macros/findDeps/getAllSources.sci b/macros/findDeps/getAllSources.sci index 5863e93..3422a95 100644 --- a/macros/findDeps/getAllSources.sci +++ b/macros/findDeps/getAllSources.sci @@ -339,6 +339,14 @@ function allSources = getAllSources(SharedInfo,BuildTool) "src/c/matrixOperations/toeplitz/ctoeplitza.c" "src/c/matrixOperations/toeplitz/i8toeplitza.c" "src/c/matrixOperations/toeplitz/i16toeplitza.c" + "src/c/matrixOperations/cross/dcrossa.c" + "src/c/matrixOperations/cross/zcrossa.c" + "src/c/matrixOperations/cross/ccrossa.c" + "src/c/matrixOperations/cross/scrossa.c" + "src/c/matrixOperations/cross/u8crossa.c" + "src/c/matrixOperations/cross/i8crossa.c" + "src/c/matrixOperations/cross/u16crossa.c" + "src/c/matrixOperations/cross/i16crossa.c" "src/c/elementaryFunctions/nextpow2/dnextpow2a.c" "src/c/elementaryFunctions/isreal/sisreals.c" "src/c/elementaryFunctions/isreal/disreals.c" diff --git a/macros/findDeps/lib b/macros/findDeps/lib Binary files differBinary files differindex 69c3c0e..afcd3ca 100644 --- a/macros/findDeps/lib +++ b/macros/findDeps/lib diff --git a/src/c/matrixOperations/cross/ccrossa.c b/src/c/matrixOperations/cross/ccrossa.c new file mode 100644 index 0000000..5f74bb3 --- /dev/null +++ b/src/c/matrixOperations/cross/ccrossa.c @@ -0,0 +1,37 @@ +#include <stdio.h> +#include <stdlib.h> +#include <cross.h> +#include "floatComplex.h" +#include "stdlib.h" +#include "string.h" +#include "cat.h" + +void ccrossa (floatComplex* inp1, int size1_r, int size1_c, floatComplex* inp2, int size2_r, int size2_c ,floatComplex* oup) +{ + int i,j; + + if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix + { + oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1]; + oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2]; + oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0]; + printf("%lf ", oup[0]); + printf("%lf ", oup[1]); + printf("%lf \n", oup[2]); + } + else // Calculating the cross product for a 3XN Matrix + { + for(i = 0; i < size1_r; i++) + { + for(j = 0; j < size1_c; j = j+3) + { + oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)]; + oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)]; + oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)]; + + } + } + + } +} + diff --git a/src/c/matrixOperations/cross/dcrossa.c b/src/c/matrixOperations/cross/dcrossa.c new file mode 100644 index 0000000..203ec24 --- /dev/null +++ b/src/c/matrixOperations/cross/dcrossa.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include <stdlib.h> +#include <cross.h> + +void dcrossa (double* inp1, int size1_r, int size1_c, double* inp2, int size2_r, int size2_c ,double* oup) +{ + int i,j; + + if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix + { + oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1]; + oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2]; + oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0]; + printf("%lf ", oup[0]); + printf("%lf ", oup[1]); + printf("%lf \n", oup[2]); + } + else // Calculating the cross product for a 3XN Matrix + { + for(i = 0; i < size1_r; i++) + { + for(j = 0; j < size1_c; j = j+3) + { + oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)]; + oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)]; + oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)]; + + } + } + + } +} + diff --git a/src/c/matrixOperations/cross/i16crossa.c b/src/c/matrixOperations/cross/i16crossa.c new file mode 100644 index 0000000..91cdb7f --- /dev/null +++ b/src/c/matrixOperations/cross/i16crossa.c @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <stdlib.h> +#include <cross.h> +#include "int16.h" + +void i16crossa (int16* inp1, int size1_r, int size1_c, int16* inp2, int size2_r, int size2_c ,int16* oup) +{ + int i,j; + + if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix + { + oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1]; + oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2]; + oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0]; + printf("%lf ", oup[0]); + printf("%lf ", oup[1]); + printf("%lf \n", oup[2]); + } + else // Calculating the cross product for a 3XN Matrix + { + for(i = 0; i < size1_r; i++) + { + for(j = 0; j < size1_c; j = j+3) + { + oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)]; + oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)]; + oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)]; + + } + } + + } +} + diff --git a/src/c/matrixOperations/cross/i8crossa.c b/src/c/matrixOperations/cross/i8crossa.c new file mode 100644 index 0000000..adfbd53 --- /dev/null +++ b/src/c/matrixOperations/cross/i8crossa.c @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <stdlib.h> +#include <cross.h> +#include "int8.h" + +void i8crossa (int8* inp1, int size1_r, int size1_c, int8* inp2, int size2_r, int size2_c ,int8* oup) +{ + int i,j; + + if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix + { + oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1]; + oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2]; + oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0]; + printf("%lf ", oup[0]); + printf("%lf ", oup[1]); + printf("%lf \n", oup[2]); + } + else // Calculating the cross product for a 3XN Matrix + { + for(i = 0; i < size1_r; i++) + { + for(j = 0; j < size1_c; j = j+3) + { + oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)]; + oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)]; + oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)]; + + } + } + + } +} + diff --git a/src/c/matrixOperations/cross/scrossa.c b/src/c/matrixOperations/cross/scrossa.c new file mode 100644 index 0000000..414b85a --- /dev/null +++ b/src/c/matrixOperations/cross/scrossa.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include <stdlib.h> +#include <cross.h> + +void scrossa (float* inp1, int size1_r, int size1_c, float* inp2, int size2_r, int size2_c ,float* oup) +{ + int i,j; + + if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix + { + oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1]; + oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2]; + oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0]; + printf("%lf ", oup[0]); + printf("%lf ", oup[1]); + printf("%lf \n", oup[2]); + } + else // Calculating the cross product for a 3XN Matrix + { + for(i = 0; i < size1_r; i++) + { + for(j = 0; j < size1_c; j = j+3) + { + oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)]; + oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)]; + oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)]; + + } + } + + } +} + diff --git a/src/c/matrixOperations/cross/u16crossa.c b/src/c/matrixOperations/cross/u16crossa.c new file mode 100644 index 0000000..e0a32bc --- /dev/null +++ b/src/c/matrixOperations/cross/u16crossa.c @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <stdlib.h> +#include <cross.h> +#include "uint16.h" + +void u16crossa (uint16* inp1, int size1_r, int size1_c, uint16* inp2, int size2_r, int size2_c ,uint16* oup) +{ + int i,j; + + if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix + { + oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1]; + oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2]; + oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0]; + printf("%lf ", oup[0]); + printf("%lf ", oup[1]); + printf("%lf \n", oup[2]); + } + else // Calculating the cross product for a 3XN Matrix + { + for(i = 0; i < size1_r; i++) + { + for(j = 0; j < size1_c; j = j+3) + { + oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)]; + oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)]; + oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)]; + + } + } + + } +} + diff --git a/src/c/matrixOperations/cross/u8crossa.c b/src/c/matrixOperations/cross/u8crossa.c new file mode 100644 index 0000000..7a8b857 --- /dev/null +++ b/src/c/matrixOperations/cross/u8crossa.c @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <stdlib.h> +#include <cross.h> +#include "uint8.h" + +void u8crossa (uint8* inp1, int size1_r, int size1_c, uint8* inp2, int size2_r, int size2_c ,uint8* oup) +{ + int i,j; + + if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix + { + oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1]; + oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2]; + oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0]; + printf("%lf ", oup[0]); + printf("%lf ", oup[1]); + printf("%lf \n", oup[2]); + } + else // Calculating the cross product for a 3XN Matrix + { + for(i = 0; i < size1_r; i++) + { + for(j = 0; j < size1_c; j = j+3) + { + oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)]; + oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)]; + oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)]; + + } + } + + } +} + diff --git a/src/c/matrixOperations/cross/zcrossa.c b/src/c/matrixOperations/cross/zcrossa.c new file mode 100644 index 0000000..85a1960 --- /dev/null +++ b/src/c/matrixOperations/cross/zcrossa.c @@ -0,0 +1,37 @@ +#include <stdio.h> +#include <stdlib.h> +#include <cross.h> +#include "doubleComplex.h" +#include "stdlib.h" +#include "string.h" +#include "cat.h" + +void zcrossa (doubleComplex* inp1, int size1_r, int size1_c, doubleComplex* inp2, int size2_r, int size2_c ,doubleComplex* oup) +{ + int i,j; + + if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix + { + oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1]; + oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2]; + oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0]; + printf("%lf ", oup[0]); + printf("%lf ", oup[1]); + printf("%lf \n", oup[2]); + } + else // Calculating the cross product for a 3XN Matrix + { + for(i = 0; i < size1_r; i++) + { + for(j = 0; j < size1_c; j = j+3) + { + oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)]; + oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)]; + oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)]; + + } + } + + } +} + diff --git a/src/c/matrixOperations/includes/cross.h b/src/c/matrixOperations/includes/cross.h new file mode 100644 index 0000000..0abd001 --- /dev/null +++ b/src/c/matrixOperations/includes/cross.h @@ -0,0 +1,37 @@ + /* 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: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ + +#ifndef __CROSS_H__ +#define __CROSS_H__ +#include "types.h" +#include "doubleComplex.h" +#include "floatComplex.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void dcrossa (double* inp1, int size1_r, int size1_c, double* inp2, int size2_r, int size2_c ,double* oup); +void zcrossa (doubleComplex* inp1, int size1_r, int size1_c, doubleComplex* inp2, int size2_r, int size2_c ,doubleComplex* oup); +void ccrossa (floatComplex* inp1, int size1_r, int size1_c, floatComplex* inp2, int size2_r, int size2_c ,floatComplex* oup); +void scrossa (float* inp1, int size1_r, int size1_c, float* inp2, int size2_r, int size2_c ,float* oup); +void u8crossa (uint8* inp1, int size1_r, int size1_c, uint8* inp2, int size2_r, int size2_c ,uint8* oup); +void u16crossa (uint16* inp1, int size1_r, int size1_c, uint16* inp2, int size2_r, int size2_c ,uint16* oup); +void i8crossa (int8* inp1, int size1_r, int size1_c, int8* inp2, int size2_r, int size2_c ,int8* oup); +void i16crossa (int16* inp1, int size1_r, int size1_c, int16* inp2, int size2_r, int size2_c ,int16* oup); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__CROSS_H__*/ diff --git a/src/c/matrixOperations/interfaces/int_cross.h b/src/c/matrixOperations/interfaces/int_cross.h new file mode 100644 index 0000000..8f4e782 --- /dev/null +++ b/src/c/matrixOperations/interfaces/int_cross.h @@ -0,0 +1,35 @@ + /* 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: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ +#ifndef __INT_CROSS_H__ +#define __INT_CROSS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define d2d2crossd2(in1,size1,in2,size2,out) dcrossa(in1,size1[0],size1[1],in2,size2[0],size2[1],out) +#define z2z2crossz2(in1,size1,in2,size2,out) zcrossa(in1,size1[0],size1[1],in2,size2[0],size2[1],out) +#define c2c2crossc2(in1,size1,in2,size2,out) ccrossa(in1,size1[0],size1[1],in2,size2[0],size2[1],out) +#define s2s2crosss2(in1,size1,in2,size2,out) scrossa(in1,size1[0],size1[1],in2,size2[0],size2[1],out) +#define u82u82crossu82(in1,size1,in2,size2,out) u8crossa(in1,size1[0],size1[1],in2,size2[0],size2[1],out) +#define i82i82crossi82(in1,size1,in2,size2,out) i8crossa(in1,size1[0],size1[1],in2,size2[0],size2[1],out) +#define u162u162crossu162(in1,size1,in2,size2,out) u16crossa(in1,size1[0],size1[1],in2,size2[0],size2[1],out) +#define i162i162crossi162(in1,size1,in2,size2,out) i16crossa(in1,size1[0],size1[1],in2,size2[0],size2[1],out) + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__INT_CROSS_H__*/ diff --git a/tests/unit_tests/test_ffilt/scilabcode/ffilttest.sci b/tests/unit_tests/test_ffilt/scilabcode/ffilttest.sci new file mode 100644 index 0000000..fcf1732 --- /dev/null +++ b/tests/unit_tests/test_ffilt/scilabcode/ffilttest.sci @@ -0,0 +1,8 @@ +function ffilttest() + ft="sb"; + ni=5; + fc=0.2; + fh=0.9; + xi=ffilt(ft,ni,fc,fh); + disp(xi); +endfunction diff --git a/tests/unit_tests/test_ffilt/scilabcode/main.sci b/tests/unit_tests/test_ffilt/scilabcode/main.sci new file mode 100644 index 0000000..ced653a --- /dev/null +++ b/tests/unit_tests/test_ffilt/scilabcode/main.sci @@ -0,0 +1,12 @@ +// The main function test the ffilt function +// ffilt->returns the coefficients of FIR low pass filter +function main() + ft="sb"; //ft is the type of filter + ni=5; //ni is the number of filters sample required + fc=0.2; //low frequency cutoff + fh=0.9; //high cutoff frequency + xi=ffilt(ft,ni,fc,fh); + disp(xi); +endfunction +//output +// 0.2449143 0.4898285 - 0.4 0.4898285 0.2449143 diff --git a/tests/unit_tests/test_filtsinc/scilabcode/filt_sinctest.sci b/tests/unit_tests/test_filtsinc/scilabcode/filt_sinctest.sci new file mode 100644 index 0000000..ab674b6 --- /dev/null +++ b/tests/unit_tests/test_filtsinc/scilabcode/filt_sinctest.sci @@ -0,0 +1,10 @@ +//This is the demo for filt_sinc function +//This function gives the samples of the sinc fuction +function filt_sinctest() + ni=int(10); //This is the number of samples + fc=2; //This is the cut-off freq. of the assosciated low pass filter + sd=filt_sinc(ni,fc); + disp(sd); +endfunction +//output +// diff --git a/tests/unit_tests/test_fsfirlin/scilabcode/fsfirlintest.sci b/tests/unit_tests/test_fsfirlin/scilabcode/fsfirlintest.sci new file mode 100644 index 0000000..4ecec4e --- /dev/null +++ b/tests/unit_tests/test_fsfirlin/scilabcode/fsfirlintest.sci @@ -0,0 +1,6 @@ +function fsfirlintest() + in=[1 2 3 4 5 6 7 8]; + flg=2; + op=fsfirlin(in,flg); + disp(op); +endfunction diff --git a/tests/unit_tests/test_fsfirlin/scilabcode/main.sci b/tests/unit_tests/test_fsfirlin/scilabcode/main.sci new file mode 100644 index 0000000..a3acc51 --- /dev/null +++ b/tests/unit_tests/test_fsfirlin/scilabcode/main.sci @@ -0,0 +1,9 @@ +//This is the demo file to test the function fsfirlin +//The function gives design of FIR,linear phase filters using frequency sampling technique +function main() + in=[1 2 3 4 5 6 7 8]; //This is the vector of desired frequency responses samples + flg=2; //flg=2 for type-2 filter , it can be 1 for type-1 filter + op=fsfirlin(in,flg); + disp(op); +endfunction +//output |