summaryrefslogtreecommitdiff
path: root/src/c
diff options
context:
space:
mode:
authorBrijeshcr2017-08-18 16:29:50 +0530
committerBrijeshcr2017-08-18 16:29:50 +0530
commita210606cd1e59d66c621b0444d6c14927c71b381 (patch)
tree31174b8d67faef5fab07d3d0e0e852ee0423ba5e /src/c
parent4bc007e5b44a13b582b0275bf7fc6693942ba2ac (diff)
downloadScilab2C_fossee_old-a210606cd1e59d66c621b0444d6c14927c71b381.tar.gz
Scilab2C_fossee_old-a210606cd1e59d66c621b0444d6c14927c71b381.tar.bz2
Scilab2C_fossee_old-a210606cd1e59d66c621b0444d6c14927c71b381.zip
Scaling and Log2 added
Diffstat (limited to 'src/c')
-rw-r--r--src/c/elementaryFunctions/includes/log2.h39
-rw-r--r--src/c/elementaryFunctions/interfaces/int_log2.h33
-rw-r--r--src/c/elementaryFunctions/log2/dlog2a.c20
-rw-r--r--src/c/elementaryFunctions/log2/dlog2s.c21
-rw-r--r--src/c/elementaryFunctions/log2/slog2a.c21
-rw-r--r--src/c/elementaryFunctions/log2/slog2s.c20
-rw-r--r--src/c/elementaryFunctions/log2/zlog2a.c20
-rw-r--r--src/c/elementaryFunctions/log2/zlog2s.c22
-rw-r--r--src/c/graphics/transforms/includes/scaling.h36
-rw-r--r--src/c/graphics/transforms/interfaces/int_scaling.h35
-rw-r--r--src/c/graphics/transforms/scaling/dscalinga.c34
-rw-r--r--src/c/graphics/transforms/scaling/sscalinga.c34
-rw-r--r--src/c/graphics/transforms/scaling/zscalinga.c38
-rw-r--r--src/c/linearAlgebra/includes/lu.h33
-rw-r--r--src/c/linearAlgebra/interfaces/int_lu.h26
-rw-r--r--src/c/linearAlgebra/lu/dlua.c55
16 files changed, 487 insertions, 0 deletions
diff --git a/src/c/elementaryFunctions/includes/log2.h b/src/c/elementaryFunctions/includes/log2.h
new file mode 100644
index 0000000..e7b2aff
--- /dev/null
+++ b/src/c/elementaryFunctions/includes/log2.h
@@ -0,0 +1,39 @@
+ /* 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: Brijesh Gupta C R
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+
+#ifndef __LOG2_H__
+#define __LOG2_H__
+
+#include "dynlib_elementaryfunctions.h"
+#include "floatComplex.h"
+#include "doubleComplex.h"
+#include "types.h"
+#include "log.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+double dlog2s(double inp);
+float slog2s(float inp);
+doubleComplex zlog2s(doubleComplex inp);
+void dlog2a(double* inp,int size, double* out);
+void slog2a(float* inp,int size, float* out);
+void zlog2a(doubleComplex* inp,int size, doubleComplex* out);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+
+#endif /* !__LOG2_H__ */
+
diff --git a/src/c/elementaryFunctions/interfaces/int_log2.h b/src/c/elementaryFunctions/interfaces/int_log2.h
new file mode 100644
index 0000000..370503c
--- /dev/null
+++ b/src/c/elementaryFunctions/interfaces/int_log2.h
@@ -0,0 +1,33 @@
+/* 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: Brijesh Gupta C R
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+#ifndef __INT_LOG2_H__
+#define __INT_LOG2_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+#define d0log2d0(in1) dlog2s(in1)
+#define d2log2d2(in1, size1, out) dlog2a(in1,size1[0]*size1[1], out)
+#define s0log2s0(in1) slog2s(in1, in2)
+#define s2log2s2(in1, size1, out) slog2a(in1,size1[0]*size1[1], out)
+#define z0log2z0(in1) zlog2s(in1, in2)
+#define z2log2z2(in1, size1, out) zlog2a(in1,size1[0]*size1[1], out)
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__INT_LOG2_H__*/
diff --git a/src/c/elementaryFunctions/log2/dlog2a.c b/src/c/elementaryFunctions/log2/dlog2a.c
new file mode 100644
index 0000000..79047de
--- /dev/null
+++ b/src/c/elementaryFunctions/log2/dlog2a.c
@@ -0,0 +1,20 @@
+/* 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: Brijesh Gupta C R
+ Email: toolbox@scilab.in
+*/
+#include <stdio.h>
+#include <math.h>
+#include "log2.h"
+
+void dlog2a(double* inp,int size, double* out)
+{
+ for(int i = 0; i<size; i++)
+ out[i] = dlog2s(inp[i]);
+}
diff --git a/src/c/elementaryFunctions/log2/dlog2s.c b/src/c/elementaryFunctions/log2/dlog2s.c
new file mode 100644
index 0000000..9d2f8ab
--- /dev/null
+++ b/src/c/elementaryFunctions/log2/dlog2s.c
@@ -0,0 +1,21 @@
+/* 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: Brijesh Gupta C R
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+#include <stdio.h>
+#include <math.h>
+#include "log2.h"
+
+double dlog2s(double inp)
+{
+ return log(inp)/log(2);
+}
+
+
diff --git a/src/c/elementaryFunctions/log2/slog2a.c b/src/c/elementaryFunctions/log2/slog2a.c
new file mode 100644
index 0000000..0472307
--- /dev/null
+++ b/src/c/elementaryFunctions/log2/slog2a.c
@@ -0,0 +1,21 @@
+/* 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: Brijesh Gupta C R
+ Email: toolbox@scilab.in
+*/
+#include <stdio.h>
+#include <math.h>
+#include "factorial.h"
+#include "log2.h"
+
+void slog2a(float* inp,int size, float* out)
+{
+ for(int i = 0; i<size; i++)
+ out[i] = slog2s(inp[i]);
+}
diff --git a/src/c/elementaryFunctions/log2/slog2s.c b/src/c/elementaryFunctions/log2/slog2s.c
new file mode 100644
index 0000000..d162248
--- /dev/null
+++ b/src/c/elementaryFunctions/log2/slog2s.c
@@ -0,0 +1,20 @@
+/* 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: Brijesh Gupta C R
+ Email: toolbox@scilab.in
+*/
+#include <stdio.h>
+#include <math.h>
+#include "factorial.h"
+#include "log2.h"
+
+float slog2s(float inp)
+{
+ return log(inp)/log(2);
+}
diff --git a/src/c/elementaryFunctions/log2/zlog2a.c b/src/c/elementaryFunctions/log2/zlog2a.c
new file mode 100644
index 0000000..4cd0b33
--- /dev/null
+++ b/src/c/elementaryFunctions/log2/zlog2a.c
@@ -0,0 +1,20 @@
+/* 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: Brijesh Gupta C R
+ Email: toolbox@scilab.in
+*/
+#include <stdio.h>
+#include <math.h>
+#include "log2.h"
+
+void zlog2a(doubleComplex* inp,int size, doubleComplex* out)
+{
+ for(int i = 0; i<size; i++)
+ out[i] = zlog2s(inp[i]);
+}
diff --git a/src/c/elementaryFunctions/log2/zlog2s.c b/src/c/elementaryFunctions/log2/zlog2s.c
new file mode 100644
index 0000000..8447c9e
--- /dev/null
+++ b/src/c/elementaryFunctions/log2/zlog2s.c
@@ -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: Brijesh Gupta C R
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+#include <stdio.h>
+#include <math.h>
+#include "log2.h"
+#include "log.h"
+
+doubleComplex zlog2s(doubleComplex inp)
+{
+ return zlogs(inp)/zlogs(2);
+}
+
+
diff --git a/src/c/graphics/transforms/includes/scaling.h b/src/c/graphics/transforms/includes/scaling.h
new file mode 100644
index 0000000..35d9f24
--- /dev/null
+++ b/src/c/graphics/transforms/includes/scaling.h
@@ -0,0 +1,36 @@
+ /* 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: Brijesh Gupta C R
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+#ifndef __SCALING_H__
+#define __SCALING_H__
+#include "types.h"
+#include "floatComplex.h"
+#include "doubleComplex.h"
+#include "uint8.h"
+#include "uint16.h"
+#include "int16.h"
+#include "factorial.h"
+#include "ones.h"
+#include "matrixMultiplication.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void dscalinga (double* inp1, int row, int col, double inp2, double* inp3, int size3, double* out);
+void sscalinga (float* inp1, int row, int col, double inp2, float* inp3, int size3, float* out);
+void zscalinga (doubleComplex* inp1, int row, int col, doubleComplex inp2, doubleComplex* inp3, int size3, doubleComplex* out);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__SCALING_H__*/
diff --git a/src/c/graphics/transforms/interfaces/int_scaling.h b/src/c/graphics/transforms/interfaces/int_scaling.h
new file mode 100644
index 0000000..61cb5ab
--- /dev/null
+++ b/src/c/graphics/transforms/interfaces/int_scaling.h
@@ -0,0 +1,35 @@
+/* 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: Brijesh Gupta C R
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+#ifndef __INT_SCALING_H__
+#define __INT_SCALING_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+#define d2d0d2scalingd2(in1, size1, in2, in3, size2, out) dscalinga(in1, size1[0], size1[1], in2, in3, size2[0]*size2[1], out)
+#define s2s0s2scalings2(in1, size1, in2, in3, size2, out) sscalinga(in1, size1[0], size1[1], in2, in3, size2[0]*size2[1], out)
+#define s2d0s2scalings2(in1, size1, in2, in3, size2, out) sscalinga(in1, size1[0], size1[1], in2, in3, size2[0]*size2[1], out)
+#define z2z0z2scalingz2(in1, size1, in2, in3, size2, out) zscalinga(in1, size1[0], size1[1], in2, in3, size2[0]*size2[1], out)
+#define z2d0d2scalingz2(in1, size1, in2, in3, size2, out) zscalinga(in1, size1[0], size1[1], in2, in3, size2[0]*size2[1], out)
+#define z2z0d2scalingz2(in1, size1, in2, in3, size2, out) zscalinga(in1, size1[0], size1[1], in2, in3, size2[0]*size2[1], out)
+#define z2d0z2scalingz2(in1, size1, in2, in3, size2, out) zscalinga(in1, size1[0], size1[1], in2, in3, size2[0]*size2[1], out)
+
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__INT_SCALING_H__*/
diff --git a/src/c/graphics/transforms/scaling/dscalinga.c b/src/c/graphics/transforms/scaling/dscalinga.c
new file mode 100644
index 0000000..24d4573
--- /dev/null
+++ b/src/c/graphics/transforms/scaling/dscalinga.c
@@ -0,0 +1,34 @@
+/* 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: Brijesh Gupta C R
+ Email: toolbox@scilab.in
+*/
+#include <stdio.h>
+#include <math.h>
+#include "scaling.h"
+#include "ones.h"
+#include "matrixMultiplication.h"
+
+void dscalinga (double* inp1, int row, int col, double inp2, double* inp3, int size3, double* out)
+{
+ double temp[row*col], one[col], prod[row*col], diff[row*col];
+
+ for(int i = 0; i < row*col; i++)
+ temp[i] = inp1[i];
+
+ donesa(one, 1, col);
+
+ dmulma(inp3, 2, 1, one, 1, col, prod);
+
+ for(int i = 0; i < row*col; i++)
+ diff[i] = inp1[i] - prod[i];
+
+ for(int i = 0; i < row*col; i++)
+ out[i] = (inp2 * diff[i]) + prod[i];
+}
diff --git a/src/c/graphics/transforms/scaling/sscalinga.c b/src/c/graphics/transforms/scaling/sscalinga.c
new file mode 100644
index 0000000..1adfcf3
--- /dev/null
+++ b/src/c/graphics/transforms/scaling/sscalinga.c
@@ -0,0 +1,34 @@
+/* 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: Brijesh Gupta C R
+ Email: toolbox@scilab.in
+*/
+#include <stdio.h>
+#include <math.h>
+#include "scaling.h"
+#include "ones.h"
+#include "matrixMultiplication.h"
+
+void sscalinga (float* inp1, int row, int col, double inp2, float* inp3, int size3, float* out)
+{
+ float temp[row*col], one[col], prod[row*col], diff[row*col];
+
+ for(int i = 0; i < row*col; i++)
+ temp[i] = inp1[i];
+
+ sonesa(one, 1, col);
+
+ smulma(inp3, 2, 1, one, 1, col, prod);
+
+ for(int i = 0; i < row*col; i++)
+ diff[i] = inp1[i] - prod[i];
+
+ for(int i = 0; i < row*col; i++)
+ out[i] = (inp2 * diff[i]) + prod[i];
+}
diff --git a/src/c/graphics/transforms/scaling/zscalinga.c b/src/c/graphics/transforms/scaling/zscalinga.c
new file mode 100644
index 0000000..fb71a77
--- /dev/null
+++ b/src/c/graphics/transforms/scaling/zscalinga.c
@@ -0,0 +1,38 @@
+/* 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: Brijesh Gupta C R
+ Email: toolbox@scilab.in
+*/
+#include <stdio.h>
+#include <math.h>
+#include "scaling.h"
+#include "ones.h"
+#include "matrixMultiplication.h"
+#include "doubleComplex.h"
+#include "subtraction.h"
+#include "addition.h"
+#include "multiplication.h"
+
+void zscalinga (doubleComplex* inp1, int row, int col, doubleComplex inp2, doubleComplex* inp3, int size3, doubleComplex* out)
+{
+ doubleComplex temp[row*col], one[col], prod[row*col], diff[row*col];
+
+ for(int i = 0; i < row*col; i++)
+ temp[i] = inp1[i];
+
+ zonesa(one, 1, col);
+
+ zmulma(inp3, 2, 1, one, 1, col, prod);
+
+ for(int i = 0; i < row*col; i++)
+ diff[i] = zdiffs(inp1[i], prod[i]);
+
+ for(int i = 0; i < row*col; i++)
+ out[i] = zadds(zmuls(inp2, diff[i]), prod[i]);
+}
diff --git a/src/c/linearAlgebra/includes/lu.h b/src/c/linearAlgebra/includes/lu.h
new file mode 100644
index 0000000..08f4663
--- /dev/null
+++ b/src/c/linearAlgebra/includes/lu.h
@@ -0,0 +1,33 @@
+ /* 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: Brijesh Gupta C R
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+#ifndef __LU_H__
+#define __LU_H__
+#include "types.h"
+#include "doubleComplex.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "lapack.h"
+#include "string.h"
+#include "matrixTranspose.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void dlua(double*inp1, int size, double* out1, double* out2);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__LU_H__*/
diff --git a/src/c/linearAlgebra/interfaces/int_lu.h b/src/c/linearAlgebra/interfaces/int_lu.h
new file mode 100644
index 0000000..44c258a
--- /dev/null
+++ b/src/c/linearAlgebra/interfaces/int_lu.h
@@ -0,0 +1,26 @@
+ /* 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: Brijesh Gupta C R
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+
+#ifndef __INT_LU_H__
+#define __INT_LU_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define d2lud2d2(in1,size1, out1,out2) dlua(in1,size1[0]*size1[1],out1,out2)
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__INT_LU_H__*/
diff --git a/src/c/linearAlgebra/lu/dlua.c b/src/c/linearAlgebra/lu/dlua.c
new file mode 100644
index 0000000..d3cf6d1
--- /dev/null
+++ b/src/c/linearAlgebra/lu/dlua.c
@@ -0,0 +1,55 @@
+/* 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: Brijesh Gupta C R
+ Email: toolbox@scilab.in
+*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "lu.h"
+#include "lapack.h"
+#include "string.h"
+#include "matrixTranspose.h"
+
+extern double dgetrf_ (int* , int* , double* , int* , int* , int* );
+
+void dlua(double*inp1, int size, double* out1, double* out2)
+{
+ char TRANS = 'N';
+ int INFO=3;
+ int LDA = 3;
+ int LDB = 3;
+ int N = 3;
+ int NRHS = 1;
+ int IPIV[2] ;
+
+ /*double A[9] =
+ {
+ 1, 2, 3,
+ 2, 3, 4,
+ 3, 4, 1
+ };*/
+
+ //void LAPACK_dgetrf( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, lapack_int* ipiv, lapack_int *info );
+// dgetrf_(&N,&N,inp1,&LDA,IPIV,&INFO);
+
+ dgetrf_(6,2,inp1,6,IPIV,&INFO);
+
+ // checks INFO, if INFO != 0 something goes wrong, for more information see the MAN page of dgetrf.
+ for(int i = 0; i < 3*3; i++)
+ printf("%lf \n ", inp1[i]);
+
+ printf("PIVOTTTTTT \n ");
+
+ for(int i = 0; i < 2; i++)
+ printf("%d \n ", IPIV[i]);
+
+
+}
+