summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
-rw-r--r--src/c/interpolation/includes/interp1.h30
-rw-r--r--src/c/interpolation/interfaces/int_interp1.h28
-rw-r--r--src/c/interpolation/interp1/dinterp13a.c75
-rw-r--r--src/c/matrixOperations/cat/ccata.c2
-rw-r--r--src/c/matrixOperations/cat/zcata.c2
-rw-r--r--src/c/signalProcessing/includes/dct.h36
-rw-r--r--src/c/signalProcessing/includes/idct.h36
-rw-r--r--src/c/signalProcessing/includes/modk.h28
-rw-r--r--src/c/signalProcessing/interfaces/int_dct.h32
-rw-r--r--src/c/signalProcessing/interfaces/int_idct.h26
-rw-r--r--src/c/signalProcessing/interfaces/int_modk.h18
-rw-r--r--src/c/signalProcessing/modk/dmodka.c97
-rw-r--r--src/c/signalProcessing/transforms/dct/cdcta.c177
-rw-r--r--src/c/signalProcessing/transforms/dct/ddcta.c160
-rw-r--r--src/c/signalProcessing/transforms/dct/zdcta.c177
-rw-r--r--src/c/signalProcessing/transforms/idct/cidcta.c97
-rw-r--r--src/c/signalProcessing/transforms/idct/didcta.c83
-rw-r--r--src/c/signalProcessing/transforms/idct/zidcta.c97
29 files changed, 1489 insertions, 2 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;
+ }
+}
diff --git a/src/c/interpolation/includes/interp1.h b/src/c/interpolation/includes/interp1.h
new file mode 100644
index 0000000..1c01417
--- /dev/null
+++ b/src/c/interpolation/includes/interp1.h
@@ -0,0 +1,30 @@
+/* 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 __INTERP1_H__
+#define __INTERP1_H__
+
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+//void dinterp13a(double *x,double *fx,double *q,int size,double *out);
+void dinterp13a(double *x,int size1,double *fx,int size2,double *q,int size3,char *a,int size4,double *out);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif
diff --git a/src/c/interpolation/interfaces/int_interp1.h b/src/c/interpolation/interfaces/int_interp1.h
new file mode 100644
index 0000000..6d579e1
--- /dev/null
+++ b/src/c/interpolation/interfaces/int_interp1.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
+*/
+
+/* THIS IS AN AUTOMATICALLY GENERATED FILE : DO NOT EDIT BY HAND. */
+
+
+#ifndef __INT_INTERP1_H__
+#define __INT_INTERP1_H__
+
+#include "interp1.h"
+#include <string.h>
+
+#define d2d2d2interp1d2(x,size1,fx,size2,q,size3,out) dinterp13a(x,size1[0]*size1[1],fx,size2[0]*size1[1],q,size3[0]*size3[1],"linear",6,out)
+
+#define d2d2d2g2interp1d2(x,size1,fx,size2,q,size3,ch,size4,out) dinterp13a(x,size1[0]*size1[1],fx,size2[0]*size1[1],q,size3[0]*size3[1],ch,size4[0]*size4[1],out)
+
+
+#endif
+
diff --git a/src/c/interpolation/interp1/dinterp13a.c b/src/c/interpolation/interp1/dinterp13a.c
new file mode 100644
index 0000000..7b755e1
--- /dev/null
+++ b/src/c/interpolation/interp1/dinterp13a.c
@@ -0,0 +1,75 @@
+/* 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 "interp1.h"
+#include <string.h>
+
+void dinterp13a(double *x,int size1,double *fx,int size2,double *q,int size3,char *ch,int size4,double *out)
+{
+ int i,j,k,f;
+ double a,b;
+ if(strcmp(ch,"linear")==0)
+ {
+ for(i=0;i<size3;i++)
+ {
+ f=0;
+ for(j=0;j<size1;j++)
+ {
+ if(q[i]==x[j])
+ {
+ out[i]=fx[j];
+ f=1;
+ break;
+ }
+ }
+ if(f==0)
+ {
+ j=0;
+ while(q[i]>x[j])
+ {
+ j++;
+ }
+ a=x[j-1];
+ b=x[j];
+ out[i]=fx[j-1]+(q[i]-a)*((fx[j]-fx[j-1])/(b-a));
+ }
+ }
+ }
+ else if(strcmp(ch,"nearest")==0)
+ {
+ for(i=0;i<size3;i++)
+ {
+ f=0;
+ for(j=0;j<size1;j++)
+ {
+ if(q[i]==x[j])
+ {
+ out[i]=fx[j];
+ f=1;
+ break;
+ }
+ }
+ if(f==0)
+ {
+ j=0;
+ while(q[i]>x[j])
+ {
+ j++;
+ }
+ out[i]=fx[j];
+ }
+ }
+ }
+}
+
+
diff --git a/src/c/matrixOperations/cat/ccata.c b/src/c/matrixOperations/cat/ccata.c
index a6ac6cf..cd2b4c9 100644
--- a/src/c/matrixOperations/cat/ccata.c
+++ b/src/c/matrixOperations/cat/ccata.c
@@ -26,7 +26,7 @@ void crowcata(floatComplex *in1, int lines1, int columns1, floatComplex *in2, i
{
for (j = 0 ; j < lines1 ; ++j)
{
- /*out[i*(lines1 + lines2) + j] = in1[i*lines1 + j];*/
+ out[i*(lines1 + lines2) + j] = in1[i*lines1 + j];
}
for (j = 0 ; j < lines2 ; ++j)
{
diff --git a/src/c/matrixOperations/cat/zcata.c b/src/c/matrixOperations/cat/zcata.c
index bfb6e92..485553d 100644
--- a/src/c/matrixOperations/cat/zcata.c
+++ b/src/c/matrixOperations/cat/zcata.c
@@ -26,7 +26,7 @@ void zrowcata(doubleComplex *in1, int lines1, int columns1, doubleComplex *in2,
{
for (j = 0 ; j < lines1 ; ++j)
{
- /*out[i*(lines1 + lines2) + j] = in1[i*lines1 + j];*/
+ out[i*(lines1 + lines2) + j] = in1[i*lines1 + j];
}
for (j = 0 ; j < lines2 ; ++j)
{
diff --git a/src/c/signalProcessing/includes/dct.h b/src/c/signalProcessing/includes/dct.h
new file mode 100644
index 0000000..5255241
--- /dev/null
+++ b/src/c/signalProcessing/includes/dct.h
@@ -0,0 +1,36 @@
+/* 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 __DCT_H__
+#define __DCT_H__
+
+#include <math.h>
+#include "types.h"
+#include "doubleComplex.h"
+#include "addition.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void ddcta(double *in,int row,int col,int sign,double *out);
+
+void zdcta(doubleComplex *in,int row,int col,int sign,doubleComplex *out);
+
+void cdcta(floatComplex *in,int row,int col,int sign,floatComplex *out);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif
diff --git a/src/c/signalProcessing/includes/idct.h b/src/c/signalProcessing/includes/idct.h
new file mode 100644
index 0000000..13458b7
--- /dev/null
+++ b/src/c/signalProcessing/includes/idct.h
@@ -0,0 +1,36 @@
+/* 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 __IDCT_H__
+#define __IDCT_H__
+
+#include <math.h>
+#include "types.h"
+#include "doubleComplex.h"
+#include "addition.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void didcta(double *in,int row,int col,double *out);
+
+void zidcta(doubleComplex *in,int row,int col,doubleComplex *out);
+
+void cidcta(floatComplex *in,int row,int col,floatComplex *out);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif
diff --git a/src/c/signalProcessing/includes/modk.h b/src/c/signalProcessing/includes/modk.h
new file mode 100644
index 0000000..5040eb7
--- /dev/null
+++ b/src/c/signalProcessing/includes/modk.h
@@ -0,0 +1,28 @@
+/* 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
+ */
+
+#ifndef __MODK_H__
+#define __MODK_H__
+#include "types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void dmodka(double* inp,int size,double* oup);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* __MODK_H__ */
+
diff --git a/src/c/signalProcessing/interfaces/int_dct.h b/src/c/signalProcessing/interfaces/int_dct.h
new file mode 100644
index 0000000..6cfb21c
--- /dev/null
+++ b/src/c/signalProcessing/interfaces/int_dct.h
@@ -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
+*/
+
+
+
+#ifndef __INT_DCT_H__
+#define __INT_DCT_H__
+
+
+
+#define d2dctd2(in,size,out) ddcta(in,size[0],size[1],-1,out)
+
+#define d2d0dctd2(in,size,sign,out) ddcta(in,size[0],size[1],sign,out)
+
+#define z2dctz2(in,size,out) zdcta(in,size[0],size[1],-1,out)
+
+#define z2d0dctz2(in,size,sign,out) zdcta(in,size[0],size[1],sign,out)
+
+#define c2dctc2(in,size,out) cdcta(in,size[0],size[1],-1,out)
+
+#define c2s0dctc2(in,size,sign,out) cdcta(in,size[0],size[1],sign,out)
+
+#endif
diff --git a/src/c/signalProcessing/interfaces/int_idct.h b/src/c/signalProcessing/interfaces/int_idct.h
new file mode 100644
index 0000000..c3a174a
--- /dev/null
+++ b/src/c/signalProcessing/interfaces/int_idct.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
+*/
+
+
+
+#ifndef __INT_IDCT_H__
+#define __INT_IDCT_H__
+
+
+
+#define d2idctd2(in,size,out) didcta(in,size[0],size[1],out)
+
+#define z2idctz2(in,size,out) zidcta(in,size[0],size[1],out)
+
+#define c2idctc2(in,size,out) cidcta(in,size[0],size[1],out)
+
+#endif
diff --git a/src/c/signalProcessing/interfaces/int_modk.h b/src/c/signalProcessing/interfaces/int_modk.h
new file mode 100644
index 0000000..441b9b1
--- /dev/null
+++ b/src/c/signalProcessing/interfaces/int_modk.h
@@ -0,0 +1,18 @@
+/* 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
+ */
+
+#ifndef __INT_MODK_H__
+#define __INT_MODK_H__
+
+#define d2modkd2(inp,size,oup) dmodka(inp,size[1],oup)
+
+#endif /* !INT_MODK_H__! */
diff --git a/src/c/signalProcessing/modk/dmodka.c b/src/c/signalProcessing/modk/dmodka.c
new file mode 100644
index 0000000..c0630ec
--- /dev/null
+++ b/src/c/signalProcessing/modk/dmodka.c
@@ -0,0 +1,97 @@
+#include<stdio.h>
+#include<math.h>
+#include "modk.h"
+double max_calc(double* ptr,int sz)
+{
+ int i=0;
+ double mx;
+ if(ptr[0]<0)
+ {
+ ptr[0]=-1*ptr[0];
+ }
+ mx=(ptr[0]);
+ //printf("%lf\n",mx);
+ for(i=1;i<sz;i++)
+ {
+ if(ptr[i]<0)
+ {
+ ptr[i]=-1*ptr[i];
+ }
+ if(mx<(ptr[i]))
+ mx=(ptr[i]);
+ }
+ return mx;
+}
+void dmodka(double* inp,int size,double* oup)
+{
+ double ones[size],PI=M_PI;
+ double eps=pow(2,-52);
+ int i;
+ for(i=0;i<size;i++)
+ {
+ ones[i]=1;
+ }
+ double a[size],b[size],c[size],an[size],bn[size],cn[size],kans[size];
+
+ int j,kk,l,m;
+ for(j=0;j<size;j++)
+ {
+ a[j]=1;
+ }
+ for(kk=0;kk<size;kk++)
+ {
+ b[kk]=sqrt(ones[kk]-inp[kk]);
+ }
+ for(l=0;l<size;l++)
+ {
+ c[l]=sqrt(inp[l]);
+
+ }
+ int x=0;
+ //double maxi;
+ //maxi=max_calc(c,size);
+ //printf("%lf",maxi);
+
+ while(max_calc(c,size)>eps)
+ {
+ int q,w,r;
+ for(q=0;q<size;q++)
+ {
+ an[q]=0.5*(a[q]+b[q]);
+ }
+ for(w=0;w<size;w++)
+ {
+ bn[w]=sqrt(a[w]*b[w]);
+ }
+ for(r=0;r<size;r++)
+ {
+ cn[r]=0.5*(a[r]-b[r]);
+ }
+ int x,y,z;
+ for(x=0;x<size;x++)
+ {
+ a[x]=an[x];
+ }
+ for(y=0;y<size;y++)
+ {
+ b[y]=bn[y];
+ }
+ for(z=0;z<size;z++)
+ {
+ c[z]=cn[z];
+ }
+ }
+ int q,w;
+ for(q=0;q<size;q++)
+ {
+ oup[q]=PI*(ones[q]/(2*a[q]));
+ }
+
+}
+/*
+int main()
+{
+ double m[3]={0.1,0.2,0.3};
+ dka(m,3);
+}
+*/
diff --git a/src/c/signalProcessing/transforms/dct/cdcta.c b/src/c/signalProcessing/transforms/dct/cdcta.c
new file mode 100644
index 0000000..5bc2792
--- /dev/null
+++ b/src/c/signalProcessing/transforms/dct/cdcta.c
@@ -0,0 +1,177 @@
+/* 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 "dct.h"
+#include "addition.h"
+#include "types.h"
+#include "floatComplex.h"
+/*#include "matrixMultiplication"*/
+/*#include <fftw3.h>*/
+#include <math.h>
+
+void cdcta(floatComplex *in,int row,int col,int sign,floatComplex *out)
+{
+ int i,j,k,u,v;
+ int n;
+ int x,y;
+ float res,ress;
+ float re,z,q,m;
+ floatComplex accu = DoubleComplex(0, 0);
+ floatComplex temp,mm;
+ if(sign==-1)
+ {
+ if(row==1)
+ {
+ n=col;
+ for(u=0;u<row;u++)
+ {
+ for(v=0;v<col;v++)
+ {
+ x=v*row+u;
+ out[x]=FloatComplex(0,0);
+ for(i=0;i<row;i++)
+ {
+ for(j=0;j<col;j++)
+ {
+ y=row*j+i;
+ temp=in[y]*(cos(((M_PI)*(y+1-1./2.)*(x))/n));
+ out[x]=cadds(out[x],temp);
+ }
+ }
+ if(x==0)
+ out[x]*=1./(sqrt(n));
+ else
+ {
+ float res=2./n;
+ out[x]*=sqrt(res);
+ }
+ }
+ }
+ }
+ else
+ {
+ n=col*row;
+ for(u=0;u<row;u++)
+ {
+ for(v=0;v<col;v++)
+ {
+ x=v*row+u;
+ out[x]=FloatComplex(0,0);
+ for(i=0;i<row;i++)
+ {
+ temp=FloatComplex(0,0);
+ mm=FloatComplex(0,0);
+ for(j=0;j<col;j++)
+ {
+ y=j*row+i;
+ z=(float)(((float)j+1.0/2.0)*(float)v);
+ q=(float)(M_PI/(float)col);
+ mm=in[y]*(cos(q*z));
+ temp=cadds(temp,mm);
+ }
+ z=(float)(((float)i+1.0/2.0)*(float)u);
+ q=(float)(M_PI/(float)row);
+ temp*=cos(q*z);
+ out[x]=cadds(out[x],temp);
+ }
+ if(u==0)
+ {
+ out[x]*=1./sqrt((float)row);
+ if(v==0)
+ out[x]*=1./sqrt((float)col);
+ else
+ out[x]*=sqrt(2./col);
+ }
+ else
+ {
+ out[x]*=sqrt(2./row);
+ if(v==0)
+ out[x]*=1./sqrt((float)col);
+ else
+ out[x]*=sqrt(2./col);
+ }
+ }
+ }
+ }
+ }
+ else if(sign==1)
+ {
+ n=col;
+ if(row==1)
+ {
+ res=1./sqrt(n);
+ ress=sqrt(2./n);
+ for(u=0;u<row;u++)
+ {
+ for(v=0;v<col;v++)
+ {
+ x=v*row+u;
+ out[x]=FloatComplex(0,0);
+ for(i=0;i<row;i++)
+ {
+ for(j=0;j<col;j++)
+ {
+ y=row*j+i;
+ if(y==0)
+ {
+ q=res*(cos(((M_PI)*(j)*(v+1./2.))/n));
+ out[x]=cadds(out[x],in[y]*q);
+ }
+ else
+ {
+ q=ress*(cos(((M_PI)*(j)*(v+1./2.))/n));
+ out[x]=cadds(out[x],in[y]*q);
+ }
+ }
+ }
+ }
+
+ }
+ }
+ else
+ {
+ for(u=0;u<row;u++)
+ {
+ for(v=0;v<col;v++)
+ {
+ x=v*row+u;
+ out[x]=FloatComplex(0,0);
+ for(i=0;i<row;i++)
+ {
+ re=0;
+ mm=FloatComplex(0,0);
+ temp=FloatComplex(0,0);
+ for(j=0;j<col;j++)
+ {
+ y=row*j+i;
+ mm=in[j*row+i];
+ z=(float)(((float)v+1.0/2.0)*(float)j);
+ q=(float)(M_PI/(float)col);
+ mm=mm*(cos(q*z));
+ if(j==0)
+ temp=cadds(temp,mm*(1./sqrt((float)col)));
+ else
+ temp=cadds(temp,mm*sqrt(2./col));
+ }
+ z=(float)(((float)u+1.0/2.0)*(float)i);
+ q=(float)(M_PI/(float)row);
+ if(i==0)
+ out[x]=cadds(out[x],temp*((cos(z*q))*(1./sqrt(row))));
+ else
+ out[x]=cadds(out[x],temp*((cos(z*q))*sqrt(2./row)));
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/c/signalProcessing/transforms/dct/ddcta.c b/src/c/signalProcessing/transforms/dct/ddcta.c
new file mode 100644
index 0000000..3802c81
--- /dev/null
+++ b/src/c/signalProcessing/transforms/dct/ddcta.c
@@ -0,0 +1,160 @@
+/* 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 "dct.h"
+/*#include <fftw3.h>*/
+#include <math.h>
+
+void ddcta(double *in,int row,int col,int sign,double *out)
+{
+ int i,j,k,u,v;
+ int n;
+ int x,y;
+ double res,ress;
+ double re,z,q,m;
+ if(sign==-1)
+ {
+ if(row==1)
+ {
+ n=col;
+ for(u=0;u<row;u++)
+ {
+ for(v=0;v<col;v++)
+ {
+ x=v*row+u;
+ out[x]=0;
+ for(i=0;i<row;i++)
+ {
+ for(j=0;j<col;j++)
+ {
+ y=row*j+i;
+ out[x]+=in[y]*(cos(((M_PI)*(y+1-1./2.)*(x))/n));
+ }
+ }
+ if(x==0)
+ out[x]*=1./(sqrt(n));
+ else
+ {
+ double res=2./n;
+ out[x]*=sqrt(res);
+ }
+ }
+ }
+ }
+ else
+ {
+ n=col*row;
+ for(u=0;u<row;u++)
+ {
+ for(v=0;v<col;v++)
+ {
+ x=v*row+u;
+ out[x]=0;
+ for(i=0;i<row;i++)
+ {
+ re=0;
+ for(j=0;j<col;j++)
+ {
+ m=(double)in[j*row+i];
+ z=(double)(((double)j+1.0/2.0)*(double)v);
+ q=(double)(M_PI/(double)col);
+ re+=m*(cos(q*z));
+ }
+ z=(double)(((double)i+1.0/2.0)*(double)u);
+ q=(double)(M_PI/(double)row);
+ out[x]+=re*(cos(q*z));
+ }
+ if(u==0)
+ {
+ out[x]/=sqrt((double)row);
+ if(v==0)
+ out[x]/=sqrt((double)col);
+ else
+ out[x]*=sqrt(2./col);
+ }
+ else
+ {
+ out[x]*=sqrt(2./row);
+ if(v==0)
+ out[x]/=sqrt((double)col);
+ else
+ out[x]*=sqrt(2./col);
+ }
+ }
+ }
+
+ }
+ }
+ else if(sign==1)
+ {
+ n=col;
+ if(row==1)
+ {
+ res=1./sqrt(n);
+ ress=sqrt(2./n);
+ for(u=0;u<row;u++)
+ {
+ for(v=0;v<col;v++)
+ {
+ x=v*row+u;
+ out[x]=0;
+ for(i=0;i<row;i++)
+ {
+ for(j=0;j<col;j++)
+ {
+ y=row*j+i;
+ if(y==0)
+ out[x]+=res*in[y]*(cos(((M_PI)*(j)*(v+1./2.))/n));
+ else
+ out[x]+=ress*in[y]*(cos(((M_PI)*(j)*(v+1./2.))/n));
+ }
+ }
+ }
+
+ }
+ }
+ else
+ {
+ for(u=0;u<row;u++)
+ {
+ for(v=0;v<col;v++)
+ {
+ x=v*row+u;
+ out[x]=0;
+ for(i=0;i<row;i++)
+ {
+ re=0;
+ for(j=0;j<col;j++)
+ {
+ y=row*j+i;
+ m=(double)in[j*row+i];
+ z=(double)(((double)v+1.0/2.0)*(double)j);
+ q=(double)(M_PI/(double)col);
+ m=m*(cos(q*z));
+ if(j==0)
+ re+=m/sqrt((double)col);
+ else
+ re+=m*sqrt(2./col);
+ }
+ z=(double)(((double)u+1.0/2.0)*(double)i);
+ q=(double)(M_PI/(double)row);
+ if(i==0)
+ out[x]+=(re*(cos(z*q)))/sqrt((double)row);
+ else
+ out[x]+=(re*(cos(z*q))*sqrt(2./row));
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/c/signalProcessing/transforms/dct/zdcta.c b/src/c/signalProcessing/transforms/dct/zdcta.c
new file mode 100644
index 0000000..0204d68
--- /dev/null
+++ b/src/c/signalProcessing/transforms/dct/zdcta.c
@@ -0,0 +1,177 @@
+/* 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 "dct.h"
+#include "addition.h"
+#include "types.h"
+#include "doubleComplex.h"
+/*#include "matrixMultiplication"*/
+/*#include <fftw3.h>*/
+#include <math.h>
+
+void zdcta(doubleComplex *in,int row,int col,int sign,doubleComplex *out)
+{
+ int i,j,k,u,v;
+ int n;
+ int x,y;
+ double res,ress;
+ double re,z,q,m;
+ doubleComplex accu = DoubleComplex(0, 0);
+ doubleComplex temp,mm;
+ if(sign==-1)
+ {
+ if(row==1)
+ {
+ n=col;
+ for(u=0;u<row;u++)
+ {
+ for(v=0;v<col;v++)
+ {
+ x=v*row+u;
+ out[x]=DoubleComplex(0,0);
+ for(i=0;i<row;i++)
+ {
+ for(j=0;j<col;j++)
+ {
+ y=row*j+i;
+ temp=in[y]*(cos(((M_PI)*(y+1-1./2.)*(x))/n));
+ out[x]=zadds(out[x],temp);
+ }
+ }
+ if(x==0)
+ out[x]*=1./(sqrt(n));
+ else
+ {
+ double res=2./n;
+ out[x]*=sqrt(res);
+ }
+ }
+ }
+ }
+ else
+ {
+ n=col*row;
+ for(u=0;u<row;u++)
+ {
+ for(v=0;v<col;v++)
+ {
+ x=v*row+u;
+ out[x]=DoubleComplex(0,0);
+ for(i=0;i<row;i++)
+ {
+ temp=DoubleComplex(0,0);
+ mm=DoubleComplex(0,0);
+ for(j=0;j<col;j++)
+ {
+ y=j*row+i;
+ z=(double)(((double)j+1.0/2.0)*(double)v);
+ q=(double)(M_PI/(double)col);
+ mm=in[y]*(cos(q*z));
+ temp=zadds(temp,mm);
+ }
+ z=(double)(((double)i+1.0/2.0)*(double)u);
+ q=(double)(M_PI/(double)row);
+ temp*=cos(q*z);
+ out[x]=zadds(out[x],temp);
+ }
+ if(u==0)
+ {
+ out[x]*=1./sqrt((double)row);
+ if(v==0)
+ out[x]*=1./sqrt((double)col);
+ else
+ out[x]*=sqrt(2./col);
+ }
+ else
+ {
+ out[x]*=sqrt(2./row);
+ if(v==0)
+ out[x]*=1./sqrt((double)col);
+ else
+ out[x]*=sqrt(2./col);
+ }
+ }
+ }
+ }
+ }
+ else if(sign==1)
+ {
+ n=col;
+ if(row==1)
+ {
+ res=1./sqrt(n);
+ ress=sqrt(2./n);
+ for(u=0;u<row;u++)
+ {
+ for(v=0;v<col;v++)
+ {
+ x=v*row+u;
+ out[x]=DoubleComplex(0,0);
+ for(i=0;i<row;i++)
+ {
+ for(j=0;j<col;j++)
+ {
+ y=row*j+i;
+ if(y==0)
+ {
+ q=res*(cos(((M_PI)*(j)*(v+1./2.))/n));
+ out[x]=zadds(out[x],in[y]*q);
+ }
+ else
+ {
+ q=ress*(cos(((M_PI)*(j)*(v+1./2.))/n));
+ out[x]=zadds(out[x],in[y]*q);
+ }
+ }
+ }
+ }
+
+ }
+ }
+ else
+ {
+ for(u=0;u<row;u++)
+ {
+ for(v=0;v<col;v++)
+ {
+ x=v*row+u;
+ out[x]=DoubleComplex(0,0);
+ for(i=0;i<row;i++)
+ {
+ re=0;
+ mm=DoubleComplex(0,0);
+ temp=DoubleComplex(0,0);
+ for(j=0;j<col;j++)
+ {
+ y=row*j+i;
+ mm=in[j*row+i];
+ z=(double)(((double)v+1.0/2.0)*(double)j);
+ q=(double)(M_PI/(double)col);
+ mm=mm*(cos(q*z));
+ if(j==0)
+ temp=zadds(temp,mm*(1./sqrt((double)col)));
+ else
+ temp=zadds(temp,mm*sqrt(2./col));
+ }
+ z=(double)(((double)u+1.0/2.0)*(double)i);
+ q=(double)(M_PI/(double)row);
+ if(i==0)
+ out[x]=zadds(out[x],temp*((cos(z*q))*(1./sqrt(row))));
+ else
+ out[x]=zadds(out[x],temp*((cos(z*q))*sqrt(2./row)));
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/c/signalProcessing/transforms/idct/cidcta.c b/src/c/signalProcessing/transforms/idct/cidcta.c
new file mode 100644
index 0000000..ec0df0c
--- /dev/null
+++ b/src/c/signalProcessing/transforms/idct/cidcta.c
@@ -0,0 +1,97 @@
+/* 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 "idct.h"
+#include "addition.h"
+#include "types.h"
+#include "floatComplex.h"
+/*#include "matrixMultiplication"*/
+/*#include <fftw3.h>*/
+#include <math.h>
+
+void cidcta(floatComplex *in,int row,int col,floatComplex *out)
+{
+ int i,j,k,u,v;
+ int n=col;
+ int x,y;
+ float res,ress;
+ float re,z,q,m;
+ floatComplex accu = DoubleComplex(0, 0);
+ floatComplex temp,mm;
+ if(row==1)
+ {
+ res=1./sqrt(n);
+ ress=sqrt(2./n);
+ for(u=0;u<row;u++)
+ {
+ for(v=0;v<col;v++)
+ {
+ x=v*row+u;
+ out[x]=FloatComplex(0,0);
+ for(i=0;i<row;i++)
+ {
+ for(j=0;j<col;j++)
+ {
+ y=row*j+i;
+ if(y==0)
+ {
+ q=res*(cos(((M_PI)*(j)*(v+1./2.))/n));
+ out[x]=cadds(out[x],in[y]*q);
+ }
+ else
+ {
+ q=ress*(cos(((M_PI)*(j)*(v+1./2.))/n));
+ out[x]=cadds(out[x],in[y]*q);
+ }
+ }
+ }
+ }
+
+ }
+ }
+ else
+ {
+ for(u=0;u<row;u++)
+ {
+ for(v=0;v<col;v++)
+ {
+ x=v*row+u;
+ out[x]=FloatComplex(0,0);
+ for(i=0;i<row;i++)
+ {
+ re=0;
+ mm=FloatComplex(0,0);
+ temp=FloatComplex(0,0);
+ for(j=0;j<col;j++)
+ {
+ y=row*j+i;
+ mm=in[j*row+i];
+ z=(float)(((float)v+1.0/2.0)*(float)j);
+ q=(float)(M_PI/(float)col);
+ mm=mm*(cos(q*z));
+ if(j==0)
+ temp=cadds(temp,mm*(1./sqrt((float)col)));
+ else
+ temp=cadds(temp,mm*sqrt(2./col));
+ }
+ z=(float)(((float)u+1.0/2.0)*(float)i);
+ q=(float)(M_PI/(float)row);
+ if(i==0)
+ out[x]=cadds(out[x],temp*((cos(z*q))*(1./sqrt(row))));
+ else
+ out[x]=cadds(out[x],temp*((cos(z*q))*sqrt(2./row)));
+ }
+ }
+ }
+ }
+}
diff --git a/src/c/signalProcessing/transforms/idct/didcta.c b/src/c/signalProcessing/transforms/idct/didcta.c
new file mode 100644
index 0000000..5f47516
--- /dev/null
+++ b/src/c/signalProcessing/transforms/idct/didcta.c
@@ -0,0 +1,83 @@
+/* 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 "idct.h"
+/*#include <fftw3.h>*/
+#include <math.h>
+
+void didcta(double *in,int row,int col,double *out)
+{
+ int i,j,k,u,v;
+ int n=col;
+ int x,y;
+ double res,ress;
+ double re,z,q,m;
+ if(row==1)
+ {
+ res=1./sqrt(n);
+ ress=sqrt(2./n);
+ for(u=0;u<row;u++)
+ {
+ for(v=0;v<col;v++)
+ {
+ x=v*row+u;
+ out[x]=0;
+ for(i=0;i<row;i++)
+ {
+ for(j=0;j<col;j++)
+ {
+ y=row*j+i;
+ if(y==0)
+ out[x]+=res*in[y]*(cos(((M_PI)*(j)*(v+1./2.))/n));
+ else
+ out[x]+=ress*in[y]*(cos(((M_PI)*(j)*(v+1./2.))/n));
+ }
+ }
+ }
+
+ }
+ }
+ else
+ {
+ for(u=0;u<row;u++)
+ {
+ for(v=0;v<col;v++)
+ {
+ x=v*row+u;
+ out[x]=0;
+ for(i=0;i<row;i++)
+ {
+ re=0;
+ for(j=0;j<col;j++)
+ {
+ y=row*j+i;
+ m=(double)in[j*row+i];
+ z=(double)(((double)v+1.0/2.0)*(double)j);
+ q=(double)(M_PI/(double)col);
+ m=m*(cos(q*z));
+ if(j==0)
+ re+=m/sqrt((double)col);
+ else
+ re+=m*sqrt(2./col);
+ }
+ z=(double)(((double)u+1.0/2.0)*(double)i);
+ q=(double)(M_PI/(double)row);
+ if(i==0)
+ out[x]+=(re*(cos(z*q)))/sqrt((double)row);
+ else
+ out[x]+=(re*(cos(z*q))*sqrt(2./row));
+ }
+ }
+ }
+ }
+}
diff --git a/src/c/signalProcessing/transforms/idct/zidcta.c b/src/c/signalProcessing/transforms/idct/zidcta.c
new file mode 100644
index 0000000..2177b18
--- /dev/null
+++ b/src/c/signalProcessing/transforms/idct/zidcta.c
@@ -0,0 +1,97 @@
+/* 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 "idct.h"
+#include "addition.h"
+#include "types.h"
+#include "doubleComplex.h"
+/*#include "matrixMultiplication"*/
+/*#include <fftw3.h>*/
+#include <math.h>
+
+void zidcta(doubleComplex *in,int row,int col,doubleComplex *out)
+{
+ int i,j,k,u,v;
+ int n=col;
+ int x,y;
+ double res,ress;
+ double re,z,q,m;
+ doubleComplex accu = DoubleComplex(0, 0);
+ doubleComplex temp,mm;
+ if(row==1)
+ {
+ res=1./sqrt(n);
+ ress=sqrt(2./n);
+ for(u=0;u<row;u++)
+ {
+ for(v=0;v<col;v++)
+ {
+ x=v*row+u;
+ out[x]=DoubleComplex(0,0);
+ for(i=0;i<row;i++)
+ {
+ for(j=0;j<col;j++)
+ {
+ y=row*j+i;
+ if(y==0)
+ {
+ q=res*(cos(((M_PI)*(j)*(v+1./2.))/n));
+ out[x]=zadds(out[x],in[y]*q);
+ }
+ else
+ {
+ q=ress*(cos(((M_PI)*(j)*(v+1./2.))/n));
+ out[x]=zadds(out[x],in[y]*q);
+ }
+ }
+ }
+ }
+
+ }
+ }
+ else
+ {
+ for(u=0;u<row;u++)
+ {
+ for(v=0;v<col;v++)
+ {
+ x=v*row+u;
+ out[x]=DoubleComplex(0,0);
+ for(i=0;i<row;i++)
+ {
+ re=0;
+ mm=DoubleComplex(0,0);
+ temp=DoubleComplex(0,0);
+ for(j=0;j<col;j++)
+ {
+ y=row*j+i;
+ mm=in[j*row+i];
+ z=(double)(((double)v+1.0/2.0)*(double)j);
+ q=(double)(M_PI/(double)col);
+ mm=mm*(cos(q*z));
+ if(j==0)
+ temp=zadds(temp,mm*(1./sqrt((double)col)));
+ else
+ temp=zadds(temp,mm*sqrt(2./col));
+ }
+ z=(double)(((double)u+1.0/2.0)*(double)i);
+ q=(double)(M_PI/(double)row);
+ if(i==0)
+ out[x]=zadds(out[x],temp*((cos(z*q))*(1./sqrt(row))));
+ else
+ out[x]=zadds(out[x],temp*((cos(z*q))*sqrt(2./row)));
+ }
+ }
+ }
+ }
+}