diff options
-rw-r--r-- | demos/Brijesh_Demos/Test_Erfinv.sci | 10 | ||||
-rw-r--r-- | includes/sci2clib.h | 7 | ||||
-rw-r--r-- | jar/scilab_en_US_help.jar | bin | 11210 -> 11210 bytes | |||
-rw-r--r-- | macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci | 30 | ||||
-rw-r--r-- | macros/findDeps/getAllHeaders.sci | 1 | ||||
-rw-r--r-- | macros/findDeps/getAllInterfaces.sci | 1 | ||||
-rw-r--r-- | macros/findDeps/getAllSources.sci | 4 | ||||
-rw-r--r-- | src/c/specialFunctions/erfinv/derfinva.c | 25 | ||||
-rw-r--r-- | src/c/specialFunctions/erfinv/derfinvs.c | 49 | ||||
-rw-r--r-- | src/c/specialFunctions/erfinv/serfinva.c | 25 | ||||
-rw-r--r-- | src/c/specialFunctions/erfinv/serfinvs.c | 50 | ||||
-rw-r--r-- | src/c/specialFunctions/includes/erfinv.h | 35 | ||||
-rw-r--r-- | src/c/specialFunctions/interfaces/int_erfinv.h | 30 |
13 files changed, 266 insertions, 1 deletions
diff --git a/demos/Brijesh_Demos/Test_Erfinv.sci b/demos/Brijesh_Demos/Test_Erfinv.sci new file mode 100644 index 0000000..99a8683 --- /dev/null +++ b/demos/Brijesh_Demos/Test_Erfinv.sci @@ -0,0 +1,10 @@ +function Test_Erfinv + disp('Datatype: Double'); + i1 = [12 0.6 -2 -0.75]; + o1 = erfinv(i1); + disp(o1); + disp('Datatype: float'); + i2 = float([5 0.35 -1 -.97 -6]); + o2 = erf(i2); + disp(o2); +endfunction diff --git a/includes/sci2clib.h b/includes/sci2clib.h index dbfc8cc..10476ea 100644 --- a/includes/sci2clib.h +++ b/includes/sci2clib.h @@ -86,10 +86,15 @@ extern "C" { #include "erf.h" #include "int_erf.h" -/* interfacing erf */ +/* interfacing erfc */ #include "erfc.h" #include "int_erfc.h" +/* interfacing erfinv */ +#include "erfinv.h" +#include "int_erfinv.h" + + /* ELEMENTARY FUNCTIONS */ #include "nextpow2.h" diff --git a/jar/scilab_en_US_help.jar b/jar/scilab_en_US_help.jar Binary files differindex fb924f1..45e15ed 100644 --- a/jar/scilab_en_US_help.jar +++ b/jar/scilab_en_US_help.jar diff --git a/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci b/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci index 85472a8..265dd95 100644 --- a/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci +++ b/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci @@ -4931,6 +4931,36 @@ INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCAnnFunDir,ClassName,GeneralReport,E INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCFLFunDir,ClassName,GeneralReport,ExtensionCFuncListFun);
+//------------------------------------
+//---- Class ERFINV ----------------
+//------------------------------------
+ClassName = 'erfinv';
+
+// --- Class Annotation. ---
+PrintStringInfo(' Adding Class: '+ClassName+'.',GeneralReport,'file','y');
+ClassFileName = fullfile(SCI2CLibCAnnClsDir,ClassName+ExtensionCAnnCls);
+
+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)= 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('d0'+ArgSeparator+'d0',ClassFileName,'file','y');
+PrintStringInfo('d2'+ArgSeparator+'d2',ClassFileName,'file','y');
+PrintStringInfo('s0'+ArgSeparator+'s0',ClassFileName,'file','y');
+PrintStringInfo('s2'+ArgSeparator+'s2',ClassFileName,'file','y');
+
+
+// --- Annotation Function And Function List Function. ---
+FunctionName = 'erfinv';
+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/findDeps/getAllHeaders.sci b/macros/findDeps/getAllHeaders.sci index cf606ab..a00d15e 100644 --- a/macros/findDeps/getAllHeaders.sci +++ b/macros/findDeps/getAllHeaders.sci @@ -227,6 +227,7 @@ function allHeaders = getAllHeaders(SharedInfo) "src/c/elementaryFunctions/includes/sinc.h" "src/c/specialFunctions/includes/erf.h" "src/c/specialFunctions/includes/erfc.h" + "src/c/specialFunctions/includes/erfinv.h" "src/c/CACSD/includes/syslin.h" "src/c/CACSD/includes/lqr.h" "src/c/CACSD/includes/lqe.h" diff --git a/macros/findDeps/getAllInterfaces.sci b/macros/findDeps/getAllInterfaces.sci index 977ea76..ece1685 100644 --- a/macros/findDeps/getAllInterfaces.sci +++ b/macros/findDeps/getAllInterfaces.sci @@ -222,6 +222,7 @@ function allInterfaces = getAllInterfaces(SharedInfo) "src/c/elementaryFunctions/interfaces/int_sinc.h" "src/c/specialFunctions/interfaces/int_erf.h" "src/c/specialFunctions/interfaces/int_erfc.h" + "src/c/specialFunctions/interfaces/int_erfinv.h" "src/c/CACSD/interfaces/int_syslin.h" "src/c/CACSD/interfaces/int_lqr.h" "src/c/CACSD/interfaces/int_lqe.h" diff --git a/macros/findDeps/getAllSources.sci b/macros/findDeps/getAllSources.sci index 60908c8..b72a19f 100644 --- a/macros/findDeps/getAllSources.sci +++ b/macros/findDeps/getAllSources.sci @@ -1336,6 +1336,10 @@ function allSources = getAllSources(SharedInfo,BuildTool) "src/c/specialFunctions/erfc/derfca.c" "src/c/specialFunctions/erfc/serfcs.c" "src/c/specialFunctions/erfc/serfca.c" + "src/c/specialFunctions/erfinv/derfinvs.c" + "src/c/specialFunctions/erfinv/derfinva.c" + "src/c/specialFunctions/erfinv/serfinvs.c" + "src/c/specialFunctions/erfinv/serfinva.c" "src/c/CACSD/syslin/dsyslina.c" "src/c/CACSD/lqr/dlqra.c" "src/c/CACSD/lqe/dlqea.c" diff --git a/src/c/specialFunctions/erfinv/derfinva.c b/src/c/specialFunctions/erfinv/derfinva.c new file mode 100644 index 0000000..45d119c --- /dev/null +++ b/src/c/specialFunctions/erfinv/derfinva.c @@ -0,0 +1,25 @@ +/* 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: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "erfinv.h" + +void derfinva(double* inp1, int sizer, int sizec,double* out) +{ + for (int i = 0; i < sizer*sizec; i++) + { + out[i] = derfinvs(inp1[i]); + } +} + diff --git a/src/c/specialFunctions/erfinv/derfinvs.c b/src/c/specialFunctions/erfinv/derfinvs.c new file mode 100644 index 0000000..379d6af --- /dev/null +++ b/src/c/specialFunctions/erfinv/derfinvs.c @@ -0,0 +1,49 @@ +/* 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: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "erfinv.h" + +# define PI 3.1415927 + +double derfinvs (double inp1) +{ + double a[] = {0.88622692374517353,-1.6601283962374516,0.92661860147244357,-0.14110320437680104}; + double b[] = {-2.13505380615258078,1.46060340345661088,-0.33198239813321595,0.01197270616590528}; + double c[] = {-1.994216456587148,-1.87267416351196,3.60874665878559364,1.82365845766309853}; + double d[] = {3.74146294065960872,1.81848952562894617}; + + if ((inp1 > 1) || (inp1 < -1)) + { + return 0.0/0.0; + } + if ((inp1 >= -0.7) && (inp1 <= 0.7)) + { + double sq = inp1 * inp1; + return (inp1 * (((a[3]*sq+a[2]) * sq+a[1]) * sq+a[0]) / ((((b[3]*sq+b[2]) * sq+b[1]) * sq+b[0]) * sq+1)); + } + + else if ((inp1 > 0.7) && (inp1 < 1)) + { + double z = sqrt(-log((1-inp1)/2)); + return ((((c[3]*z+c[2]) * z+c[1]) * z+c[0]) / ((d[1]*z+d[0]) * z+1)); + } + + else if ((inp1 > -1) && (inp1 < 0.7)) + { + double z = sqrt(-log((1+inp1)/2)); + return (-(((c[3]*z+c[2]) * z+c[1]) * z+c[0]) / ((d[1]*z+d[0]) * z+1)); + } +} + diff --git a/src/c/specialFunctions/erfinv/serfinva.c b/src/c/specialFunctions/erfinv/serfinva.c new file mode 100644 index 0000000..56e47c2 --- /dev/null +++ b/src/c/specialFunctions/erfinv/serfinva.c @@ -0,0 +1,25 @@ +/* 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: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "erfinv.h" + +void serfinva(float* inp1, int sizer, int sizec,float* out) +{ + for (int i = 0; i < sizer*sizec; i++) + { + out[i] = derfinvs(inp1[i]); + } +} + diff --git a/src/c/specialFunctions/erfinv/serfinvs.c b/src/c/specialFunctions/erfinv/serfinvs.c new file mode 100644 index 0000000..2d97ef7 --- /dev/null +++ b/src/c/specialFunctions/erfinv/serfinvs.c @@ -0,0 +1,50 @@ +/* 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: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "erfinv.h" + +# define PI 3.1415927 + +float serfinvs (float inp1) +{ + float a[] = {0.88622692374517353,-1.6601283962374516,0.92661860147244357,-0.14110320437680104}; + float b[] = {-2.13505380615258078,1.46060340345661088,-0.33198239813321595,0.01197270616590528}; + float c[] = {-1.994216456587148,-1.87267416351196,3.60874665878559364,1.82365845766309853}; + float d[] = {3.74146294065960872,1.81848952562894617}; + + if ((inp1 > 1) || (inp1 < -1)) + { + double na = 0.0/0.0; + return (float)na; + } + if ((inp1 >= -0.7) && (inp1 <= 0.7)) + { + float sq = inp1 * inp1; + return (inp1 * (((a[3]*sq+a[2]) * sq+a[1]) * sq+a[0]) / ((((b[3]*sq+b[2]) * sq+b[1]) * sq+b[0]) * sq+1)); + } + + else if ((inp1 > 0.7) && (inp1 < 1)) + { + float z = sqrt(-log((1-inp1)/2)); + return ((((c[3]*z+c[2]) * z+c[1]) * z+c[0]) / ((d[1]*z+d[0]) * z+1)); + } + + else if ((inp1 > -1) && (inp1 < 0.7)) + { + float z = sqrt(-log((1+inp1)/2)); + return (-(((c[3]*z+c[2]) * z+c[1]) * z+c[0]) / ((d[1]*z+d[0]) * z+1)); + } +} + diff --git a/src/c/specialFunctions/includes/erfinv.h b/src/c/specialFunctions/includes/erfinv.h new file mode 100644 index 0000000..5d6210c --- /dev/null +++ b/src/c/specialFunctions/includes/erfinv.h @@ -0,0 +1,35 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET + * + * 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 + * + */ + +#ifndef __ERFINV_H__ +#define __ERFINV_H__ +#include "types.h" +#include "floatComplex.h" +#include "doubleComplex.h" +#include "uint8.h" +#include "uint16.h" +#include "int16.h" + +#ifdef __cplusplus +extern "C" { +#endif + +double derfinvs (double inp1); +float serfinvs (float inp1); +void derfinva(double* inp1, int sizer, int sizec,double* out); +void serfinva(float* inp1, int sizer, int sizec,float* out); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__ERFINV_H__*/ diff --git a/src/c/specialFunctions/interfaces/int_erfinv.h b/src/c/specialFunctions/interfaces/int_erfinv.h new file mode 100644 index 0000000..f19baa1 --- /dev/null +++ b/src/c/specialFunctions/interfaces/int_erfinv.h @@ -0,0 +1,30 @@ +/* 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_ERFINV_H__ +#define __INT_ERFINV_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define d0erfinvd0(in1) derfinvs(in1) +#define s0erfinvs0(in1) serfinvs(in1) +#define d2erfinvd2(in1,size,out) derfinva(in1,size[0],size[1],out) +#define s2erfinvs2(in1,size,out) serfinva(in1,size[0],size[1],out) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__INT_ERFINV_H__*/ |