summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/elementaryFunctions
diff options
context:
space:
mode:
Diffstat (limited to '2.3-1/src/c/elementaryFunctions')
-rw-r--r--2.3-1/src/c/elementaryFunctions/Trigonometry/sinc/dsinca.c46
-rw-r--r--2.3-1/src/c/elementaryFunctions/Trigonometry/sinc/int_sinc.h18
-rw-r--r--2.3-1/src/c/elementaryFunctions/Trigonometry/sinc/sinc.h27
-rw-r--r--2.3-1/src/c/elementaryFunctions/Trigonometry/sinc/zsinca.c31
-rw-r--r--2.3-1/src/c/elementaryFunctions/discrete_mathematics/gcd/u8gcda.c60
-rw-r--r--2.3-1/src/c/elementaryFunctions/discrete_mathematics/lcm/u8lcma.c68
-rw-r--r--2.3-1/src/c/elementaryFunctions/includes/gcd.h26
-rw-r--r--2.3-1/src/c/elementaryFunctions/includes/lcm.h27
-rw-r--r--2.3-1/src/c/elementaryFunctions/includes/sinc.h29
-rw-r--r--2.3-1/src/c/elementaryFunctions/interfaces/int_gcd.h25
-rw-r--r--2.3-1/src/c/elementaryFunctions/interfaces/int_lcm.h27
-rw-r--r--2.3-1/src/c/elementaryFunctions/interfaces/int_sinc.h19
12 files changed, 403 insertions, 0 deletions
diff --git a/2.3-1/src/c/elementaryFunctions/Trigonometry/sinc/dsinca.c b/2.3-1/src/c/elementaryFunctions/Trigonometry/sinc/dsinca.c
new file mode 100644
index 00000000..0cd24e96
--- /dev/null
+++ b/2.3-1/src/c/elementaryFunctions/Trigonometry/sinc/dsinca.c
@@ -0,0 +1,46 @@
+/* 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: Ankit Raj
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+#include<stdio.h>
+#include<math.h>
+#include "sinc.h"
+#define PI 3.14159265358979
+void dsinca(double* sample,int size,double* oup)
+{
+ int j;
+ for(j=0;j<size;j++)
+ {
+ if(sample[j]==0)
+ {
+ oup[j]=1;
+ }
+ else
+ {
+ oup[j]=(sin(sample[j]))/(sample[j]);
+ }
+ }
+}
+/*
+int main()
+{
+ int n;
+ printf("Enter the length of the array");
+ scanf("%d",&n);
+ double arr[100000];
+ int i;
+ printf("Now enter the element of the array");
+ for(i=0;i<n;i++)
+ {
+ scanf("%ld",&arr[i]);
+ }
+ sinc(arr[],n);
+}
+*/
diff --git a/2.3-1/src/c/elementaryFunctions/Trigonometry/sinc/int_sinc.h b/2.3-1/src/c/elementaryFunctions/Trigonometry/sinc/int_sinc.h
new file mode 100644
index 00000000..0dc969de
--- /dev/null
+++ b/2.3-1/src/c/elementaryFunctions/Trigonometry/sinc/int_sinc.h
@@ -0,0 +1,18 @@
+/* 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: Ankit Raj
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+
+#ifndef __INT_SINC_H__
+#define __INT_SINC_H__
+
+#define d2sincd2(sample,size,oup) dsinca(sample,size,oup)
+
+#endif /* !__INT_SINC_H__! */
diff --git a/2.3-1/src/c/elementaryFunctions/Trigonometry/sinc/sinc.h b/2.3-1/src/c/elementaryFunctions/Trigonometry/sinc/sinc.h
new file mode 100644
index 00000000..6a5c315b
--- /dev/null
+++ b/2.3-1/src/c/elementaryFunctions/Trigonometry/sinc/sinc.h
@@ -0,0 +1,27 @@
+/* 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: Ankit Raj
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+
+#ifndef __SINC_H__
+#define __SINC_H__
+#include "types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void dsinca(double* sample,int size,double* oup);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* __SINC_H__ */
diff --git a/2.3-1/src/c/elementaryFunctions/Trigonometry/sinc/zsinca.c b/2.3-1/src/c/elementaryFunctions/Trigonometry/sinc/zsinca.c
new file mode 100644
index 00000000..ad7d095b
--- /dev/null
+++ b/2.3-1/src/c/elementaryFunctions/Trigonometry/sinc/zsinca.c
@@ -0,0 +1,31 @@
+/* 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: Ankit Raj
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+#include<stdio.h>
+#include<math.h>
+#include "sinc.h"
+#include "sin.h"
+#include "doubleComplex.h"
+void zsinca(doubleComplex* sample,int size,doubleComplex* oup)
+{
+ int j;
+ for(j=0;j<size;j++)
+ {
+ if(sample[j]==0)
+ {
+ oup[j]==DoubleComplex(1,0);
+ }
+ else
+ {
+ oup[j]=zsins(sample[j])/sample[j];
+ }
+ }
+}
diff --git a/2.3-1/src/c/elementaryFunctions/discrete_mathematics/gcd/u8gcda.c b/2.3-1/src/c/elementaryFunctions/discrete_mathematics/gcd/u8gcda.c
new file mode 100644
index 00000000..3d586232
--- /dev/null
+++ b/2.3-1/src/c/elementaryFunctions/discrete_mathematics/gcd/u8gcda.c
@@ -0,0 +1,60 @@
+/* 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: Ankit Raj
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+#include<stdio.h>
+/* This is the "gcd" function , which takes two input. first
+ one is the array and the second one is the length of the array.
+ Now to calculate the gcd of two elements we fin the maximum of
+ the two elements, and then iterate from maximum value down to 1,
+ and check whether the particular value divides the two elements.
+ And in this way we can calculate the gcd of the whole array.
+*/
+#include "gcd.h"
+uint8 u8gcdua(uint8* in,int size)
+{
+
+ int temp;
+ if(size==1)
+ {
+ temp=*in;
+ }
+ else
+ {
+ int x=*in;
+ int y=*(in+1);
+ int max=(x>y)?x:y;
+ for(int i=max;i>=1;i--)
+ {
+ if(x%i==0 && y%i==0)
+ {
+ temp=i;
+ break;
+ }
+ }
+ for(int j=2;j<size;j++)
+ {
+ x=temp;
+ y=*(in+j);
+ max=(x>y)?x:y;
+ for(int i=max;i>=1;i--)
+ {
+ if(x%i==0 && y%i==0)
+ {
+ temp=i;
+ break;
+ }
+ }
+ }
+}
+
+ return temp;
+}
+
diff --git a/2.3-1/src/c/elementaryFunctions/discrete_mathematics/lcm/u8lcma.c b/2.3-1/src/c/elementaryFunctions/discrete_mathematics/lcm/u8lcma.c
new file mode 100644
index 00000000..56856e43
--- /dev/null
+++ b/2.3-1/src/c/elementaryFunctions/discrete_mathematics/lcm/u8lcma.c
@@ -0,0 +1,68 @@
+/* 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: Ankit Raj
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+#include<stdio.h>
+/* This is the "lcm" function, accepting two inputs which are the array of integers
+ and second the size of the array. The algorithm works like this:
+ We take a temproary variable and store the lcm of the first two elements of the
+ array in it. Now using this temproary variable we recursively fin the lcm of
+ the whole array.
+ Now to fin the lcm of two elements we fin the maximum of the two elements and
+ check whether it is divisible by both the elements, if the condition is true we
+ get the lcm, else increase the maximum value by itself unless we get the lcm.
+*/
+#include "lcm.h"
+uint8 u8lcma(uint8* in,int size)
+{
+ long long int lcm_temp;
+ if(size==1)
+ {
+ lcm_temp=*in;
+ }
+ else
+ {
+
+ int x1=*in;
+ int x2=*(in+1);
+ long long int max=(x1>x2)?x1:x2;
+ long long int i=max;
+ while(1)
+ {
+ if(i%x1==0 && i%x2==0)
+ {
+ lcm_temp=i;
+ break;
+ }
+ else
+ i+=max;
+ }
+ for(int j=2;j<size;j++)
+ {
+ x1=lcm_temp;
+ x2=*(in+j);
+ max=(x1>x2)?x1:x2;
+ i=max;
+ while(1)
+ {
+ if(i%x1==0 && i%x2==0)
+ {
+ lcm_temp=i;
+ break;
+ }
+ else
+ i+=max;
+ }
+ }
+
+ }
+ return lcm_temp;
+}
+
diff --git a/2.3-1/src/c/elementaryFunctions/includes/gcd.h b/2.3-1/src/c/elementaryFunctions/includes/gcd.h
new file mode 100644
index 00000000..179eea0e
--- /dev/null
+++ b/2.3-1/src/c/elementaryFunctions/includes/gcd.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: Ankit Raj
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+#ifndef __GCD_H__
+#define __GCD_H__
+#include "types.h"
+
+ #ifdef __cplusplus
+ extern "C"{
+ #endif
+
+uint8 u8gcda(uint8* in,int size);
+
+ #ifdef __cplusplus
+ } /* extern "C" */
+ #endif
+
+#endif /*__GCD_H__*/
diff --git a/2.3-1/src/c/elementaryFunctions/includes/lcm.h b/2.3-1/src/c/elementaryFunctions/includes/lcm.h
new file mode 100644
index 00000000..3a3e66fb
--- /dev/null
+++ b/2.3-1/src/c/elementaryFunctions/includes/lcm.h
@@ -0,0 +1,27 @@
+/* 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: Ankit Raj
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+#ifndef __LCM_H__
+#define __LCM_H__
+#include "types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+uint8 u8lcma(uint8* in,int size);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__LCM_H__*/
+
diff --git a/2.3-1/src/c/elementaryFunctions/includes/sinc.h b/2.3-1/src/c/elementaryFunctions/includes/sinc.h
new file mode 100644
index 00000000..8bc98d28
--- /dev/null
+++ b/2.3-1/src/c/elementaryFunctions/includes/sinc.h
@@ -0,0 +1,29 @@
+/* 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: Ankit Raj
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+
+#ifndef __SINC_H__
+#define __SINC_H__
+#include "types.h"
+#include "doubleComplex.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void dsinca(double* sample,int size,double* oup);
+void zsinca(doubleComplex* sample,int size,doubleComplex* oup);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* __SINC_H__ */
diff --git a/2.3-1/src/c/elementaryFunctions/interfaces/int_gcd.h b/2.3-1/src/c/elementaryFunctions/interfaces/int_gcd.h
new file mode 100644
index 00000000..f3e117c5
--- /dev/null
+++ b/2.3-1/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: Ankit Raj
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+#ifndef __INT_GCD_H__
+#define __INT_GCD_H__
+
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+
+#define u82gcdu80(in,size) u8gcda(in,size[1])
+
+ #ifdef __cplusplus
+ } /* extern "C" */
+ #endif
+
+#endif /*__INT_GCD_H__*/
diff --git a/2.3-1/src/c/elementaryFunctions/interfaces/int_lcm.h b/2.3-1/src/c/elementaryFunctions/interfaces/int_lcm.h
new file mode 100644
index 00000000..2ef1a081
--- /dev/null
+++ b/2.3-1/src/c/elementaryFunctions/interfaces/int_lcm.h
@@ -0,0 +1,27 @@
+/* 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: Ankit Raj
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+
+
+
+#ifndef __INT_LCM_H__
+#define __INT_LCM_H__
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+
+#define u82lcmu80(in,size) u8lcma(in,size[1])
+
+ #ifdef __cplusplus
+ } /* extern "C" */
+ #endif
+
+#endif /* !__INT_LCM_H__ */
diff --git a/2.3-1/src/c/elementaryFunctions/interfaces/int_sinc.h b/2.3-1/src/c/elementaryFunctions/interfaces/int_sinc.h
new file mode 100644
index 00000000..35a519db
--- /dev/null
+++ b/2.3-1/src/c/elementaryFunctions/interfaces/int_sinc.h
@@ -0,0 +1,19 @@
+/* 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: Ankit Raj
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+
+#ifndef __INT_SINC_H__
+#define __INT_SINC_H__
+
+#define d2sincd2(sample,size,oup) dsinca(sample,size[1],oup)
+#define z2sincz2(sample,size,oup) zsinca(sample,size[1],oup)
+
+#endif /* !__INT_SINC_H__! */