summaryrefslogtreecommitdiff
path: root/src/c/elementaryFunctions
diff options
context:
space:
mode:
authorsiddhu89902017-06-21 15:18:15 +0530
committersiddhu89902017-06-21 15:18:15 +0530
commitadbc46709966e50b3fed6ff061afff9e59d4b79c (patch)
treec0a375b9c280a878e451d06f9cac2e90a433165d /src/c/elementaryFunctions
parent240e5e93815eef0992834ec7bd2a8162acca13f0 (diff)
parent18f7cf96174799b674115e43f108423fa5d0fc9c (diff)
downloadScilab2C_fossee_old-adbc46709966e50b3fed6ff061afff9e59d4b79c.tar.gz
Scilab2C_fossee_old-adbc46709966e50b3fed6ff061afff9e59d4b79c.tar.bz2
Scilab2C_fossee_old-adbc46709966e50b3fed6ff061afff9e59d4b79c.zip
Merged Ukasha's work, code generation for control loop changed
Diffstat (limited to 'src/c/elementaryFunctions')
-rw-r--r--src/c/elementaryFunctions/discrete_mathematics/gcd/dgcda.c32
-rw-r--r--src/c/elementaryFunctions/discrete_mathematics/gcd/u8gcds.c32
-rw-r--r--src/c/elementaryFunctions/includes/gcd.h31
-rw-r--r--src/c/elementaryFunctions/includes/isreal.h30
-rw-r--r--src/c/elementaryFunctions/includes/nextpow2.h28
-rw-r--r--src/c/elementaryFunctions/interfaces/int_gcd.h25
-rw-r--r--src/c/elementaryFunctions/interfaces/int_isreal.h22
-rw-r--r--src/c/elementaryFunctions/interfaces/int_nextpow2.h26
-rw-r--r--src/c/elementaryFunctions/isreal/disreals.c17
-rw-r--r--src/c/elementaryFunctions/isreal/sisreals.c17
-rw-r--r--src/c/elementaryFunctions/nextpow2/dnextpow2a.c30
11 files changed, 290 insertions, 0 deletions
diff --git a/src/c/elementaryFunctions/discrete_mathematics/gcd/dgcda.c b/src/c/elementaryFunctions/discrete_mathematics/gcd/dgcda.c
new file mode 100644
index 0000000..a32ed77
--- /dev/null
+++ b/src/c/elementaryFunctions/discrete_mathematics/gcd/dgcda.c
@@ -0,0 +1,32 @@
+/* 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: Ukasha Noor
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+#include "gcd.h"
+#include "types.h"
+
+void dgcda(double *in,int size,double *out)
+{
+ double a=in[0];
+ double b=in[1];
+ while(a!=b && a!=0 && b!=0)
+ {
+ if(a>b)
+ {
+ a=a-b;
+ }
+ else
+ {
+ b=b-a;
+ }
+ }
+ out[0]=b;
+}
diff --git a/src/c/elementaryFunctions/discrete_mathematics/gcd/u8gcds.c b/src/c/elementaryFunctions/discrete_mathematics/gcd/u8gcds.c
new file mode 100644
index 0000000..75f831f
--- /dev/null
+++ b/src/c/elementaryFunctions/discrete_mathematics/gcd/u8gcds.c
@@ -0,0 +1,32 @@
+/* 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: Ukasha Noor
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+#include "gcd.h"
+#include "types.h"
+
+int8 u8gcds(int8 *in,int size)
+{
+ int a=in[0];
+ int b=in[1];
+ while(a!=b && a!=0 && b!=0)
+ {
+ if(a>b)
+ {
+ a=a-b;
+ }
+ else
+ {
+ b=b-a;
+ }
+ }
+ return b;
+}
diff --git a/src/c/elementaryFunctions/includes/gcd.h b/src/c/elementaryFunctions/includes/gcd.h
new file mode 100644
index 0000000..eb75c97
--- /dev/null
+++ b/src/c/elementaryFunctions/includes/gcd.h
@@ -0,0 +1,31 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2007-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
+ * Author: Ukasha Noor
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __GCD_H__
+#define __GCD_H__
+
+#include "types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int8 u8gcds(int8 *in,int size);
+
+void dgcda(double *in,int size,double *out);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif
diff --git a/src/c/elementaryFunctions/includes/isreal.h b/src/c/elementaryFunctions/includes/isreal.h
new file mode 100644
index 0000000..0183ebc
--- /dev/null
+++ b/src/c/elementaryFunctions/includes/isreal.h
@@ -0,0 +1,30 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2007-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 __ISREAL_H__
+#define __ISREAL_H__
+
+#include "types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+float sisreals(float a);
+
+double disreals(double a);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif
diff --git a/src/c/elementaryFunctions/includes/nextpow2.h b/src/c/elementaryFunctions/includes/nextpow2.h
new file mode 100644
index 0000000..c86bea0
--- /dev/null
+++ b/src/c/elementaryFunctions/includes/nextpow2.h
@@ -0,0 +1,28 @@
+/* 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: Ukasha Noor
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+
+#ifndef __NEXTPOW2_H__
+#define __NEXTPOW2_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void dnextpow2a(double *in,int size,double *out);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif
+
diff --git a/src/c/elementaryFunctions/interfaces/int_gcd.h b/src/c/elementaryFunctions/interfaces/int_gcd.h
new file mode 100644
index 0000000..c2135b7
--- /dev/null
+++ b/src/c/elementaryFunctions/interfaces/int_gcd.h
@@ -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: Ukasha Noor
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* THIS IS AN AUTOMATICALLY GENERATED FILE : DO NOT EDIT BY HAND. */
+
+#ifndef __INT_GCD_H__
+#define __INT_GCD_H__
+
+#include "gcd.h"
+
+#define u82gcdu80(in,size) u8gcds(in,size)
+
+#define d2gcdd2(in,size,out) dgcda(in,size[0]*size[1],out)
+
+#endif
+
diff --git a/src/c/elementaryFunctions/interfaces/int_isreal.h b/src/c/elementaryFunctions/interfaces/int_isreal.h
new file mode 100644
index 0000000..cebbf6d
--- /dev/null
+++ b/src/c/elementaryFunctions/interfaces/int_isreal.h
@@ -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: Ukasha Noor
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+
+
+#ifndef __INT_ISREAL_H__
+#define __INT_ISREAL_H__
+
+#define s0isreals0(in) sisreals(in)
+
+#define d0isreald0(in) disreals(in)
+
+#endif
diff --git a/src/c/elementaryFunctions/interfaces/int_nextpow2.h b/src/c/elementaryFunctions/interfaces/int_nextpow2.h
new file mode 100644
index 0000000..6ae4747
--- /dev/null
+++ b/src/c/elementaryFunctions/interfaces/int_nextpow2.h
@@ -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: Ukasha Noor
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* THIS IS AN AUTOMATICALLY GENERATED FILE : DO NOT EDIT BY HAND. */
+
+
+#ifndef __INT_NEXTPOW2_H__
+#define __INT_NEXTPOW2_H__
+
+
+#include "nextpow2.h"
+
+#define d0nextpow2d0(in,size,out) dnextpow2a(in,size[0]*size[1],out)
+
+#define d2nextpow2d2(in,size,out) dnextpow2a(in,size[0]*size[1],out)
+
+#endif
diff --git a/src/c/elementaryFunctions/isreal/disreals.c b/src/c/elementaryFunctions/isreal/disreals.c
new file mode 100644
index 0000000..8c7c820
--- /dev/null
+++ b/src/c/elementaryFunctions/isreal/disreals.c
@@ -0,0 +1,17 @@
+/* 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: Ukasha Noor
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+#include "isreal.h"
+
+double disreals(double a){
+ return 1;
+}
diff --git a/src/c/elementaryFunctions/isreal/sisreals.c b/src/c/elementaryFunctions/isreal/sisreals.c
new file mode 100644
index 0000000..4b93c02
--- /dev/null
+++ b/src/c/elementaryFunctions/isreal/sisreals.c
@@ -0,0 +1,17 @@
+/* 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: Ukasha Noor
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+#include "isreal.h"
+
+float sisreals(float a){
+ return 1;
+}
diff --git a/src/c/elementaryFunctions/nextpow2/dnextpow2a.c b/src/c/elementaryFunctions/nextpow2/dnextpow2a.c
new file mode 100644
index 0000000..46f7eb8
--- /dev/null
+++ b/src/c/elementaryFunctions/nextpow2/dnextpow2a.c
@@ -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
+ Organization: FOSSEE, IIT Bombay
+ Author: Ukasha Noor
+ Email: toolbox@scilab.in
+*/
+
+#include "nextpow2.h"
+#include <math.h>
+
+void dnextpow2a(double *in,int size,double *out)
+{
+ int i,j,s;
+ double k;
+ i=2;
+ for(s=0;s<size;s++)
+ {
+ j=-1;
+ do{
+ j++;
+ k=pow(i,j);
+ }while(in[s]>k);
+ out[s]=j;
+ }
+}