From ad787796e65e1debe25871a98f9713f23d655ae4 Mon Sep 17 00:00:00 2001 From: Brijeshcr Date: Fri, 4 Aug 2017 21:40:41 +0530 Subject: Added Covar --- demos/Brijesh_Demos/test_covar.sci | 20 ++++++ includes/sci2clib.h | 3 + jar/scilab_en_US_help.jar | Bin 18035 -> 11210 bytes macros/ASTManagement/lib | Bin 0 -> 2008 bytes macros/CCodeGeneration/lib | Bin 0 -> 1056 bytes macros/ErrorMessages/lib | Bin 0 -> 520 bytes macros/FunctionAnnotation/lib | Bin 0 -> 2412 bytes macros/FunctionList/lib | Bin 0 -> 588 bytes macros/GeneralFunctions/lib | Bin 0 -> 1132 bytes macros/Hardware/AVR/lib | Bin 0 -> 972 bytes macros/Hardware/RasberryPi/Digital/lib | Bin 0 -> 600 bytes macros/Hardware/RasberryPi/I2C/lib | Bin 0 -> 704 bytes macros/Hardware/RasberryPi/Interrupt/lib | Bin 0 -> 536 bytes macros/Hardware/RasberryPi/Misc/lib | Bin 0 -> 564 bytes macros/Hardware/RasberryPi/SPI/lib | Bin 0 -> 584 bytes macros/Hardware/RasberryPi/Serial/lib | Bin 0 -> 692 bytes macros/Hardware/RasberryPi/Setup/lib | Bin 0 -> 616 bytes macros/Hardware/RasberryPi/Shift/lib | Bin 0 -> 568 bytes macros/Hardware/RasberryPi/Soft/lib | Bin 0 -> 636 bytes macros/Hardware/RasberryPi/Timing/lib | Bin 0 -> 596 bytes macros/Hardware/RasberryPi/gertBoard/lib | Bin 0 -> 656 bytes macros/Hardware/RasberryPi/lcd/lib | Bin 0 -> 776 bytes macros/Hardware/RasberryPi/lcd128x64/lib | Bin 0 -> 800 bytes macros/Hardware/RasberryPi/lib | Bin 0 -> 592 bytes macros/Hardware/RasberryPi/mcp/lib | Bin 0 -> 608 bytes macros/Hardware/RasberryPi/pcf/lib | Bin 0 -> 536 bytes macros/Hardware/RasberryPi/piGlow/lib | Bin 0 -> 596 bytes macros/Hardware/RasberryPi/pinMap/lib | Bin 0 -> 548 bytes macros/Hardware/RasberryPi/pwm/lib | Bin 0 -> 608 bytes macros/ImageProcessing/core/lib | Bin 0 -> 524 bytes macros/ImageProcessing/highgui/lib | Bin 0 -> 584 bytes macros/ImageProcessing/imgproc/lib | Bin 0 -> 752 bytes macros/Scilab-Arduino/lib | Bin 0 -> 716 bytes macros/SymbolTable/lib | Bin 0 -> 752 bytes .../ToolInitialization/INIT_FillSCI2LibCDirs.sci | 35 ++++++++++ macros/ToolInitialization/lib | Bin 0 -> 804 bytes macros/findDeps/getAllHeaders.sci | 1 + macros/findDeps/getAllInterfaces.sci | 1 + macros/findDeps/getAllSources.sci | 3 + macros/findDeps/lib | Bin 0 -> 620 bytes macros/lib | Bin 0 -> 536 bytes src/c/statisticsFunctions/covar/dcovars.c | 70 ++++++++++++++++++++ src/c/statisticsFunctions/covar/scovars.c | 70 ++++++++++++++++++++ src/c/statisticsFunctions/covar/zcovars.c | 71 +++++++++++++++++++++ src/c/statisticsFunctions/includes/covar.h | 43 +++++++++++++ src/c/statisticsFunctions/interfaces/int_covar.h | 29 +++++++++ 46 files changed, 346 insertions(+) create mode 100644 demos/Brijesh_Demos/test_covar.sci create mode 100644 macros/ASTManagement/lib create mode 100644 macros/CCodeGeneration/lib create mode 100644 macros/ErrorMessages/lib create mode 100644 macros/FunctionAnnotation/lib create mode 100644 macros/FunctionList/lib create mode 100644 macros/GeneralFunctions/lib create mode 100644 macros/Hardware/AVR/lib create mode 100644 macros/Hardware/RasberryPi/Digital/lib create mode 100644 macros/Hardware/RasberryPi/I2C/lib create mode 100644 macros/Hardware/RasberryPi/Interrupt/lib create mode 100644 macros/Hardware/RasberryPi/Misc/lib create mode 100644 macros/Hardware/RasberryPi/SPI/lib create mode 100644 macros/Hardware/RasberryPi/Serial/lib create mode 100644 macros/Hardware/RasberryPi/Setup/lib create mode 100644 macros/Hardware/RasberryPi/Shift/lib create mode 100644 macros/Hardware/RasberryPi/Soft/lib create mode 100644 macros/Hardware/RasberryPi/Timing/lib create mode 100644 macros/Hardware/RasberryPi/gertBoard/lib create mode 100644 macros/Hardware/RasberryPi/lcd/lib create mode 100644 macros/Hardware/RasberryPi/lcd128x64/lib create mode 100644 macros/Hardware/RasberryPi/lib create mode 100644 macros/Hardware/RasberryPi/mcp/lib create mode 100644 macros/Hardware/RasberryPi/pcf/lib create mode 100644 macros/Hardware/RasberryPi/piGlow/lib create mode 100644 macros/Hardware/RasberryPi/pinMap/lib create mode 100644 macros/Hardware/RasberryPi/pwm/lib create mode 100644 macros/ImageProcessing/core/lib create mode 100644 macros/ImageProcessing/highgui/lib create mode 100644 macros/ImageProcessing/imgproc/lib create mode 100644 macros/Scilab-Arduino/lib create mode 100644 macros/SymbolTable/lib create mode 100644 macros/ToolInitialization/lib create mode 100644 macros/findDeps/lib create mode 100644 macros/lib create mode 100644 src/c/statisticsFunctions/covar/dcovars.c create mode 100644 src/c/statisticsFunctions/covar/scovars.c create mode 100644 src/c/statisticsFunctions/covar/zcovars.c create mode 100644 src/c/statisticsFunctions/includes/covar.h create mode 100644 src/c/statisticsFunctions/interfaces/int_covar.h diff --git a/demos/Brijesh_Demos/test_covar.sci b/demos/Brijesh_Demos/test_covar.sci new file mode 100644 index 0000000..b182532 --- /dev/null +++ b/demos/Brijesh_Demos/test_covar.sci @@ -0,0 +1,20 @@ +function test_covar + disp('Datatype: Double'); + i3 = [1 2 3 4 5 6]; + i4 = [1 2]; + fre = [1 2 ;3 4; 5 6; 7 8; 9 1; 2 3]; + o2 = covar(i3,i4,fre); + disp(o2); + disp('Datatype: float'); + i7 = float([1 2 3 4 5 6]); + i8 = float([1 2]); + ffre = float([1 2 ;3 4; 5 6; 7 8; 9 1; 2 3]); + o4 = covar(i7,i8,ffre); + disp(o4); + disp('Datatype: DoubleComplex'); + i11 = [1 2 %i 4 6+6*%i 5]; + i12 = [1 %i]; + zfre = [1 %i ;3 0; 5 6*%i; 7 8; 9 1; 2 3]; + o6 = covar(i11,i12,zfre); + disp(o6); +endfunction diff --git a/includes/sci2clib.h b/includes/sci2clib.h index d7964b5..9a252ee 100644 --- a/includes/sci2clib.h +++ b/includes/sci2clib.h @@ -677,6 +677,9 @@ extern "C" { /* interfacing correl */ #include "correl.h" #include "int_correl.h" +/* interfacing covar */ +#include "covar.h" +#include "int_covar.h" /* TYPE */ diff --git a/jar/scilab_en_US_help.jar b/jar/scilab_en_US_help.jar index aeb5ddf..45d24f1 100644 Binary files a/jar/scilab_en_US_help.jar and b/jar/scilab_en_US_help.jar differ diff --git a/macros/ASTManagement/lib b/macros/ASTManagement/lib new file mode 100644 index 0000000..dee4362 Binary files /dev/null and b/macros/ASTManagement/lib differ diff --git a/macros/CCodeGeneration/lib b/macros/CCodeGeneration/lib new file mode 100644 index 0000000..3d4fed1 Binary files /dev/null and b/macros/CCodeGeneration/lib differ diff --git a/macros/ErrorMessages/lib b/macros/ErrorMessages/lib new file mode 100644 index 0000000..ba3b9a5 Binary files /dev/null and b/macros/ErrorMessages/lib differ diff --git a/macros/FunctionAnnotation/lib b/macros/FunctionAnnotation/lib new file mode 100644 index 0000000..239105c Binary files /dev/null and b/macros/FunctionAnnotation/lib differ diff --git a/macros/FunctionList/lib b/macros/FunctionList/lib new file mode 100644 index 0000000..1c722dd Binary files /dev/null and b/macros/FunctionList/lib differ diff --git a/macros/GeneralFunctions/lib b/macros/GeneralFunctions/lib new file mode 100644 index 0000000..7586a91 Binary files /dev/null and b/macros/GeneralFunctions/lib differ diff --git a/macros/Hardware/AVR/lib b/macros/Hardware/AVR/lib new file mode 100644 index 0000000..ed4c52b Binary files /dev/null and b/macros/Hardware/AVR/lib differ diff --git a/macros/Hardware/RasberryPi/Digital/lib b/macros/Hardware/RasberryPi/Digital/lib new file mode 100644 index 0000000..ba42ba7 Binary files /dev/null and b/macros/Hardware/RasberryPi/Digital/lib differ diff --git a/macros/Hardware/RasberryPi/I2C/lib b/macros/Hardware/RasberryPi/I2C/lib new file mode 100644 index 0000000..561476c Binary files /dev/null and b/macros/Hardware/RasberryPi/I2C/lib differ diff --git a/macros/Hardware/RasberryPi/Interrupt/lib b/macros/Hardware/RasberryPi/Interrupt/lib new file mode 100644 index 0000000..97a61ac Binary files /dev/null and b/macros/Hardware/RasberryPi/Interrupt/lib differ diff --git a/macros/Hardware/RasberryPi/Misc/lib b/macros/Hardware/RasberryPi/Misc/lib new file mode 100644 index 0000000..c718615 Binary files /dev/null and b/macros/Hardware/RasberryPi/Misc/lib differ diff --git a/macros/Hardware/RasberryPi/SPI/lib b/macros/Hardware/RasberryPi/SPI/lib new file mode 100644 index 0000000..a16d474 Binary files /dev/null and b/macros/Hardware/RasberryPi/SPI/lib differ diff --git a/macros/Hardware/RasberryPi/Serial/lib b/macros/Hardware/RasberryPi/Serial/lib new file mode 100644 index 0000000..a007f00 Binary files /dev/null and b/macros/Hardware/RasberryPi/Serial/lib differ diff --git a/macros/Hardware/RasberryPi/Setup/lib b/macros/Hardware/RasberryPi/Setup/lib new file mode 100644 index 0000000..83655c9 Binary files /dev/null and b/macros/Hardware/RasberryPi/Setup/lib differ diff --git a/macros/Hardware/RasberryPi/Shift/lib b/macros/Hardware/RasberryPi/Shift/lib new file mode 100644 index 0000000..2b12025 Binary files /dev/null and b/macros/Hardware/RasberryPi/Shift/lib differ diff --git a/macros/Hardware/RasberryPi/Soft/lib b/macros/Hardware/RasberryPi/Soft/lib new file mode 100644 index 0000000..09ecede Binary files /dev/null and b/macros/Hardware/RasberryPi/Soft/lib differ diff --git a/macros/Hardware/RasberryPi/Timing/lib b/macros/Hardware/RasberryPi/Timing/lib new file mode 100644 index 0000000..d271c90 Binary files /dev/null and b/macros/Hardware/RasberryPi/Timing/lib differ diff --git a/macros/Hardware/RasberryPi/gertBoard/lib b/macros/Hardware/RasberryPi/gertBoard/lib new file mode 100644 index 0000000..e8db080 Binary files /dev/null and b/macros/Hardware/RasberryPi/gertBoard/lib differ diff --git a/macros/Hardware/RasberryPi/lcd/lib b/macros/Hardware/RasberryPi/lcd/lib new file mode 100644 index 0000000..c2b693f Binary files /dev/null and b/macros/Hardware/RasberryPi/lcd/lib differ diff --git a/macros/Hardware/RasberryPi/lcd128x64/lib b/macros/Hardware/RasberryPi/lcd128x64/lib new file mode 100644 index 0000000..94dfda8 Binary files /dev/null and b/macros/Hardware/RasberryPi/lcd128x64/lib differ diff --git a/macros/Hardware/RasberryPi/lib b/macros/Hardware/RasberryPi/lib new file mode 100644 index 0000000..49ed811 Binary files /dev/null and b/macros/Hardware/RasberryPi/lib differ diff --git a/macros/Hardware/RasberryPi/mcp/lib b/macros/Hardware/RasberryPi/mcp/lib new file mode 100644 index 0000000..d411aad Binary files /dev/null and b/macros/Hardware/RasberryPi/mcp/lib differ diff --git a/macros/Hardware/RasberryPi/pcf/lib b/macros/Hardware/RasberryPi/pcf/lib new file mode 100644 index 0000000..da6a8da Binary files /dev/null and b/macros/Hardware/RasberryPi/pcf/lib differ diff --git a/macros/Hardware/RasberryPi/piGlow/lib b/macros/Hardware/RasberryPi/piGlow/lib new file mode 100644 index 0000000..3f30f85 Binary files /dev/null and b/macros/Hardware/RasberryPi/piGlow/lib differ diff --git a/macros/Hardware/RasberryPi/pinMap/lib b/macros/Hardware/RasberryPi/pinMap/lib new file mode 100644 index 0000000..133363e Binary files /dev/null and b/macros/Hardware/RasberryPi/pinMap/lib differ diff --git a/macros/Hardware/RasberryPi/pwm/lib b/macros/Hardware/RasberryPi/pwm/lib new file mode 100644 index 0000000..8711baf Binary files /dev/null and b/macros/Hardware/RasberryPi/pwm/lib differ diff --git a/macros/ImageProcessing/core/lib b/macros/ImageProcessing/core/lib new file mode 100644 index 0000000..40b7b0a Binary files /dev/null and b/macros/ImageProcessing/core/lib differ diff --git a/macros/ImageProcessing/highgui/lib b/macros/ImageProcessing/highgui/lib new file mode 100644 index 0000000..0d7f88a Binary files /dev/null and b/macros/ImageProcessing/highgui/lib differ diff --git a/macros/ImageProcessing/imgproc/lib b/macros/ImageProcessing/imgproc/lib new file mode 100644 index 0000000..63b5e7e Binary files /dev/null and b/macros/ImageProcessing/imgproc/lib differ diff --git a/macros/Scilab-Arduino/lib b/macros/Scilab-Arduino/lib new file mode 100644 index 0000000..a62fd4e Binary files /dev/null and b/macros/Scilab-Arduino/lib differ diff --git a/macros/SymbolTable/lib b/macros/SymbolTable/lib new file mode 100644 index 0000000..4379c83 Binary files /dev/null and b/macros/SymbolTable/lib differ diff --git a/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci b/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci index ff5afb5..617f689 100644 --- a/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci +++ b/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci @@ -1182,6 +1182,41 @@ INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCFLFunDir,ClassName,GeneralReport,Ex +// ------------------- +// --- Class COVAR. --- +// ------------------- +ClassName = 'covar'; + +// --- Class Annotation. --- +PrintStringInfo(' Adding Class: '+ClassName+'.',GeneralReport,'file','y'); +ClassFileName = fullfile(SCI2CLibCAnnClsDir,ClassName+ExtensionCAnnCls); +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)= ''1''',ClassFileName,'file','y'); +PrintStringInfo('OUT(1).SZ(2)= ''1''',ClassFileName,'file','y'); + + + +//---Function list class. ---- +ClassFileName = fullfile(SCI2CLibCFLClsDir,ClassName+ExtensionCFuncListCls); +PrintStringInfo('d2d2d2'+ArgSeparator+'d0',ClassFileName,'file','y'); +PrintStringInfo('s2s2s2'+ArgSeparator+'s0',ClassFileName,'file','y'); +PrintStringInfo('z2z2z2'+ArgSeparator+'z0',ClassFileName,'file','y'); + + + +// --- Annotation Function And Function List Function. --- +FunctionName = 'covar'; +PrintStringInfo(' Adding Function: '+FunctionName+'.',GeneralReport,'file','y'); +INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCAnnFunDir,ClassName,GeneralReport,ExtensionCAnnFun); +INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCFLFunDir,ClassName,GeneralReport,ExtensionCFuncListFun); + + + + + + // ------------------- // --- Class Nanmin. --- // ------------------- diff --git a/macros/ToolInitialization/lib b/macros/ToolInitialization/lib new file mode 100644 index 0000000..670a52e Binary files /dev/null and b/macros/ToolInitialization/lib differ diff --git a/macros/findDeps/getAllHeaders.sci b/macros/findDeps/getAllHeaders.sci index 6f417ec..d33bf16 100644 --- a/macros/findDeps/getAllHeaders.sci +++ b/macros/findDeps/getAllHeaders.sci @@ -164,6 +164,7 @@ function allHeaders = getAllHeaders(SharedInfo) "src/c/statisticsFunctions/includes/wcenter.h" "src/c/statisticsFunctions/includes/center.h" "src/c/statisticsFunctions/includes/correl.h" + "src/c/statisticsFunctions/includes/covar.h" "src/c/operations/includes/subtraction.h" "src/c/operations/includes/addition.h" "src/c/operations/includes/dynlib_operations.h" diff --git a/macros/findDeps/getAllInterfaces.sci b/macros/findDeps/getAllInterfaces.sci index 9d44df9..967051d 100644 --- a/macros/findDeps/getAllInterfaces.sci +++ b/macros/findDeps/getAllInterfaces.sci @@ -152,6 +152,7 @@ function allInterfaces = getAllInterfaces(SharedInfo) "src/c/statisticsFunctions/interfaces/int_wcenter.h" "src/c/statisticsFunctions/interfaces/int_center.h" "src/c/statisticsFunctions/interfaces/int_correl.h" + "src/c/statisticsFunctions/interfaces/int_covar.h" "src/c/operations/interfaces/int_OpEqual.h" "src/c/operations/interfaces/int_OpLogNot.h" "src/c/operations/interfaces/int_OpLogEq.h" diff --git a/macros/findDeps/getAllSources.sci b/macros/findDeps/getAllSources.sci index c3fd3a5..34f9dd3 100644 --- a/macros/findDeps/getAllSources.sci +++ b/macros/findDeps/getAllSources.sci @@ -1100,6 +1100,9 @@ function allSources = getAllSources(SharedInfo,BuildTool) "src/c/statisticsFunctions/correl/scorrelfres.c" "src/c/statisticsFunctions/correl/zcorrels.c" "src/c/statisticsFunctions/correl/zcorrelfres.c" + "src/c/statisticsFunctions/covar/dcovars.c" + "src/c/statisticsFunctions/covar/scovars.c" + "src/c/statisticsFunctions/covar/zcovars.c" "src/c/operations/multiplication/cmula.c" "src/c/operations/multiplication/cmuls.c" "src/c/operations/multiplication/cmulv.c" diff --git a/macros/findDeps/lib b/macros/findDeps/lib new file mode 100644 index 0000000..afcd3ca Binary files /dev/null and b/macros/findDeps/lib differ diff --git a/macros/lib b/macros/lib new file mode 100644 index 0000000..551263e Binary files /dev/null and b/macros/lib differ diff --git a/src/c/statisticsFunctions/covar/dcovars.c b/src/c/statisticsFunctions/covar/dcovars.c new file mode 100644 index 0000000..f67905e --- /dev/null +++ b/src/c/statisticsFunctions/covar/dcovars.c @@ -0,0 +1,70 @@ +#include +#include +#include +#include +#include "addition.h" +#include "subtraction.h" +#include "multiplication.h" +#include "division.h" +#include "sqrt.h" +#include "sum.h" +#include "correl.h" +#include "matrix.h" +#include "mean.h" + +double dcovars (double* inp1, int sr1, int sc1, double* inp2, int sr2, int sc2, double* fre, int sr3, int sc3) +{ + double fr[sr3*sc3], s3 = 0, sfrr[sc3], p1[sc2*sc3], s1 = 0, d1[sc2] , one[sr1*sc1], p2[sc1 * sc2], p3[sr3*sc3], sfrc[sr3], p4[sr3], s2 = 0, d2[sr1*sc1], one2[sr2*sc2], p5[sr1*sc1*sr2*sc2], p6[sr1*sc1*sr2*sc2],s4 = 0; + + for(int i = 0; i < sr3*sc3; i++) + s3 += fre[i]; + + for(int i = 0; i < sr3*sc3; i++) + fr[i] = fre[i]/s3; + + drowsuma(fr, sr3, sc3, sfrr); + + for(int i = 0; i < sc3; i++) + p1[i] = inp2[i] * sfrr[i]; + + for(int i = 0; i < sc3; i++) + s1 += p1[i]; + + + + for(int i = 0; i < sc2; i++) + d1[i] = inp2[i] - s1; + + donesa(one, sr1*sc1, 1); + + dmulma(one, sr1*sc1, 1, d1, 1, sc2, p2); + + for(int i = 0; i < sr3*sc3; i++) + p3[i] = fr[i] * p2[i]; + + dcolumnsuma(fr, sr3, sc3, sfrc); + + for(int i = 0; i < sr3; i++) + p4[i] = inp1[i] * sfrc[i]; + + for(int i = 0; i < sr3; i++) + s2 += p4[i]; + + for(int i = 0; i < sr1*sc1; i++) + d2[i] = inp1[i] - s2; + + donesa(one2, 1, sr2*sc2); + + dmulma(d2, sr1*sc1, 1, one2, 1, sr2*sc2, p5); + + for(int i = 0; i < sr1*sc1*sr2*sc2; i++) + p6[i] = p5[i] * p3[i]; + + + for(int i = 0; i < sr1*sc1*sr2*sc2; i++) + s4 += p6[i]; + + + return s4; + +} diff --git a/src/c/statisticsFunctions/covar/scovars.c b/src/c/statisticsFunctions/covar/scovars.c new file mode 100644 index 0000000..daff6b9 --- /dev/null +++ b/src/c/statisticsFunctions/covar/scovars.c @@ -0,0 +1,70 @@ +#include +#include +#include +#include +#include "addition.h" +#include "subtraction.h" +#include "multiplication.h" +#include "division.h" +#include "sqrt.h" +#include "sum.h" +#include "correl.h" +#include "matrix.h" +#include "mean.h" + +float scovars (float* inp1, int sr1, int sc1, float* inp2, int sr2, int sc2, float* fre, int sr3, int sc3) +{ + float fr[sr3*sc3], s3 = 0, sfrr[sc3], p1[sc2*sc3], s1 = 0, d1[sc2] , one[sr1*sc1], p2[sc1 * sc2], p3[sr3*sc3], sfrc[sr3], p4[sr3], s2 = 0, d2[sr1*sc1], one2[sr2*sc2], p5[sr1*sc1*sr2*sc2], p6[sr1*sc1*sr2*sc2],s4 = 0; + + for(int i = 0; i < sr3*sc3; i++) + s3 += fre[i]; + + for(int i = 0; i < sr3*sc3; i++) + fr[i] = fre[i]/s3; + + srowsuma(fr, sr3, sc3, sfrr); + + for(int i = 0; i < sc3; i++) + p1[i] = inp2[i] * sfrr[i]; + + for(int i = 0; i < sc3; i++) + s1 += p1[i]; + + + + for(int i = 0; i < sc2; i++) + d1[i] = inp2[i] - s1; + + sonesa(one, sr1*sc1, 1); + + smulma(one, sr1*sc1, 1, d1, 1, sc2, p2); + + for(int i = 0; i < sr3*sc3; i++) + p3[i] = fr[i] * p2[i]; + + scolumnsuma(fr, sr3, sc3, sfrc); + + for(int i = 0; i < sr3; i++) + p4[i] = inp1[i] * sfrc[i]; + + for(int i = 0; i < sr3; i++) + s2 += p4[i]; + + for(int i = 0; i < sr1*sc1; i++) + d2[i] = inp1[i] - s2; + + sonesa(one2, 1, sr2*sc2); + + smulma(d2, sr1*sc1, 1, one2, 1, sr2*sc2, p5); + + for(int i = 0; i < sr1*sc1*sr2*sc2; i++) + p6[i] = p5[i] * p3[i]; + + + for(int i = 0; i < sr1*sc1*sr2*sc2; i++) + s4 += p6[i]; + + + return s4; + +} diff --git a/src/c/statisticsFunctions/covar/zcovars.c b/src/c/statisticsFunctions/covar/zcovars.c new file mode 100644 index 0000000..6adbd3c --- /dev/null +++ b/src/c/statisticsFunctions/covar/zcovars.c @@ -0,0 +1,71 @@ +#include +#include +#include +#include +#include "addition.h" +#include "subtraction.h" +#include "multiplication.h" +#include "division.h" +#include "sqrt.h" +#include "sum.h" +#include "correl.h" +#include "matrix.h" +#include "mean.h" +#include "doubleComplex.h" + +doubleComplex zcovars (doubleComplex* inp1, int sr1, int sc1, doubleComplex* inp2, int sr2, int sc2, doubleComplex* fre, int sr3, int sc3) +{ + doubleComplex fr[sr3*sc3], s3 = 0, sfrr[sc3], p1[sc2*sc3], s1 = 0, d1[sc2] , one[sr1*sc1], p2[sc1 * sc2], p3[sr3*sc3], sfrc[sr3], p4[sr3], s2 = 0, d2[sr1*sc1], one2[sr2*sc2], p5[sr1*sc1*sr2*sc2], p6[sr1*sc1*sr2*sc2],s4 = 0; + + for(int i = 0; i < sr3*sc3; i++) + s3 = zadds(s3, fre[i]); + + for(int i = 0; i < sr3*sc3; i++) + fr[i] = zrdivs(fre[i], s3); + + zrowsuma(fr, sr3, sc3, sfrr); + + for(int i = 0; i < sc3; i++) + p1[i] = zmuls(inp2[i], sfrr[i]); + + for(int i = 0; i < sc3; i++) + s1 = zadds(s1, p1[i]); + + + + for(int i = 0; i < sc2; i++) + d1[i] = zdiffs(inp2[i], s1); + + zonesa(one, sr1*sc1, 1); + + zmulma(one, sr1*sc1, 1, d1, 1, sc2, p2); + + for(int i = 0; i < sr3*sc3; i++) + p3[i] = fr[i] * p2[i]; + + zcolumnsuma(fr, sr3, sc3, sfrc); + + for(int i = 0; i < sr3; i++) + p4[i] = zmuls(inp1[i], sfrc[i]); + + for(int i = 0; i < sr3; i++) + s2 = zadds(s2, p4[i]); + + for(int i = 0; i < sr1*sc1; i++) + d2[i] = zdiffs(inp1[i], s2); + + zonesa(one2, 1, sr2*sc2); + + zmulma(d2, sr1*sc1, 1, one2, 1, sr2*sc2, p5); + + for(int i = 0; i < sr1*sc1*sr2*sc2; i++) + p6[i] = zmuls(p5[i], p3[i]); + + + for(int i = 0; i < sr1*sc1*sr2*sc2; i++) + s4 = zadds(s4, p6[i]); + + + return s4; + +} diff --git a/src/c/statisticsFunctions/includes/covar.h b/src/c/statisticsFunctions/includes/covar.h new file mode 100644 index 0000000..4f37f85 --- /dev/null +++ b/src/c/statisticsFunctions/includes/covar.h @@ -0,0 +1,43 @@ + /* 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 __COVAR_H__ +#define __COVAR_H__ +#include "types.h" +#include "doubleComplex.h" +#include "floatComplex.h" +#include +#include +#include "addition.h" +#include "subtraction.h" +#include "multiplication.h" +#include "division.h" +#include "sqrt.h" +#include "sum.h" +#include "correl.h" +#include "matrix.h" +#include "mean.h" + +#ifdef __cplusplus +extern "C" { +#endif + +double dcovars (double* inp1, int sr1, int sc1, double* inp2, int sr2, int sc2, double* fre, int sr3, int sc3); +float scovars (float* inp1, int sr1, int sc1, float* inp2, int sr2, int sc2, float* fre, int sr3, int sc3); +doubleComplex zcovars (doubleComplex* inp1, int sr1, int sc1, doubleComplex* inp2, int sr2, int sc2, doubleComplex* fre, int sr3, int sc3); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__COVAR_H__*/ diff --git a/src/c/statisticsFunctions/interfaces/int_covar.h b/src/c/statisticsFunctions/interfaces/int_covar.h new file mode 100644 index 0000000..5ebef22 --- /dev/null +++ b/src/c/statisticsFunctions/interfaces/int_covar.h @@ -0,0 +1,29 @@ + /* 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_COVAR_H__ +#define __INT_COVAR_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#define d2d2d2covard0(in1, size, in2, size2, in3, size3) dcovars(in1, size[0], size[1], in2, size2[0], size2[1], in3, size3[0], size3[1]) +#define s2s2s2covars0(in1, size, in2, size2, in3, size3) scovars(in1, size[0], size[1], in2, size2[0], size2[1], in3, size3[0], size3[1]) +#define z2z2z2covarz0(in1, size, in2, size2, in3, size3) zcovars(in1, size[0], size[1], in2, size2[0], size2[1], in3, size3[0], size3[1]) + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__INT_COVAR_H__*/ -- cgit