summaryrefslogtreecommitdiff
path: root/src/signalProcessing/crossCorr
diff options
context:
space:
mode:
authortorset2009-01-08 09:23:27 +0000
committertorset2009-01-08 09:23:27 +0000
commit4c9dadaa3b1aec2ba0a6db60b55441c53ef9f143 (patch)
tree626325cf4e80b0a1f01d97843db04e3d24098045 /src/signalProcessing/crossCorr
parent9d4fef2da881c036b30f5c99a059d4d02370ce12 (diff)
downloadscilab2c-4c9dadaa3b1aec2ba0a6db60b55441c53ef9f143.tar.gz
scilab2c-4c9dadaa3b1aec2ba0a6db60b55441c53ef9f143.tar.bz2
scilab2c-4c9dadaa3b1aec2ba0a6db60b55441c53ef9f143.zip
add cross correlation (need assertions)
Diffstat (limited to 'src/signalProcessing/crossCorr')
-rw-r--r--src/signalProcessing/crossCorr/Makefile.am66
-rw-r--r--src/signalProcessing/crossCorr/ccrossCorra.c32
-rw-r--r--src/signalProcessing/crossCorr/dcrossCorra.c34
-rw-r--r--src/signalProcessing/crossCorr/scrossCorra.c29
-rw-r--r--src/signalProcessing/crossCorr/testDoubleCrossCorr.c62
-rw-r--r--src/signalProcessing/crossCorr/testFloatCrossCorr.c48
-rw-r--r--src/signalProcessing/crossCorr/zcrossCorra.c32
7 files changed, 303 insertions, 0 deletions
diff --git a/src/signalProcessing/crossCorr/Makefile.am b/src/signalProcessing/crossCorr/Makefile.am
new file mode 100644
index 00000000..c24390be
--- /dev/null
+++ b/src/signalProcessing/crossCorr/Makefile.am
@@ -0,0 +1,66 @@
+##
+## Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+## Copyright (C) 2008 - INRIA - Arnaud TORSET
+##
+## 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
+##
+##
+
+
+
+
+libCrossCorr_la_CFLAGS = -I $(top_builddir)/type \
+ -I $(top_builddir)/auxiliaryFunctions/includes \
+ -I $(top_builddir)/signalProcessing/includes
+
+
+instdir = $(top_builddir)/lib
+
+
+pkglib_LTLIBRARIES = libCrossCorr.la
+
+HEAD = ../includes/crossCorr.h
+
+libCrossCorr_la_SOURCES = $(HEAD) \
+ scrossCorra.c \
+ dcrossCorra.c \
+ ccrossCorra.c \
+ zcrossCorra.c
+
+
+###############
+#### Check ####
+###############
+
+check_LDADD = $(top_builddir)/type/libDoubleComplex.la \
+ $(top_builddir)/type/libFloatComplex.la \
+ $(top_builddir)/auxiliaryFunctions/conj/libConj.la \
+ $(top_builddir)/operations/multiplication/libMultiplication.la \
+ $(top_builddir)/operations/addition/libAddition.la \
+ $(top_builddir)/signalProcessing/conv2d/libConv2d.la \
+ libCrossCorr.la
+
+
+
+check_INCLUDES = -I $(top_builddir)/type \
+ -I $(top_builddir)/auxiliaryFunctions/includes \
+ -I $(top_builddir)/signalProcessing/includes
+
+check_PROGRAMS = testFloatCrossCorr testDoubleCrossCorr
+
+TESTS = testFloatCrossCorr testDoubleCrossCorr
+
+testDoubleCrossCorr_SOURCES = testDoubleCrossCorr.c
+testDoubleCrossCorr_LDADD = $(check_LDADD)
+testDoubleCrossCorr_CFLAGS = $(check_INCLUDES)
+
+testFloatCrossCorr_SOURCES = testFloatCrossCorr.c
+testFloatCrossCorr_LDADD = $(check_LDADD)
+testFloatCrossCorr_CFLAGS = $(check_INCLUDES)
+
+
+
diff --git a/src/signalProcessing/crossCorr/ccrossCorra.c b/src/signalProcessing/crossCorr/ccrossCorra.c
new file mode 100644
index 00000000..2310520e
--- /dev/null
+++ b/src/signalProcessing/crossCorr/ccrossCorra.c
@@ -0,0 +1,32 @@
+
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008 - INRIA - Arnaud TORSET
+ *
+ * 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 "crossCorr.h"
+#include "conv2d.h"
+#include "conj.h"
+
+void ccrossCorra(floatComplex* in1, int rows1, int cols1, floatComplex* in2, int rows2, int cols2, floatComplex* out){
+ floatComplex *in2Copy;
+ int i;
+
+ in2Copy=malloc((uint)rows2*sizeof(floatComplex));
+
+ /* We change in2 to be in appropriate form in in2Copy*/
+ for (i=0;i<(rows2*cols2);i++) in2Copy[i]=cconjs(in2[rows2*cols2-1-i]);
+
+ cconv2da(in1, rows1, cols1, in2Copy, rows2, cols2, out);
+
+}
+
+
diff --git a/src/signalProcessing/crossCorr/dcrossCorra.c b/src/signalProcessing/crossCorr/dcrossCorra.c
new file mode 100644
index 00000000..e537f7f4
--- /dev/null
+++ b/src/signalProcessing/crossCorr/dcrossCorra.c
@@ -0,0 +1,34 @@
+
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008 - INRIA - Arnaud TORSET
+ *
+ * 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 "crossCorr.h"
+#include "conv2d.h"
+
+
+
+void dcrossCorra(double* in1, int rows1, int cols1, double* in2, int rows2, int cols2, double* out){
+ double *in2Copy;
+ int i;
+
+ in2Copy=malloc((uint)rows2*sizeof(double));
+
+ /* We change in2 to be in appropriate form in in2Copy*/
+ for (i=0;i<(rows2*cols2);i++) in2Copy[i]=in2[rows2*cols2-1-i];
+
+ dconv2da(in1, rows1, cols1, in2Copy, rows2, cols2, out);
+}
+
+
+
+
diff --git a/src/signalProcessing/crossCorr/scrossCorra.c b/src/signalProcessing/crossCorr/scrossCorra.c
new file mode 100644
index 00000000..bd2013ed
--- /dev/null
+++ b/src/signalProcessing/crossCorr/scrossCorra.c
@@ -0,0 +1,29 @@
+
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008 - INRIA - Arnaud TORSET
+ *
+ * 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 "crossCorr.h"
+#include "conv2d.h"
+
+void scrossCorra(float* in1, int rows1, int cols1, float* in2, int rows2, int cols2, float* out){
+ float *in2Copy;
+ int i;
+
+ in2Copy=malloc((uint)rows2*sizeof(float));
+
+ /* We change in2 to be in appropriate form in in2Copy*/
+ for (i=0;i<(rows2*cols2);i++) in2Copy[i]=in2[rows2*cols2-1-i];
+
+ sconv2da(in1, rows1, cols1, in2Copy, rows2, cols2, out);
+
+}
diff --git a/src/signalProcessing/crossCorr/testDoubleCrossCorr.c b/src/signalProcessing/crossCorr/testDoubleCrossCorr.c
new file mode 100644
index 00000000..20847fd3
--- /dev/null
+++ b/src/signalProcessing/crossCorr/testDoubleCrossCorr.c
@@ -0,0 +1,62 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008 - INRIA - Arnaud TORSET
+ *
+ * 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 <assert.h>
+#include <math.h>
+#include "crossCorr.h"
+#include <stdio.h>
+
+
+static void dcrossCorraTest(void){
+ int i;
+ double in1[] = {1,2,3,4,5,6,7,8,9,10,11,12};
+ double in2[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
+ double inV1[]={0.8812593049369752407074,0.459206754341721534729,0.4192749080248177051544,0.9930617930367588996887,0.1705299648456275463104,0.8114501461386680603027, 0.4106854074634611606598};
+ double inV2[]={0.5211019767448306083679, 0.2967169224284589290619, 0.4054284896701574325562, 0.6229536165483295917511};
+ double out[42],outV1[10],outV[12*16];
+
+ /* Test Matrice-Matrice */
+ dcrossCorra(in1,4,3,in2,4,4,out);
+ for (i=0;i<42;i++){
+ printf("out[%d] : %f\n",i,out[i]);
+ }
+
+ /* Test VecteuLigne-VecteurColonne */
+ dcrossCorra(in1,12,1,in2,1,16,outV);
+ for (i=0;i<12*16;i++){
+ printf("out[%d] : %f\n",i,outV[i]);
+ }
+
+ /* Test VecteurLigne-VecteurLigne */
+ dcrossCorra(inV1,1,7,inV2,1,4,outV1);
+ for (i=0;i<10;i++){
+ printf("out[%d] : %f\n",i,outV1[i]);
+ }
+}
+
+
+static void zcrossCorraTest(void){
+
+}
+
+
+static int crossCorraTest(void){
+ dcrossCorraTest();
+ zcrossCorraTest();
+ return 0;
+}
+
+int main (void){
+ assert(crossCorraTest()==0);
+ return 0;
+}
+
diff --git a/src/signalProcessing/crossCorr/testFloatCrossCorr.c b/src/signalProcessing/crossCorr/testFloatCrossCorr.c
new file mode 100644
index 00000000..603227ed
--- /dev/null
+++ b/src/signalProcessing/crossCorr/testFloatCrossCorr.c
@@ -0,0 +1,48 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008 - INRIA - Arnaud TORSET
+ *
+ * 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 <assert.h>
+#include <math.h>
+#include "crossCorr.h"
+#include <stdio.h>
+
+
+static void scrossCorraTest(void){
+ int i;
+ float in1[] = {1.0f,2.0f,3.0f,4.0f,5.0f,6.0f,7.0f,8.0f,9.0f,10.0f,11.0f,12.0f};
+ float in2[] = {1.0f,2.0f,3.0f,4.0f,5.0f,6.0f,7.0f,8.0f,9.0f,10.0f,11.0f,12.0f,13.0f,14.0f,15.0f,16.0f};
+
+ float out[42];
+
+ scrossCorra(in1,4,3,in2,4,4,out);
+ for (i=0;i<42;i++){
+ printf("out[%d] : %f\n",i,out[i]);
+ }
+}
+
+
+static void ccrossCorraTest(void){
+
+}
+
+
+static int crossCorraTest(void){
+ scrossCorraTest();
+ ccrossCorraTest();
+ return 0;
+}
+
+int main (void){
+ assert(crossCorraTest()==0);
+ return 0;
+}
+
diff --git a/src/signalProcessing/crossCorr/zcrossCorra.c b/src/signalProcessing/crossCorr/zcrossCorra.c
new file mode 100644
index 00000000..49ac5a7a
--- /dev/null
+++ b/src/signalProcessing/crossCorr/zcrossCorra.c
@@ -0,0 +1,32 @@
+
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008 - INRIA - Arnaud TORSET
+ *
+ * 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 "crossCorr.h"
+#include "conv2d.h"
+#include "conj.h"
+
+void zcrossCorra(doubleComplex* in1, int rows1, int cols1, doubleComplex* in2, int rows2, int cols2, doubleComplex* out){
+ doubleComplex *in2Copy;
+ int i;
+
+ in2Copy=malloc((uint)(rows2*cols2)*sizeof(doubleComplex));
+
+ /* We change in2 to be in appropriate form in in2Copy*/
+ for (i=0;i<(rows2*cols2);i++) in2Copy[i]=zconjs(in2[rows2*cols2-1-i]);
+
+ zconv2da(in1, rows1, cols1, in2Copy, rows2, cols2, out);
+
+}
+
+