summaryrefslogtreecommitdiff
path: root/2.3-1/src
diff options
context:
space:
mode:
Diffstat (limited to '2.3-1/src')
-rw-r--r--2.3-1/src/c/auxiliaryFunctions/includes/rand.h56
-rw-r--r--2.3-1/src/c/auxiliaryFunctions/interfaces/int_rand.h41
-rw-r--r--2.3-1/src/c/auxiliaryFunctions/rand/i16randa.c12
-rw-r--r--2.3-1/src/c/auxiliaryFunctions/rand/i16rands.c46
-rw-r--r--2.3-1/src/c/auxiliaryFunctions/rand/i8randa.c12
-rw-r--r--2.3-1/src/c/auxiliaryFunctions/rand/i8rands.c42
-rw-r--r--2.3-1/src/c/auxiliaryFunctions/rand/u16randa.c12
-rw-r--r--2.3-1/src/c/auxiliaryFunctions/rand/u16rands.c46
-rw-r--r--2.3-1/src/c/auxiliaryFunctions/rand/u8randa.c15
-rw-r--r--2.3-1/src/c/auxiliaryFunctions/rand/u8rands.c68
-rw-r--r--2.3-1/src/c/scilab-arduino/cmd_digital_out/u8cmd_digital_outs.c1
11 files changed, 351 insertions, 0 deletions
diff --git a/2.3-1/src/c/auxiliaryFunctions/includes/rand.h b/2.3-1/src/c/auxiliaryFunctions/includes/rand.h
index 4716cbba..d032a124 100644
--- a/2.3-1/src/c/auxiliaryFunctions/includes/rand.h
+++ b/2.3-1/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/2.3-1/src/c/auxiliaryFunctions/interfaces/int_rand.h b/2.3-1/src/c/auxiliaryFunctions/interfaces/int_rand.h
index 597309a4..85d08eae 100644
--- a/2.3-1/src/c/auxiliaryFunctions/interfaces/int_rand.h
+++ b/2.3-1/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/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 <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/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 <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/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 <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/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<stdio.h>
+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 <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/2.3-1/src/c/scilab-arduino/cmd_digital_out/u8cmd_digital_outs.c b/2.3-1/src/c/scilab-arduino/cmd_digital_out/u8cmd_digital_outs.c
index 621afc80..2e5c90d3 100644
--- a/2.3-1/src/c/scilab-arduino/cmd_digital_out/u8cmd_digital_outs.c
+++ b/2.3-1/src/c/scilab-arduino/cmd_digital_out/u8cmd_digital_outs.c
@@ -11,6 +11,7 @@
*/
#include "cmd_digital_out.h"
+#include "Arduino.h"
uint8 u8cmd_digital_outs(uint8 board_no, uint8 pin, uint8 value)