diff options
author | Abhinav Dronamraju | 2017-09-29 22:00:40 +0530 |
---|---|---|
committer | Abhinav Dronamraju | 2017-09-29 22:00:40 +0530 |
commit | 9bc7ad78e8d7d7acc4b9387aa592542832e80b31 (patch) | |
tree | 7fce060665a91de5e5adb12d02003351c3d1fdfc /src/c/auxiliaryFunctions | |
parent | 33755eb085a3ca8154cf83773b23fbb8aac4ba3e (diff) | |
parent | ac0045f12ad3d0938758e9742f4107a334e1afaa (diff) | |
download | scilab2c-9bc7ad78e8d7d7acc4b9387aa592542832e80b31.tar.gz scilab2c-9bc7ad78e8d7d7acc4b9387aa592542832e80b31.tar.bz2 scilab2c-9bc7ad78e8d7d7acc4b9387aa592542832e80b31.zip |
NEW FEATURES AND NEW FUNCTIONS
Diffstat (limited to 'src/c/auxiliaryFunctions')
44 files changed, 1268 insertions, 34 deletions
diff --git a/src/c/auxiliaryFunctions/abs/i16absa.c b/src/c/auxiliaryFunctions/abs/i16absa.c new file mode 100644 index 00000000..2abedc47 --- /dev/null +++ b/src/c/auxiliaryFunctions/abs/i16absa.c @@ -0,0 +1,20 @@ +/* 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 +*/ + +#include "abs.h" + +void i16absa(int16 *in, int size, int16* out) { + int i = 0; + for (i = 0; i < size; ++i) { + out[i] = i16abss(in[i]); + } +} diff --git a/src/c/auxiliaryFunctions/abs/i16abss.c b/src/c/auxiliaryFunctions/abs/i16abss.c new file mode 100644 index 00000000..ab478333 --- /dev/null +++ b/src/c/auxiliaryFunctions/abs/i16abss.c @@ -0,0 +1,20 @@ +/* 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 +*/ + +#include "abs.h" + +int16 i16abss(int16 num) { + if (num >= 0) { + return num; + } + return -num; +} diff --git a/src/c/auxiliaryFunctions/abs/i8absa.c b/src/c/auxiliaryFunctions/abs/i8absa.c new file mode 100644 index 00000000..1a646e4a --- /dev/null +++ b/src/c/auxiliaryFunctions/abs/i8absa.c @@ -0,0 +1,20 @@ +/* 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 +*/ + +#include "abs.h" + +void i8absa(int8 *in, int size, int8* out) { + int i = 0; + for (i = 0; i < size; ++i) { + out[i] = i8abss(in[i]); + } +} diff --git a/src/c/auxiliaryFunctions/abs/i8abss.c b/src/c/auxiliaryFunctions/abs/i8abss.c new file mode 100644 index 00000000..2c3e0a04 --- /dev/null +++ b/src/c/auxiliaryFunctions/abs/i8abss.c @@ -0,0 +1,20 @@ +/* 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 +*/ + +#include "abs.h" + +int8 i8abss(int8 num) { + if (num >= 0) { + return num; + } + return -num; +} diff --git a/src/c/auxiliaryFunctions/abs/u16absa.c b/src/c/auxiliaryFunctions/abs/u16absa.c new file mode 100644 index 00000000..60c1ed96 --- /dev/null +++ b/src/c/auxiliaryFunctions/abs/u16absa.c @@ -0,0 +1,20 @@ +/* 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 +*/ + +#include "abs.h" + +void u16absa(uint16 *in, int size, uint16* out) { + int i = 0; + for (i = 0; i < size; ++i) { + out[i] = u16abss(in[i]); + } +} diff --git a/src/c/auxiliaryFunctions/abs/u16abss.c b/src/c/auxiliaryFunctions/abs/u16abss.c new file mode 100644 index 00000000..2e15d25f --- /dev/null +++ b/src/c/auxiliaryFunctions/abs/u16abss.c @@ -0,0 +1,20 @@ +/* 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 +*/ + +#include "abs.h" + +uint16 u16abss(uint16 num) { + if (num >= 0) { + return num; + } + return -num; +} diff --git a/src/c/auxiliaryFunctions/abs/u8absa.c b/src/c/auxiliaryFunctions/abs/u8absa.c new file mode 100644 index 00000000..2edd8541 --- /dev/null +++ b/src/c/auxiliaryFunctions/abs/u8absa.c @@ -0,0 +1,20 @@ +/* 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 +*/ + +#include "abs.h" + +void u8absa(uint8 *in, int size, uint8* out) { + int i = 0; + for (i = 0; i < size; ++i) { + out[i] = u8abss(in[i]); + } +} diff --git a/src/c/auxiliaryFunctions/abs/u8abss.c b/src/c/auxiliaryFunctions/abs/u8abss.c new file mode 100644 index 00000000..220e9b8c --- /dev/null +++ b/src/c/auxiliaryFunctions/abs/u8abss.c @@ -0,0 +1,20 @@ +/* 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 +*/ + +#include "abs.h" + +uint8 u8abss(uint8 num) { + if (num >= 0) { + return num; + } + return -num; +} diff --git a/src/c/auxiliaryFunctions/abs/zabss.c b/src/c/auxiliaryFunctions/abs/zabss.c index 4e7b4dd3..7ada57d1 100644 --- a/src/c/auxiliaryFunctions/abs/zabss.c +++ b/src/c/auxiliaryFunctions/abs/zabss.c @@ -16,6 +16,7 @@ #include "sqrt.h" #include "max.h" #include "min.h" +#include "doubleComplex.h" double zabss(doubleComplex in) { double real = dabss(zreals(in)); diff --git a/src/c/auxiliaryFunctions/find/i16finda.c b/src/c/auxiliaryFunctions/find/i16finda.c new file mode 100644 index 00000000..4dff1020 --- /dev/null +++ b/src/c/auxiliaryFunctions/find/i16finda.c @@ -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 +*/ + +#include "find.h" + +void i16finda(int16* x, int size, int16 *out, int max) +{ + int i = 0; + int j = 0; + + /* if out is empty */ + out[0]=-1; + + + for (i = 0; i < size ; ++i) + { + /*to avoid useless search if we only want to find the max first founded value */ + if (j == max) + { + return ; + } + + if (x[i] != 0) + { + out[j] = (int16)(i+1); + ++j; + } + } +} + diff --git a/src/c/auxiliaryFunctions/find/i8finda.c b/src/c/auxiliaryFunctions/find/i8finda.c new file mode 100644 index 00000000..7e633dc1 --- /dev/null +++ b/src/c/auxiliaryFunctions/find/i8finda.c @@ -0,0 +1,40 @@ +/* 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 +*/ + + +#include "find.h" + +void i8finda(int8* x, int size, int8 *out, int max) +{ + int i = 0; + int j = 0; + + /* if out is empty */ + out[0]=-1; + + + for (i = 0; i < size ; ++i) + { + /*to avoid useless search if we only want to find the max first founded value */ + if (j == max) + { + return ; + } + + if (x[i] != 0) + { + out[j] = (int8)(i+1); + ++j; + } + } +} + diff --git a/src/c/auxiliaryFunctions/find/u16finda.c b/src/c/auxiliaryFunctions/find/u16finda.c new file mode 100644 index 00000000..2ff57869 --- /dev/null +++ b/src/c/auxiliaryFunctions/find/u16finda.c @@ -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 +*/ + +#include "find.h" + +void u16finda(uint16* x, int size, uint16 *out, int max) +{ + int i = 0; + int j = 0; + + /* if out is empty */ + out[0]=-1; + + + for (i = 0; i < size ; ++i) + { + /*to avoid useless search if we only want to find the max first founded value */ + if (j == max) + { + return ; + } + + if (x[i] != 0) + { + out[j] = (uint16)(i+1); + ++j; + } + } +} + diff --git a/src/c/auxiliaryFunctions/find/u8finda.c b/src/c/auxiliaryFunctions/find/u8finda.c new file mode 100644 index 00000000..e2de81fa --- /dev/null +++ b/src/c/auxiliaryFunctions/find/u8finda.c @@ -0,0 +1,40 @@ +/* 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 +*/ + + +#include "find.h" + +void u8finda(uint8* x, int size, uint8 *out, int max) +{ + int i = 0; + int j = 0; + + /* if out is empty */ + out[0]=-1; + + + for (i = 0; i < size ; ++i) + { + /*to avoid useless search if we only want to find the max first founded value */ + if (j == max) + { + return ; + } + + if (x[i] != 0) + { + out[j] = (uint8)(i+1); + ++j; + } + } +} + diff --git a/src/c/auxiliaryFunctions/includes/abs.h b/src/c/auxiliaryFunctions/includes/abs.h index 00565e39..cd022905 100644 --- a/src/c/auxiliaryFunctions/includes/abs.h +++ b/src/c/auxiliaryFunctions/includes/abs.h @@ -17,6 +17,7 @@ #include "floatComplex.h" #include "doubleComplex.h" #include "sqrt.h" +#include "types.h" #ifdef __cplusplus extern "C" { @@ -55,6 +56,38 @@ EXTERN_AUXFUNCT float cabss(floatComplex in); EXTERN_AUXFUNCT double zabss(doubleComplex in); /** + ** \brief Uint8 Absolute Value function + ** Determine the absolute value of in. + ** \param in : the uint8 we must determine abs. + ** \return -in or in depending on the sign of in. + **/ +EXTERN_AUXFUNCT uint8 u8abss(uint8 in); + +/** + ** \brief Int8 Absolute Value function + ** Determine the absolute value of in. + ** \param in : the int8 we must determine abs. + ** \return -in or in depending on the sign of in. + **/ +EXTERN_AUXFUNCT int8 i8abss(int8 in); + +/** + ** \brief Uint16 Absolute Value function + ** Determine the absolute value of in. + ** \param in : the uint16 we must determine abs. + ** \return -in or in depending on the sign of in. + **/ +EXTERN_AUXFUNCT uint16 u16abss(uint16 in); + +/** + ** \brief Int16 Absolute Value function + ** Determine the absolute value of in. + ** \param in : the int16 we must determine abs. + ** \return -in or in depending on the sign of in. + **/ +EXTERN_AUXFUNCT int16 i16abss(int16 in); + +/** ** \brief Float Array Absolute Value function ** Determine the absolute value of in elements. ** \param in : the float array we must determine abs. @@ -86,6 +119,40 @@ EXTERN_AUXFUNCT void cabsa(floatComplex *in, int size, float* out); **/ EXTERN_AUXFUNCT void zabsa(doubleComplex *in, int size, double* out); + +/** + ** \brief Uint8 Array Absolute Value function + ** Determine the absolute value of in elements. + ** \param in : the uint8 array we must determine abs. + ** \param out : the uint8 array result. + **/ +EXTERN_AUXFUNCT void u8absa(uint8 *in, int size, uint8* out); + +/** + ** \brief Int8 Array Absolute Value function + ** Determine the absolute value of in elements. + ** \param in : the int8 array we must determine abs. + ** \param out : the int8 array result. + **/ +EXTERN_AUXFUNCT void i8absa(int8 *in, int size, int8* out); + +/** + ** \brief Uint16 Array Absolute Value function + ** Determine the absolute value of in elements. + ** \param in : the uint16 array we must determine abs. + ** \param out : the uint16 array result. + **/ +EXTERN_AUXFUNCT void u16absa(uint16 *in, int size, uint16* out); + +/** + ** \brief Int16 Array Absolute Value function + ** Determine the absolute value of in elements. + ** \param in : the int16 array we must determine abs. + ** \param out : the int16 array result. + **/ +EXTERN_AUXFUNCT void i16absa(int16 *in, int size, int16* out); + + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/c/auxiliaryFunctions/includes/find.h b/src/c/auxiliaryFunctions/includes/find.h index 3104e957..8072f745 100644 --- a/src/c/auxiliaryFunctions/includes/find.h +++ b/src/c/auxiliaryFunctions/includes/find.h @@ -16,6 +16,7 @@ #include "dynlib_auxiliaryfunctions.h" #include "floatComplex.h" #include "doubleComplex.h" +#include "types.h" #ifdef __cplusplus extern "C" { @@ -44,6 +45,32 @@ EXTERN_AUXFUNCT void cfinda(floatComplex* z, int size, float *out, int max); */ EXTERN_AUXFUNCT void zfinda(doubleComplex* z, int size, double *out, int max); +/* +** \brief uint8 Find function +** max is an integer giving the maximum number of indices to return. (use -1 to search them all) +*/ +EXTERN_AUXFUNCT void u8finda(uint8 *x, int size, uint8 *out, int max); + +/* +** \brief uint16 Find function +** max is an integer giving the maximum number of indices to return. (use -1 to search them all) +*/ +EXTERN_AUXFUNCT void u16finda(uint16 *x, int size, uint16 *out, int max); + +/* +** \brief int8 Find function +** max is an integer giving the maximum number of indices to return. (use -1 to search them all) +*/ +EXTERN_AUXFUNCT void i8finda(int8 *x, int size, int8 *out, int max); + +/* +** \brief int16 Find function +** max is an integer giving the maximum number of indices to return. (use -1 to search them all) +*/ +EXTERN_AUXFUNCT void i16finda(int16 *x, int size, int16 *out, int max); + + + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/c/auxiliaryFunctions/includes/rand.h b/src/c/auxiliaryFunctions/includes/rand.h index 4716cbba..d032a124 100644 --- a/src/c/auxiliaryFunctions/includes/rand.h +++ b/src/c/auxiliaryFunctions/includes/rand.h @@ -17,6 +17,7 @@ #include "dynlib_auxiliaryfunctions.h" #include "floatComplex.h" #include "doubleComplex.h" +#include "types.h" #ifdef __cplusplus extern "C" { @@ -46,6 +47,35 @@ EXTERN_AUXFUNCT floatComplex crands(void); **/ EXTERN_AUXFUNCT doubleComplex zrands(void); + +/** + ** \brief uint8 Rand function + ** \return A random double. + **/ +EXTERN_AUXFUNCT double u8rands(void); + + +/** + ** \brief uint16 Rand function + ** \return A random double. + **/ +EXTERN_AUXFUNCT double u16rands(void); + + +/** + ** \brief int8 Rand function + ** \return A random double. + **/ +EXTERN_AUXFUNCT double i8rands(void); + + +/** + ** \brief int16 Rand function + ** \return A random double. + **/ +EXTERN_AUXFUNCT double i16rands(void); + + /** ** \brief Float Array Rand function ** \return A random float array. @@ -70,6 +100,32 @@ EXTERN_AUXFUNCT void cranda(floatComplex *out, int size); **/ EXTERN_AUXFUNCT void zranda(doubleComplex *out, int size); +/** + ** \brief uint8 Array Rand function + ** \return A random double array. + **/ +EXTERN_AUXFUNCT void u8randa(double *out, int size); + +/** + ** \brief uint16 Array Rand function + ** \return A random double array. + **/ +EXTERN_AUXFUNCT void u16randa(double *out, int size); + + +/** + ** \brief int8 Array Rand function + ** \return A random double array. + **/ +EXTERN_AUXFUNCT void i8randa(double *out, int size); + +/** + ** \brief int16 Array Rand function + ** \return A random double array. + **/ +EXTERN_AUXFUNCT void i16randa(double *out, int size); + + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/c/auxiliaryFunctions/includes/sign.h b/src/c/auxiliaryFunctions/includes/sign.h index 0f69b4b7..67f0da8b 100644 --- a/src/c/auxiliaryFunctions/includes/sign.h +++ b/src/c/auxiliaryFunctions/includes/sign.h @@ -18,6 +18,7 @@ #include "dynlib_auxiliaryfunctions.h" #include "floatComplex.h" #include "doubleComplex.h" +#include "types.h" #ifdef __cplusplus extern "C" { @@ -56,6 +57,38 @@ EXTERN_AUXFUNCT floatComplex csigns(floatComplex in); EXTERN_AUXFUNCT doubleComplex zsigns(doubleComplex in); /** + ** \brief Uint8 Sign function + ** Determine the sign of in (assume that 0 is positive). + ** \param in : the uint8 we must determine sign. + ** \return -1 or +1 depending on the sign of in. + **/ +EXTERN_AUXFUNCT int8 u8signs(uint8 in); + +/** + ** \brief Int8 Sign function + ** Determine the sign of in (assume that 0 is positive). + ** \param in : the int8 we must determine sign. + ** \return -1 or +1 depending on the sign of in. + **/ +EXTERN_AUXFUNCT int8 i8signs(int8 in); + +/** + ** \brief Uint16 Sign function + ** Determine the sign of in (assume that 0 is positive). + ** \param in : the uint16 we must determine sign. + ** \return -1 or +1 depending on the sign of in. + **/ +EXTERN_AUXFUNCT int16 u16signs(uint16 in); + +/** + ** \brief Int16 Sign function + ** Determine the sign of in (assume that 0 is positive). + ** \param in : the uint16 we must determine sign. + ** \return -1 or +1 depending on the sign of in. + **/ +EXTERN_AUXFUNCT int16 i16signs(int16 in); + +/** ** \brief Float Signe Array function ** Determine the sign of an array in (assume that 0 is positive). ** \param in : the float array we must determine sign. @@ -91,6 +124,43 @@ EXTERN_AUXFUNCT void csigna(floatComplex *in, int size, floatComplex *out); **/ EXTERN_AUXFUNCT void zsigna(doubleComplex *in, int size, doubleComplex *out); +/** + ** \brief Uint8 Sign Array function + ** Determine the sign of an array in (assume that 0 is positive). + ** \param in : the uint8 array we must determine sign. + ** \param size : the number of elements. + ** \return -1 or +1 depending on the sign of in elements. + **/ +EXTERN_AUXFUNCT void u8signa(uint8 *in, int size, int8 *out); + +/** + ** \brief Int8 Sign Array function + ** Determine the sign of an array in (assume that 0 is positive). + ** \param in : the int8 array we must determine sign. + ** \param size : the number of elements. + ** \return -1 or +1 depending on the sign of in elements. + **/ +EXTERN_AUXFUNCT void i8signa(int8 *in, int size, int8 *out); + +/** + ** \brief Uint16 Sign Array function + ** Determine the sign of an array in (assume that 0 is positive). + ** \param in : the uint16 array we must determine sign. + ** \param size : the number of elements. + ** \return -1 or +1 depending on the sign of in elements. + **/ +EXTERN_AUXFUNCT void u16signa(uint16 *in, int size, int16 *out); + +/** + ** \brief Int16 Sign Array function + ** Determine the sign of an array in (assume that 0 is positive). + ** \param in : the int16 array we must determine sign. + ** \param size : the number of elements. + ** \return -1 or +1 depending on the sign of in elements. + **/ +EXTERN_AUXFUNCT void i16signa(int16 *in, int size, int16 *out); + + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/c/auxiliaryFunctions/interfaces/int_abs.h b/src/c/auxiliaryFunctions/interfaces/int_abs.h index 4c353fee..70a428c2 100644 --- a/src/c/auxiliaryFunctions/interfaces/int_abs.h +++ b/src/c/auxiliaryFunctions/interfaces/int_abs.h @@ -23,6 +23,14 @@ #define z0absd0(in) zabss(in) +#define u80absu80(in) u8abss(in) + +#define i80absi80(in) i8abss(in) + +#define u160absu160(in) u16abss(in) + +#define i160absi160(in) i16abss(in) + #define s2abss2(in,size,out) sabsa(in, size[0]*size[1], out) #define d2absd2(in,size,out) dabsa(in, size[0]*size[1], out) @@ -31,4 +39,12 @@ #define z2absd2(in,size,out) zabsa(in, size[0]*size[1], out) +#define u82absu82(in,size,out) u8absa(in, size[0]*size[1], out) + +#define i82absi82(in,size,out) i8absa(in, size[0]*size[1], out) + +#define u162absu162(in,size,out) u16absa(in, size[0]*size[1], out) + +#define i162absi162(in,size,out) i16absa(in, size[0]*size[1], out) + #endif /* !__INT_ABS_H__ */ diff --git a/src/c/auxiliaryFunctions/interfaces/int_conj.h b/src/c/auxiliaryFunctions/interfaces/int_conj.h index f54de243..7884c99f 100644 --- a/src/c/auxiliaryFunctions/interfaces/int_conj.h +++ b/src/c/auxiliaryFunctions/interfaces/int_conj.h @@ -15,7 +15,7 @@ #ifndef __INT_CONJ_H__ #define __INT_CONJ_H__ -#define copy(in,size,out) {int i;for (i=0; i<size[0]*size[1];i++) out[i]=in[i];} +#define copy_c(in,size,out) {int i;for (i=0; i<size[0]*size[1];i++) out[i]=in[i];} #define s0conjs0(in) in @@ -25,12 +25,28 @@ #define z0conjz0(in) zconjs(in) -#define s2conjs2(in,size,out) copy(in,size,out) +#define u80conju80(in) in -#define d2conjd2(in,size,out) copy(in,size,out) +#define i80conji80(in) in + +#define u160conju160(in) in + +#define i160conji160(in) in + +#define s2conjs2(in,size,out) copy_c(in,size,out) + +#define d2conjd2(in,size,out) copy_c(in,size,out) #define c2conjc2(in,size,out) cconja(in, size[0]*size[1], out) #define z2conjz2(in,size,out) zconja(in, size[0]*size[1], out) +#define u82conju82(in,size,out) copy_c(in,size,out) + +#define i82conji82(in,size,out) copy_c(in,size,out) + +#define u162conju162(in,size,out) copy_c(in,size,out) + +#define i162conji162(in,size,out) copy_c(in,size,out) + #endif /* !__INT_CONJ_H__ */ diff --git a/src/c/auxiliaryFunctions/interfaces/int_find.h b/src/c/auxiliaryFunctions/interfaces/int_find.h index 891aad7e..ec1e1575 100644 --- a/src/c/auxiliaryFunctions/interfaces/int_find.h +++ b/src/c/auxiliaryFunctions/interfaces/int_find.h @@ -25,6 +25,14 @@ #define z0findd0(in) ((zreals(in) == 0) && (zimags(in) == 0)) ? -1 : 1 +#define u80findu80(in) (in == 0) ? -1 : 1 + +#define u160findu160(in) (in == 0) ? -1 : 1 + +#define i80findi80(in) (in == 0) ? -1 : 1 + +#define i160findi160(in) (in == 0) ? -1 : 1 + #define s2finds2(in,size,out) sfinda(in, size[0]*size[1], out, -1) #define d2findd2(in,size,out) dfinda(in, size[0]*size[1], out, -1) @@ -33,6 +41,14 @@ #define z2findd2(in,size,out) zfinda(in, size[0]*size[1], out, -1) +#define u82findu82(in,size,out) u8finda(in,size[0]*size[1],out, -1) + +#define u162findu162(in,size,out) u16finda(in,size[0]*size[1],out, -1) + +#define i82findi82(in,size,out) i8finda(in,size[0]*size[1],out, -1) + +#define i162findi162(in,size,out) i16finda(in,size[0]*size[1],out, -1) + /* 1 input, 2 outputs */ #define s0finds0s0(in,out2) *out2 = s0finds0(in);s0finds0(in) @@ -43,10 +59,18 @@ #define z0findd0d0(in,out2) if ((zreals(in)==0) && (zimags(in)==0)) {out2=0;} else {out2=1;} +#define u80findu80u80(in,out2) *out2 = u80findu80(in);u80findu80(in) + +#define u160findu160u160(in,out2) *out2 = u160findu160(in);u160findu160(in) + +#define i80findi80i80(in,out2) *out2 = i80findi80(in);i80findi80(in) + +#define i160findi160i160(in,out2) *out2 = i160findi160(in);i160findi160(in) + #define s2finds2s2(in,size,out1,sizeOut1,out2,sizeOut2) sfind2da(in,size[0],size[1],out1,sizeOut1,out2,sizeOut2,-1) -#define d2findd2d2(in,size,out1,out2) dfind2da(in,size[0],size[1],out1,out2,-1) +#define d2findd2d2(in,size,out1,out2) dfind2da(in,size[0],size[1],out1,out2,-1) #define c2finds2s2(in,size,out1,sizeOut1,out2,sizeOut2) cfind2da(in,size[0],size[1],out1,sizeOut1,out2,sizeOut2,-1) @@ -62,6 +86,14 @@ #define z0d0findd0(in1,in2) z0findd0(in1) +#define u80u80findu80(in1,in2) u80findu80(in1) + +#define u160u160findu160(in1,in2) u160findu160(in1) + +#define i80i80findi80(in1,in2) i80findi80(in1) + +#define i160i160findi160(in1,in2) i160findi160(in1) + #define s2s0finds2(in1,size,in2,out) {\ int temp_out_indice[2] = {0} ;\ sfinda(in1,size[0]*size[1],out,in2);\ @@ -82,6 +114,25 @@ zfinda(in1,size[0]*size[1],out,in2);\ } +#define u82u80findu82(in1,size,in2,out) {\ + int temp_out_indice[2] = {0};\ + u8finda(in1,size[0]*size[1],out,in2);\ +} + +#define u162u160findu162(in1,size,in2,out) {\ + int temp_out_indice[2] = {0};\ + u16finda(in1,size[0]*size[1],out,in2);\ +} + +#define i82i80findi82(in1,size,in2,out) {\ + int temp_out_indice[2] = {0};\ + i8finda(in1,size[0]*size[1],out,in2);\ +} + +#define i162i160findi162(in1,size,in2,out) {\ + int temp_out_indice[2] = {0};\ + i16finda(in1,size[0]*size[1],out,in2);\ +} /* 2 inputs, 2 outputs */ #define s0s0finds0s0(in1,in2,out1,out2) s0finds0s0(in1,out1,out2) @@ -92,6 +143,14 @@ #define z0d0findd0d0(in1,in2,out1,out2) z0findd0d0(in1,out1,out2) +#define u80u80findu80u80(in1,in2,out1,out2) u80findu80u80(in1,out1,out2) + +#define u160u160findu160u160(in1,in2,out1,out2) u160findu160u160(in1,out1,out2) + +#define i80i80findi80i80(in1,in2,out1,out2) i80findi80i80(in1,out1,out2) + +#define i160i60findi60i60(in1,in2,out1,out2) i60findi60i60(in1,out1,out2) + /*FIXME : prototypes are wrong*/ #define s2s0finds2s2(in1,size,in2,out1,out2) {\ diff --git a/src/c/auxiliaryFunctions/interfaces/int_rand.h b/src/c/auxiliaryFunctions/interfaces/int_rand.h index 597309a4..85d08eae 100644 --- a/src/c/auxiliaryFunctions/interfaces/int_rand.h +++ b/src/c/auxiliaryFunctions/interfaces/int_rand.h @@ -20,6 +20,14 @@ #define randd0() drands() +#define randu80() u8rands() + +#define randu160() u16rands() + +#define randi80() i8rands() + +#define randi160() i16rands() + #define s0rands0(in) srands() @@ -30,16 +38,39 @@ #define z0randz0(in) zrands() +#define u80randd0(in) u8rands() + +#define u160randd0(in) u16rands() + +#define i80randd0(in) i8rands() + +#define i160randd0(in) i16rands() + #define s0s0rands0(in1,in2) srands() #define d0d0randd0(in,in2) drands() +#define u80u80randd0(in1,in2) u8rands() + +#define u160u160randd0(in1,in2) u16rands() + +#define i80i80randd0(in1,in2) i8rands() + +#define i160i160randd0(in1,in2) i16rands() + #define s0s0rands2(in1,in2,out) sranda(out,(int)in1*(int)in2) #define d0d0randd2(in1,in2,out) dranda(out,(int)in1*(int)in2) +#define u80u80randd2(in1,in2,out) u8randa(out,(int)in1*(int)in2) + +#define u160u160randd2(in1,in2,out) u16randa(out,(int)in1*(int)in2) + +#define i80i80randd2(in1,in2,out) i8randa(out,(int)in1*(int)in2) + +#define i160i160randd2(in1,in2,out) i16randa(out,(int)in1*(int)in2) #define s2rands2(in,size,out) sranda(out, size[0]*size[1]) @@ -49,5 +80,15 @@ #define z2randz2(in,size,out) zranda(out, size[0]*size[1]) +#define u82randd2(in,size,out) u8randa(out, size[0]*size[1]) + +#define u162randd2(in,size,out) u16randa(out, size[0]*size[1]) + +#define i82randd2(in,size,out) i8randa(out, size[0]*size[1]) + +#define i62randd2(in,size,out) i16randa(out, size[0]*size[1]) + + + #endif /* !__INT_RAND_H__ */ diff --git a/src/c/auxiliaryFunctions/interfaces/int_sign.h b/src/c/auxiliaryFunctions/interfaces/int_sign.h index 4463901a..1003fe73 100644 --- a/src/c/auxiliaryFunctions/interfaces/int_sign.h +++ b/src/c/auxiliaryFunctions/interfaces/int_sign.h @@ -23,6 +23,14 @@ #define z0signz0(in) zsigns(in) +#define u80signi80(in) u8signs(in) + +#define i80signi80(in) i8signs(in) + +#define u160signi160(in) u16signs(in) + +#define i160signi160(in) i16signs(in) + #define s2signs2(in,size,out) ssigna(in, size[0]*size[1], out) #define d2signd2(in,size,out) dsigna(in, size[0]*size[1], out) @@ -31,4 +39,12 @@ #define z2signz2(in,size,out) zsigna(in, size[0]*size[1], out) +#define u82signi82(in,size,out) u8signa(in, size[0]*size[1], out) + +#define i82signi82(in,size,out) i8signa(in, size[0]*size[1], out) + +#define u162signi162(in,size,out) u16signa(in, size[0]*size[1], out) + +#define i162signi162(in,size,out) i16signa(in, size[0]*size[1], out) + #endif /* !__INT_SIGN_H__ */ diff --git a/src/c/auxiliaryFunctions/isnan/cisnans.c b/src/c/auxiliaryFunctions/isnan/cisnans.c index 7fc0759f..623cea0b 100644 --- a/src/c/auxiliaryFunctions/isnan/cisnans.c +++ b/src/c/auxiliaryFunctions/isnan/cisnans.c @@ -10,14 +10,11 @@ * */ +#ifdef _WIN32 +#include <math.h> +#endif - -#ifdef _MSC_VER -#include <float.h> -#define isnan(x) _isnan((double)x)
-#endif
-
-#include "isnan.h"
+#include "isnan.h" float cisnans(floatComplex in) { diff --git a/src/c/auxiliaryFunctions/isnan/disnans.c b/src/c/auxiliaryFunctions/isnan/disnans.c index 0d0a5699..99b5b664 100644 --- a/src/c/auxiliaryFunctions/isnan/disnans.c +++ b/src/c/auxiliaryFunctions/isnan/disnans.c @@ -10,10 +10,10 @@ * */ -#ifdef _MSC_VER -#include <float.h> -#define isnan(x) _isnan((double)x)
-#endif + +#ifdef _WIN32 +#include <math.h> +#endif #include "isnan.h" diff --git a/src/c/auxiliaryFunctions/isnan/sisnans.c b/src/c/auxiliaryFunctions/isnan/sisnans.c index 201fd31a..905890b8 100644 --- a/src/c/auxiliaryFunctions/isnan/sisnans.c +++ b/src/c/auxiliaryFunctions/isnan/sisnans.c @@ -10,10 +10,10 @@ *
*/
-#ifdef _MSC_VER
-#include <float.h>
-#define isnan(x) _isnan((double)x)
-#endif
+
+#ifdef _WIN32
+#include <math.h>
+#endif
#include "isnan.h"
diff --git a/src/c/auxiliaryFunctions/isnan/zisnans.c b/src/c/auxiliaryFunctions/isnan/zisnans.c index b7ebc1bb..95cfd972 100644 --- a/src/c/auxiliaryFunctions/isnan/zisnans.c +++ b/src/c/auxiliaryFunctions/isnan/zisnans.c @@ -10,10 +10,9 @@ * */ -#ifdef _MSC_VER -#include <float.h> -#define isnan(x) _isnan((double)x)
-#endif +#ifdef _WIN32 +#include <math.h> +#endif #include "isnan.h" diff --git a/src/c/auxiliaryFunctions/rand/dranda.c b/src/c/auxiliaryFunctions/rand/dranda.c index f4678279..3defc264 100644 --- a/src/c/auxiliaryFunctions/rand/dranda.c +++ b/src/c/auxiliaryFunctions/rand/dranda.c @@ -16,5 +16,5 @@ void dranda(double *out, int size) { int i = 0; for (i = 0 ; i < size ; ++i) { out[i] = drands(); - } + } } diff --git a/src/c/auxiliaryFunctions/rand/drands.c b/src/c/auxiliaryFunctions/rand/drands.c index 9b7c4cf4..658cd0b0 100644 --- a/src/c/auxiliaryFunctions/rand/drands.c +++ b/src/c/auxiliaryFunctions/rand/drands.c @@ -34,37 +34,60 @@ double drands(void) { if (m2==0){ /* if first entry, compute machine integer word length */ - while (m>m2){ + while (m>m2){ m2=m; m=itwo*m2; + } + halfm = m2; - - /* compute multiplier and increment for linear congruential method */ + + /* compute multiplier and increment for linear congruential method */ ia = 8*(int)(halfm*atan(1.0)/8.0) + 5; - ic = 2*(int)(halfm*(0.5-sqrt(3.0)/6.0)) + 1; - mic = (m2 - ic) + m2; - - /* s is the scale factor for converting to floating point */ + + ic = 2*(int)(halfm*(0.5-sqrt(3.0)/6.0)) + 1; + + mic = (m2 - ic) + m2; + + /* s is the scale factor for converting to floating point */ s = 0.5/halfm; + + } /* compute next random number */ iy = iy*ia; + + /* the following statement is for computers which do not allow integer overflow on addition */ - if (iy > mic) iy = (iy - m2) - m2; + if (iy > mic) + { + iy = (iy - m2) - m2; + + } iy = iy + ic; /* the following statement is for computers where the word length for addition is greater than for multiplication */ - if (iy/2 > m2) iy = (iy - m2) - m2; + if (iy/2 > m2) + { + iy = (iy - m2) - m2; + + } /* the following statement is for computers where integer overflow affects the sign bit */ - if (iy < 0) iy = (iy + m2) + m2; + if (iy < 0) + { + iy = (iy + m2) + m2; + + + } + + return (double)iy*s; } diff --git a/src/c/auxiliaryFunctions/rand/i16randa.c b/src/c/auxiliaryFunctions/rand/i16randa.c new file mode 100644 index 00000000..b6aa741d --- /dev/null +++ b/src/c/auxiliaryFunctions/rand/i16randa.c @@ -0,0 +1,23 @@ +/* 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: Mushir + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include "rand.h" + +void i16randa(double *out,int size) +{ + int i = 0; + for(i = 0 ; i < size ; ++i) + { + out[i] = i16rands(); + } + +} diff --git a/src/c/auxiliaryFunctions/rand/i16rands.c b/src/c/auxiliaryFunctions/rand/i16rands.c new file mode 100644 index 00000000..67173d23 --- /dev/null +++ b/src/c/auxiliaryFunctions/rand/i16rands.c @@ -0,0 +1,57 @@ +/* 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: Mushir + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include "rand.h" +#include <stdio.h> + +double i16rands(void) +{ + +int m=1; +const int itwo=2; +static int m2=0,halfm=0,ia=0,ic=0,mic=0,iy=0; +static double s=0.0; +if(m2==0) +{ + /*if first entry,compute machine integer word length*/ + while(m>m2) + { + m2=m; + m=itwo*m2; + } + halfm = m2; + /* compute multiplier and increment for linear congruential methos */ + ia = 8*(int)(halfm*atan(1.0)/8.0) + 5; + ic = 2*(int)(halfm*(0.5-sqrt(3.0)/6.0)) +1; + mic = (m2 - ic) + m2; + /* s is the scale factor for converting to floating point*/ + s = 0.5/halfm; + +} + +/* compute next random number */ + iy = iy*ia; +/* the following statement is for computers which do not allow interger overflow on addition*/ +if(iy > mic) iy = (iy - m2) - m2; + iy = iy + ic; + + /* the following statement is for computers where the word length for addition is greater than for multiplication */ + if(iy/2 > m2) iy = (iy - m2) - m2; + /* the following statement is for computers where integer overflow affects the sign bit */ + if(iy < 0) iy = (iy + m2) + m2; + return (double)iy*s; + + + + + +} diff --git a/src/c/auxiliaryFunctions/rand/i8randa.c b/src/c/auxiliaryFunctions/rand/i8randa.c new file mode 100644 index 00000000..68d3ff3b --- /dev/null +++ b/src/c/auxiliaryFunctions/rand/i8randa.c @@ -0,0 +1,23 @@ +/* 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: Mushir + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include "rand.h" + +void i8randa(double *out,int size) +{ + int i = 0; + for(i = 0 ; i < size ; ++i) + { + out[i] = i8rands(); + } + +} diff --git a/src/c/auxiliaryFunctions/rand/i8rands.c b/src/c/auxiliaryFunctions/rand/i8rands.c new file mode 100644 index 00000000..e9b30a33 --- /dev/null +++ b/src/c/auxiliaryFunctions/rand/i8rands.c @@ -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: Mushir + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include "rand.h" +#include <stdio.h> + +double i8rands(void) +{ + +int m=1; +const int itwo=2; +static int m2=0,halfm=0,ia=0,ic=0,mic=0,iy=0; +static double s=0.0; +if(m2==0) +{ + /*if first entry,compute machine integer word length*/ + while(m>m2) + { + m2=m; + m=itwo*m2; + } + halfm = m2; + /* compute multiplier and increment for linear congruential methos */ + ia = 8*(int)(halfm*atan(1.0)/8.0) + 5; + ic = 2*(int)(halfm*(0.5-sqrt(3.0)/6.0)) +1; + mic = (m2 - ic) + m2; + /* s is the scale factor for converting to floating point*/ + s = 0.5/halfm; + +} + +/* compute next random number */ + iy = iy*ia; +/* the following statement is for computers which do not allow interger overflow on addition*/ +if(iy > mic) iy = (iy - m2) - m2; + iy = iy + ic; + + /* the following statement is for computers where the word length for addition is greater than for multiplication */ + if(iy/2 > m2) iy = (iy - m2) - m2; + /* the following statement is for computers where integer overflow affects the sign bit */ + if(iy < 0) iy = (iy + m2) + m2; + return (double)iy*s; + +} diff --git a/src/c/auxiliaryFunctions/rand/u16randa.c b/src/c/auxiliaryFunctions/rand/u16randa.c new file mode 100644 index 00000000..cfcfb50f --- /dev/null +++ b/src/c/auxiliaryFunctions/rand/u16randa.c @@ -0,0 +1,23 @@ +/* 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: Mushir + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include "rand.h" + +void u16randa(double *out,int size) +{ + int i = 0; + for(i = 0 ; i < size ; ++i) + { + out[i] = u16rands(); + } + +} diff --git a/src/c/auxiliaryFunctions/rand/u16rands.c b/src/c/auxiliaryFunctions/rand/u16rands.c new file mode 100644 index 00000000..2023be4a --- /dev/null +++ b/src/c/auxiliaryFunctions/rand/u16rands.c @@ -0,0 +1,57 @@ +/* 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: Mushir + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include "rand.h" +#include <stdio.h> + +double u16rands(void) +{ + +int m=1; +const int itwo=2; +static int m2=0,halfm=0,ia=0,ic=0,mic=0,iy=0; +static double s=0; +if(m2==0) +{ + /*if first entry,compute machine integer word length*/ + while(m>m2) + { + m2=m; + m=itwo*m2; + } + halfm = m2; + /* compute multiplier and increment for linear congruential methos */ + ia = 8*(int)(halfm*atan(1.0)/8.0) + 5; + ic = 2*(int)(halfm*(0.5-sqrt(3.0)/6.0)) +1; + mic = (m2 - ic) + m2; + /* s is the scale factor for converting to floating point*/ + s = 0.5/halfm; + +} + +/* compute next random number */ + iy = iy*ia; +/* the following statement is for computers which do not allow interger overflow on addition*/ +if(iy > mic) iy = (iy - m2) - m2; + iy = iy + ic; + + /* the following statement is for computers where the word length for addition is greater than for multiplication */ + if(iy/2 > m2) iy = (iy - m2) - m2; + /* the following statement is for computers where integer overflow affects the sign bit */ + if(iy < 0) iy = (iy + m2) + m2; + return (double)iy*s; + + + +} + + diff --git a/src/c/auxiliaryFunctions/rand/u8randa.c b/src/c/auxiliaryFunctions/rand/u8randa.c new file mode 100644 index 00000000..a7fc5836 --- /dev/null +++ b/src/c/auxiliaryFunctions/rand/u8randa.c @@ -0,0 +1,26 @@ +/* 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: Mushir + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include "rand.h" +#include<stdio.h> +void u8randa(double *out,int size) +{ + + int i = 0; + + for(i = 0 ; i < size ; ++i) + { + out[i] = u8rands(); + + } + +} diff --git a/src/c/auxiliaryFunctions/rand/u8rands.c b/src/c/auxiliaryFunctions/rand/u8rands.c new file mode 100644 index 00000000..d03741a4 --- /dev/null +++ b/src/c/auxiliaryFunctions/rand/u8rands.c @@ -0,0 +1,79 @@ +/* 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: Mushir + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include "rand.h" +#include <stdio.h> + +double u8rands(void) +{ + +int m=1; +const int itwo=2; +static int m2=0,halfm=0,ia=0,ic=0,mic=0,iy=0; +static double s=0.0; +if(m2==0) +{ + /*if first entry,compute machine integer word length*/ + + while(m>m2) + { + + m2=m; + + m=itwo*m2; + + } + + halfm = m2; + /* compute multiplier and increment for linear congruential methos */ + ia = 8*(int)(halfm*atan(1.0)/8.0) + 5; + ic = 2*(int)(halfm*(0.5-sqrt(3.0)/6.0)) +1; + + mic = (m2 - ic) + m2; + + /* s is the scale factor for converting to floating point*/ + s = 0.5/halfm; + + +} + +/* compute next random number */ + iy = iy*ia; + +/* the following statement is for computers which do not allow interger overflow on addition*/ +if(iy > mic) +{ + iy = (iy - m2) - m2; + +} + iy = iy + ic; + + /* the following statement is for computers where the word length for addition is greater than for multiplication */ + if(iy/2 > m2) +{ + iy = (iy - m2) - m2; + +} + /* the following statement is for computers where integer overflow affects the sign bit */ + if(iy < 0) + { + iy = (iy + m2) + m2; + + } + + return (double)iy*s; + + + + + +} diff --git a/src/c/auxiliaryFunctions/sign/i16signa.c b/src/c/auxiliaryFunctions/sign/i16signa.c new file mode 100644 index 00000000..a2b61823 --- /dev/null +++ b/src/c/auxiliaryFunctions/sign/i16signa.c @@ -0,0 +1,22 @@ +/* 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 +*/ + + +#include "sign.h" + +void i16signa(int16 *in, int size, int16 *out) { + int i = 0; + + for (i = 0 ; i < size ; ++i) { + out[i] = i16signs(in[i]); + } +} diff --git a/src/c/auxiliaryFunctions/sign/i16signs.c b/src/c/auxiliaryFunctions/sign/i16signs.c new file mode 100644 index 00000000..b6e70a8a --- /dev/null +++ b/src/c/auxiliaryFunctions/sign/i16signs.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: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "sign.h" + +int16 i16signs(int16 num) { + if (num > 0) { + return (int16)1; + } + if (num < 0) { + return (int16)-1; + } + /* num == 0 */ + return (int16)0; +} diff --git a/src/c/auxiliaryFunctions/sign/i8signa.c b/src/c/auxiliaryFunctions/sign/i8signa.c new file mode 100644 index 00000000..3390b042 --- /dev/null +++ b/src/c/auxiliaryFunctions/sign/i8signa.c @@ -0,0 +1,22 @@ +/* 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 +*/ + + +#include "sign.h" + +void i8signa(int8 *in, int size, int8 *out) { + int i = 0; + + for (i = 0 ; i < size ; ++i) { + out[i] = i8signs(in[i]); + } +} diff --git a/src/c/auxiliaryFunctions/sign/i8signs.c b/src/c/auxiliaryFunctions/sign/i8signs.c new file mode 100644 index 00000000..4bbefeb3 --- /dev/null +++ b/src/c/auxiliaryFunctions/sign/i8signs.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: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "sign.h" + +int8 i8signs(int8 num) { + if (num > 0) { + return (int8)1; + } + if (num < 0) { + return (int8)-1; + } + /* num == 0 */ + return (int8)0; +} diff --git a/src/c/auxiliaryFunctions/sign/u16signa.c b/src/c/auxiliaryFunctions/sign/u16signa.c new file mode 100644 index 00000000..b962ee2d --- /dev/null +++ b/src/c/auxiliaryFunctions/sign/u16signa.c @@ -0,0 +1,22 @@ +/* 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 +*/ + + +#include "sign.h" + +void u16signa(uint16 *in, int size, int16 *out) { + int i = 0; + + for (i = 0 ; i < size ; ++i) { + out[i] = u16signs(in[i]); + } +} diff --git a/src/c/auxiliaryFunctions/sign/u16signs.c b/src/c/auxiliaryFunctions/sign/u16signs.c new file mode 100644 index 00000000..d04d19cd --- /dev/null +++ b/src/c/auxiliaryFunctions/sign/u16signs.c @@ -0,0 +1,24 @@ +/* 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 +*/ + +#include "sign.h" + +int16 u16signs(uint16 num) { + if (num > 0) { + return (int16)1; + } + if (num < 0) { + return (int16)-1; + } + /* num == 0 */ + return (int16)0; +} diff --git a/src/c/auxiliaryFunctions/sign/u8signa.c b/src/c/auxiliaryFunctions/sign/u8signa.c new file mode 100644 index 00000000..980931ec --- /dev/null +++ b/src/c/auxiliaryFunctions/sign/u8signa.c @@ -0,0 +1,22 @@ +/* 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 +*/ + + +#include "sign.h" + +void u8signa(uint8 *in, int size, int8 *out) { + int i = 0; + + for (i = 0 ; i < size ; ++i) { + out[i] = u8signs(in[i]); + } +} diff --git a/src/c/auxiliaryFunctions/sign/u8signs.c b/src/c/auxiliaryFunctions/sign/u8signs.c new file mode 100644 index 00000000..69d766b0 --- /dev/null +++ b/src/c/auxiliaryFunctions/sign/u8signs.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: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "sign.h" + +int8 u8signs(uint8 num) { + if (num > 0) { + return (int8)1; + } + if (num < 0) { + return (int8)-1; + } + /* num == 0 */ + return (int8)0; +} |