From bcb2bf1c014a1078f4306cd0111f4e596fe934ce Mon Sep 17 00:00:00 2001 From: imushir Date: Mon, 18 Jan 2016 11:47:44 +0530 Subject: added support for uin8,uint16,int8,int16 and not in GeneratedSetup.sci,u8cmd_digital_outs.c,getAllInterfaces.sci,getAllHeaders.sci --- 2.3-1/src/c/auxiliaryFunctions/rand/i16randa.c | 12 +++++ 2.3-1/src/c/auxiliaryFunctions/rand/i16rands.c | 46 +++++++++++++++++ 2.3-1/src/c/auxiliaryFunctions/rand/i8randa.c | 12 +++++ 2.3-1/src/c/auxiliaryFunctions/rand/i8rands.c | 42 ++++++++++++++++ 2.3-1/src/c/auxiliaryFunctions/rand/u16randa.c | 12 +++++ 2.3-1/src/c/auxiliaryFunctions/rand/u16rands.c | 46 +++++++++++++++++ 2.3-1/src/c/auxiliaryFunctions/rand/u8randa.c | 15 ++++++ 2.3-1/src/c/auxiliaryFunctions/rand/u8rands.c | 68 ++++++++++++++++++++++++++ 8 files changed, 253 insertions(+) create mode 100644 2.3-1/src/c/auxiliaryFunctions/rand/i16randa.c create mode 100644 2.3-1/src/c/auxiliaryFunctions/rand/i16rands.c create mode 100644 2.3-1/src/c/auxiliaryFunctions/rand/i8randa.c create mode 100644 2.3-1/src/c/auxiliaryFunctions/rand/i8rands.c create mode 100644 2.3-1/src/c/auxiliaryFunctions/rand/u16randa.c create mode 100644 2.3-1/src/c/auxiliaryFunctions/rand/u16rands.c create mode 100644 2.3-1/src/c/auxiliaryFunctions/rand/u8randa.c create mode 100644 2.3-1/src/c/auxiliaryFunctions/rand/u8rands.c (limited to '2.3-1/src/c/auxiliaryFunctions/rand') diff --git a/2.3-1/src/c/auxiliaryFunctions/rand/i16randa.c b/2.3-1/src/c/auxiliaryFunctions/rand/i16randa.c new file mode 100644 index 00000000..f3d8dd37 --- /dev/null +++ b/2.3-1/src/c/auxiliaryFunctions/rand/i16randa.c @@ -0,0 +1,12 @@ +/* Scilab2C FOSSEE IIT BOMBAY */ +#include "rand.h" + +void i16randa(double *out,int size) +{ + int i = 0; + for(i = 0 ; i < size ; ++i) + { + out[i] = i16rands(); + } + +} diff --git a/2.3-1/src/c/auxiliaryFunctions/rand/i16rands.c b/2.3-1/src/c/auxiliaryFunctions/rand/i16rands.c new file mode 100644 index 00000000..ca2ed9cd --- /dev/null +++ b/2.3-1/src/c/auxiliaryFunctions/rand/i16rands.c @@ -0,0 +1,46 @@ +/* Scilab2C FOSSEE IIT Bombay */ +#include "rand.h" +#include + +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/2.3-1/src/c/auxiliaryFunctions/rand/i8randa.c b/2.3-1/src/c/auxiliaryFunctions/rand/i8randa.c new file mode 100644 index 00000000..d679c65f --- /dev/null +++ b/2.3-1/src/c/auxiliaryFunctions/rand/i8randa.c @@ -0,0 +1,12 @@ +/* Scilab2C FOSSEE IIT BOMBAY */ +#include "rand.h" + +void i8randa(double *out,int size) +{ + int i = 0; + for(i = 0 ; i < size ; ++i) + { + out[i] = i8rands(); + } + +} diff --git a/2.3-1/src/c/auxiliaryFunctions/rand/i8rands.c b/2.3-1/src/c/auxiliaryFunctions/rand/i8rands.c new file mode 100644 index 00000000..55df9093 --- /dev/null +++ b/2.3-1/src/c/auxiliaryFunctions/rand/i8rands.c @@ -0,0 +1,42 @@ +/* Scilab2C FOSSEE IIT Bombay */ +#include "rand.h" +#include + +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/2.3-1/src/c/auxiliaryFunctions/rand/u16randa.c b/2.3-1/src/c/auxiliaryFunctions/rand/u16randa.c new file mode 100644 index 00000000..f5393369 --- /dev/null +++ b/2.3-1/src/c/auxiliaryFunctions/rand/u16randa.c @@ -0,0 +1,12 @@ +/* Scilab2C FOSSEE IIT BOMBAY */ +#include "rand.h" + +void u16randa(double *out,int size) +{ + int i = 0; + for(i = 0 ; i < size ; ++i) + { + out[i] = u16rands(); + } + +} diff --git a/2.3-1/src/c/auxiliaryFunctions/rand/u16rands.c b/2.3-1/src/c/auxiliaryFunctions/rand/u16rands.c new file mode 100644 index 00000000..a08d6a8c --- /dev/null +++ b/2.3-1/src/c/auxiliaryFunctions/rand/u16rands.c @@ -0,0 +1,46 @@ +/* Scilab2C FOSSEE IIT Bombay */ +#include "rand.h" +#include + +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/2.3-1/src/c/auxiliaryFunctions/rand/u8randa.c b/2.3-1/src/c/auxiliaryFunctions/rand/u8randa.c new file mode 100644 index 00000000..4d7d3f8a --- /dev/null +++ b/2.3-1/src/c/auxiliaryFunctions/rand/u8randa.c @@ -0,0 +1,15 @@ +/* Scilab2C FOSSEE IIT BOMBAY */ +#include "rand.h" +#include +void u8randa(double *out,int size) +{ + + int i = 0; + + for(i = 0 ; i < size ; ++i) + { + out[i] = u8rands(); + + } + +} diff --git a/2.3-1/src/c/auxiliaryFunctions/rand/u8rands.c b/2.3-1/src/c/auxiliaryFunctions/rand/u8rands.c new file mode 100644 index 00000000..bdf7f9a5 --- /dev/null +++ b/2.3-1/src/c/auxiliaryFunctions/rand/u8rands.c @@ -0,0 +1,68 @@ +/* Scilab2C FOSSEE IIT Bombay */ +#include "rand.h" +#include + +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; + + + + + +} -- cgit