summaryrefslogtreecommitdiff
path: root/src/c/auxiliaryFunctions
diff options
context:
space:
mode:
Diffstat (limited to 'src/c/auxiliaryFunctions')
-rw-r--r--src/c/auxiliaryFunctions/find/i16finda.c40
-rw-r--r--src/c/auxiliaryFunctions/find/i16finda.c~40
-rw-r--r--src/c/auxiliaryFunctions/find/i8finda.c40
-rw-r--r--src/c/auxiliaryFunctions/find/i8finda.c~40
-rw-r--r--src/c/auxiliaryFunctions/find/u16finda.c40
-rw-r--r--src/c/auxiliaryFunctions/find/u16finda.c~40
-rw-r--r--src/c/auxiliaryFunctions/find/u8finda.c40
-rw-r--r--src/c/auxiliaryFunctions/find/u8finda.c~40
-rw-r--r--src/c/auxiliaryFunctions/includes/find.h27
-rw-r--r--src/c/auxiliaryFunctions/interfaces/int_find.h61
10 files changed, 407 insertions, 1 deletions
diff --git a/src/c/auxiliaryFunctions/find/i16finda.c b/src/c/auxiliaryFunctions/find/i16finda.c
new file mode 100644
index 0000000..f7bde00
--- /dev/null
+++ b/src/c/auxiliaryFunctions/find/i16finda.c
@@ -0,0 +1,40 @@
+/*
+ * 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
+ *
+ */
+
+
+#include "find.h"
+
+void i16finda(int16* x, int size, int16 *out, int max)
+{
+ int i = 0;
+ int j = 0;
+
+ /* if out is empty */
+ out[0]=-1;
+
+
+ for (i = 0; i < size ; ++i)
+ {
+ /*to avoid useless search if we only want to find the max first founded value */
+ if (j == max)
+ {
+ return ;
+ }
+
+ if (x[i] != 0)
+ {
+ out[j] = (int16)(i+1);
+ ++j;
+ }
+ }
+}
+
diff --git a/src/c/auxiliaryFunctions/find/i16finda.c~ b/src/c/auxiliaryFunctions/find/i16finda.c~
new file mode 100644
index 0000000..f7bde00
--- /dev/null
+++ b/src/c/auxiliaryFunctions/find/i16finda.c~
@@ -0,0 +1,40 @@
+/*
+ * 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
+ *
+ */
+
+
+#include "find.h"
+
+void i16finda(int16* x, int size, int16 *out, int max)
+{
+ int i = 0;
+ int j = 0;
+
+ /* if out is empty */
+ out[0]=-1;
+
+
+ for (i = 0; i < size ; ++i)
+ {
+ /*to avoid useless search if we only want to find the max first founded value */
+ if (j == max)
+ {
+ return ;
+ }
+
+ if (x[i] != 0)
+ {
+ out[j] = (int16)(i+1);
+ ++j;
+ }
+ }
+}
+
diff --git a/src/c/auxiliaryFunctions/find/i8finda.c b/src/c/auxiliaryFunctions/find/i8finda.c
new file mode 100644
index 0000000..068c125
--- /dev/null
+++ b/src/c/auxiliaryFunctions/find/i8finda.c
@@ -0,0 +1,40 @@
+/*
+ * 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
+ *
+ */
+
+
+#include "find.h"
+
+void i8finda(int8* x, int size, int8 *out, int max)
+{
+ int i = 0;
+ int j = 0;
+
+ /* if out is empty */
+ out[0]=-1;
+
+
+ for (i = 0; i < size ; ++i)
+ {
+ /*to avoid useless search if we only want to find the max first founded value */
+ if (j == max)
+ {
+ return ;
+ }
+
+ if (x[i] != 0)
+ {
+ out[j] = (int8)(i+1);
+ ++j;
+ }
+ }
+}
+
diff --git a/src/c/auxiliaryFunctions/find/i8finda.c~ b/src/c/auxiliaryFunctions/find/i8finda.c~
new file mode 100644
index 0000000..ac223ae
--- /dev/null
+++ b/src/c/auxiliaryFunctions/find/i8finda.c~
@@ -0,0 +1,40 @@
+/*
+ * 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
+ *
+ */
+
+
+#include "find.h"
+
+void dfinda(double* x, int size, double *out, int max)
+{
+ int i = 0;
+ int j = 0;
+
+ /* if out is empty */
+ out[0]=-1;
+
+
+ for (i = 0; i < size ; ++i)
+ {
+ /*to avoid useless search if we only want to find the max first founded value */
+ if (j == max)
+ {
+ return ;
+ }
+
+ if (x[i] != 0)
+ {
+ out[j] = (double)(i+1);
+ ++j;
+ }
+ }
+}
+
diff --git a/src/c/auxiliaryFunctions/find/u16finda.c b/src/c/auxiliaryFunctions/find/u16finda.c
new file mode 100644
index 0000000..3096d61
--- /dev/null
+++ b/src/c/auxiliaryFunctions/find/u16finda.c
@@ -0,0 +1,40 @@
+/*
+ * 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
+ *
+ */
+
+
+#include "find.h"
+
+void u16finda(uint16* x, int size, uint16 *out, int max)
+{
+ int i = 0;
+ int j = 0;
+
+ /* if out is empty */
+ out[0]=-1;
+
+
+ for (i = 0; i < size ; ++i)
+ {
+ /*to avoid useless search if we only want to find the max first founded value */
+ if (j == max)
+ {
+ return ;
+ }
+
+ if (x[i] != 0)
+ {
+ out[j] = (uint16)(i+1);
+ ++j;
+ }
+ }
+}
+
diff --git a/src/c/auxiliaryFunctions/find/u16finda.c~ b/src/c/auxiliaryFunctions/find/u16finda.c~
new file mode 100644
index 0000000..3096d61
--- /dev/null
+++ b/src/c/auxiliaryFunctions/find/u16finda.c~
@@ -0,0 +1,40 @@
+/*
+ * 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
+ *
+ */
+
+
+#include "find.h"
+
+void u16finda(uint16* x, int size, uint16 *out, int max)
+{
+ int i = 0;
+ int j = 0;
+
+ /* if out is empty */
+ out[0]=-1;
+
+
+ for (i = 0; i < size ; ++i)
+ {
+ /*to avoid useless search if we only want to find the max first founded value */
+ if (j == max)
+ {
+ return ;
+ }
+
+ if (x[i] != 0)
+ {
+ out[j] = (uint16)(i+1);
+ ++j;
+ }
+ }
+}
+
diff --git a/src/c/auxiliaryFunctions/find/u8finda.c b/src/c/auxiliaryFunctions/find/u8finda.c
new file mode 100644
index 0000000..d571c7c
--- /dev/null
+++ b/src/c/auxiliaryFunctions/find/u8finda.c
@@ -0,0 +1,40 @@
+/*
+ * 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
+ *
+ */
+
+
+#include "find.h"
+
+void u8finda(uint8* x, int size, uint8 *out, int max)
+{
+ int i = 0;
+ int j = 0;
+
+ /* if out is empty */
+ out[0]=-1;
+
+
+ for (i = 0; i < size ; ++i)
+ {
+ /*to avoid useless search if we only want to find the max first founded value */
+ if (j == max)
+ {
+ return ;
+ }
+
+ if (x[i] != 0)
+ {
+ out[j] = (uint8)(i+1);
+ ++j;
+ }
+ }
+}
+
diff --git a/src/c/auxiliaryFunctions/find/u8finda.c~ b/src/c/auxiliaryFunctions/find/u8finda.c~
new file mode 100644
index 0000000..d571c7c
--- /dev/null
+++ b/src/c/auxiliaryFunctions/find/u8finda.c~
@@ -0,0 +1,40 @@
+/*
+ * 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
+ *
+ */
+
+
+#include "find.h"
+
+void u8finda(uint8* x, int size, uint8 *out, int max)
+{
+ int i = 0;
+ int j = 0;
+
+ /* if out is empty */
+ out[0]=-1;
+
+
+ for (i = 0; i < size ; ++i)
+ {
+ /*to avoid useless search if we only want to find the max first founded value */
+ if (j == max)
+ {
+ return ;
+ }
+
+ if (x[i] != 0)
+ {
+ out[j] = (uint8)(i+1);
+ ++j;
+ }
+ }
+}
+
diff --git a/src/c/auxiliaryFunctions/includes/find.h b/src/c/auxiliaryFunctions/includes/find.h
index 3104e95..8072f74 100644
--- a/src/c/auxiliaryFunctions/includes/find.h
+++ b/src/c/auxiliaryFunctions/includes/find.h
@@ -16,6 +16,7 @@
#include "dynlib_auxiliaryfunctions.h"
#include "floatComplex.h"
#include "doubleComplex.h"
+#include "types.h"
#ifdef __cplusplus
extern "C" {
@@ -44,6 +45,32 @@ EXTERN_AUXFUNCT void cfinda(floatComplex* z, int size, float *out, int max);
*/
EXTERN_AUXFUNCT void zfinda(doubleComplex* z, int size, double *out, int max);
+/*
+** \brief uint8 Find function
+** max is an integer giving the maximum number of indices to return. (use -1 to search them all)
+*/
+EXTERN_AUXFUNCT void u8finda(uint8 *x, int size, uint8 *out, int max);
+
+/*
+** \brief uint16 Find function
+** max is an integer giving the maximum number of indices to return. (use -1 to search them all)
+*/
+EXTERN_AUXFUNCT void u16finda(uint16 *x, int size, uint16 *out, int max);
+
+/*
+** \brief int8 Find function
+** max is an integer giving the maximum number of indices to return. (use -1 to search them all)
+*/
+EXTERN_AUXFUNCT void i8finda(int8 *x, int size, int8 *out, int max);
+
+/*
+** \brief int16 Find function
+** max is an integer giving the maximum number of indices to return. (use -1 to search them all)
+*/
+EXTERN_AUXFUNCT void i16finda(int16 *x, int size, int16 *out, int max);
+
+
+
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/src/c/auxiliaryFunctions/interfaces/int_find.h b/src/c/auxiliaryFunctions/interfaces/int_find.h
index 891aad7..ec1e157 100644
--- a/src/c/auxiliaryFunctions/interfaces/int_find.h
+++ b/src/c/auxiliaryFunctions/interfaces/int_find.h
@@ -25,6 +25,14 @@
#define z0findd0(in) ((zreals(in) == 0) && (zimags(in) == 0)) ? -1 : 1
+#define u80findu80(in) (in == 0) ? -1 : 1
+
+#define u160findu160(in) (in == 0) ? -1 : 1
+
+#define i80findi80(in) (in == 0) ? -1 : 1
+
+#define i160findi160(in) (in == 0) ? -1 : 1
+
#define s2finds2(in,size,out) sfinda(in, size[0]*size[1], out, -1)
#define d2findd2(in,size,out) dfinda(in, size[0]*size[1], out, -1)
@@ -33,6 +41,14 @@
#define z2findd2(in,size,out) zfinda(in, size[0]*size[1], out, -1)
+#define u82findu82(in,size,out) u8finda(in,size[0]*size[1],out, -1)
+
+#define u162findu162(in,size,out) u16finda(in,size[0]*size[1],out, -1)
+
+#define i82findi82(in,size,out) i8finda(in,size[0]*size[1],out, -1)
+
+#define i162findi162(in,size,out) i16finda(in,size[0]*size[1],out, -1)
+
/* 1 input, 2 outputs */
#define s0finds0s0(in,out2) *out2 = s0finds0(in);s0finds0(in)
@@ -43,10 +59,18 @@
#define z0findd0d0(in,out2) if ((zreals(in)==0) && (zimags(in)==0)) {out2=0;} else {out2=1;}
+#define u80findu80u80(in,out2) *out2 = u80findu80(in);u80findu80(in)
+
+#define u160findu160u160(in,out2) *out2 = u160findu160(in);u160findu160(in)
+
+#define i80findi80i80(in,out2) *out2 = i80findi80(in);i80findi80(in)
+
+#define i160findi160i160(in,out2) *out2 = i160findi160(in);i160findi160(in)
+
#define s2finds2s2(in,size,out1,sizeOut1,out2,sizeOut2) sfind2da(in,size[0],size[1],out1,sizeOut1,out2,sizeOut2,-1)
-#define d2findd2d2(in,size,out1,out2) dfind2da(in,size[0],size[1],out1,out2,-1)
+#define d2findd2d2(in,size,out1,out2) dfind2da(in,size[0],size[1],out1,out2,-1)
#define c2finds2s2(in,size,out1,sizeOut1,out2,sizeOut2) cfind2da(in,size[0],size[1],out1,sizeOut1,out2,sizeOut2,-1)
@@ -62,6 +86,14 @@
#define z0d0findd0(in1,in2) z0findd0(in1)
+#define u80u80findu80(in1,in2) u80findu80(in1)
+
+#define u160u160findu160(in1,in2) u160findu160(in1)
+
+#define i80i80findi80(in1,in2) i80findi80(in1)
+
+#define i160i160findi160(in1,in2) i160findi160(in1)
+
#define s2s0finds2(in1,size,in2,out) {\
int temp_out_indice[2] = {0} ;\
sfinda(in1,size[0]*size[1],out,in2);\
@@ -82,6 +114,25 @@
zfinda(in1,size[0]*size[1],out,in2);\
}
+#define u82u80findu82(in1,size,in2,out) {\
+ int temp_out_indice[2] = {0};\
+ u8finda(in1,size[0]*size[1],out,in2);\
+}
+
+#define u162u160findu162(in1,size,in2,out) {\
+ int temp_out_indice[2] = {0};\
+ u16finda(in1,size[0]*size[1],out,in2);\
+}
+
+#define i82i80findi82(in1,size,in2,out) {\
+ int temp_out_indice[2] = {0};\
+ i8finda(in1,size[0]*size[1],out,in2);\
+}
+
+#define i162i160findi162(in1,size,in2,out) {\
+ int temp_out_indice[2] = {0};\
+ i16finda(in1,size[0]*size[1],out,in2);\
+}
/* 2 inputs, 2 outputs */
#define s0s0finds0s0(in1,in2,out1,out2) s0finds0s0(in1,out1,out2)
@@ -92,6 +143,14 @@
#define z0d0findd0d0(in1,in2,out1,out2) z0findd0d0(in1,out1,out2)
+#define u80u80findu80u80(in1,in2,out1,out2) u80findu80u80(in1,out1,out2)
+
+#define u160u160findu160u160(in1,in2,out1,out2) u160findu160u160(in1,out1,out2)
+
+#define i80i80findi80i80(in1,in2,out1,out2) i80findi80i80(in1,out1,out2)
+
+#define i160i60findi60i60(in1,in2,out1,out2) i60findi60i60(in1,out1,out2)
+
/*FIXME : prototypes are wrong*/
#define s2s0finds2s2(in1,size,in2,out1,out2) {\