summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjofret2008-06-19 06:53:13 +0000
committerjofret2008-06-19 06:53:13 +0000
commitf9b0e9e54c8ebf227d2002bd6a621ef3f2ca1272 (patch)
treeebc9b47e0ace5139153d3367ebd05eb51a2399f5 /src
parent24f104a091afa9749e31a963f21a3d861bd74325 (diff)
downloadscilab2c-f9b0e9e54c8ebf227d2002bd6a621ef3f2ca1272.tar.gz
scilab2c-f9b0e9e54c8ebf227d2002bd6a621ef3f2ca1272.tar.bz2
scilab2c-f9b0e9e54c8ebf227d2002bd6a621ef3f2ca1272.zip
Add to compilation process
Add exhaustive tests
Diffstat (limited to 'src')
-rw-r--r--src/statisticsFunctions/sum/Makefile.am10
-rw-r--r--src/statisticsFunctions/sum/Makefile.in82
-rw-r--r--src/statisticsFunctions/sum/testDoubleSum.c419
-rw-r--r--src/statisticsFunctions/sum/testFloatSum.c389
4 files changed, 874 insertions, 26 deletions
diff --git a/src/statisticsFunctions/sum/Makefile.am b/src/statisticsFunctions/sum/Makefile.am
index 2464d6e7..f97f4579 100644
--- a/src/statisticsFunctions/sum/Makefile.am
+++ b/src/statisticsFunctions/sum/Makefile.am
@@ -20,9 +20,17 @@ pkglib_LTLIBRARIES = libSum.la
libSum_la_SOURCES = $(HEAD) $(SRC)
SRC = ssuma.c \
+ srowsuma.c \
+ scolumnsuma.c \
dsuma.c \
+ drowsuma.c \
+ dcolumnsuma.c \
csuma.c \
- zsuma.c
+ crowsuma.c \
+ ccolumnsuma.c \
+ zsuma.c \
+ zrowsuma.c \
+ zcolumnsuma.c
HEAD = ../includes/sum.h
diff --git a/src/statisticsFunctions/sum/Makefile.in b/src/statisticsFunctions/sum/Makefile.in
index ae05e61b..94bafc5d 100644
--- a/src/statisticsFunctions/sum/Makefile.in
+++ b/src/statisticsFunctions/sum/Makefile.in
@@ -54,8 +54,12 @@ pkglibLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(pkglib_LTLIBRARIES)
libSum_la_LIBADD =
am__objects_1 =
-am__objects_2 = libSum_la-ssuma.lo libSum_la-dsuma.lo \
- libSum_la-csuma.lo libSum_la-zsuma.lo
+am__objects_2 = libSum_la-ssuma.lo libSum_la-srowsuma.lo \
+ libSum_la-scolumnsuma.lo libSum_la-dsuma.lo \
+ libSum_la-drowsuma.lo libSum_la-dcolumnsuma.lo \
+ libSum_la-csuma.lo libSum_la-crowsuma.lo \
+ libSum_la-ccolumnsuma.lo libSum_la-zsuma.lo \
+ libSum_la-zrowsuma.lo libSum_la-zcolumnsuma.lo
am_libSum_la_OBJECTS = $(am__objects_1) $(am__objects_2)
libSum_la_OBJECTS = $(am_libSum_la_OBJECTS)
libSum_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
@@ -212,9 +216,17 @@ instdir = $(top_builddir)/lib
pkglib_LTLIBRARIES = libSum.la
libSum_la_SOURCES = $(HEAD) $(SRC)
SRC = ssuma.c \
+ srowsuma.c \
+ scolumnsuma.c \
dsuma.c \
+ drowsuma.c \
+ dcolumnsuma.c \
csuma.c \
- zsuma.c
+ crowsuma.c \
+ ccolumnsuma.c \
+ zsuma.c \
+ zrowsuma.c \
+ zcolumnsuma.c
HEAD = ../includes/sum.h
@@ -321,9 +333,17 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libSum_la-ccolumnsuma.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libSum_la-crowsuma.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libSum_la-csuma.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libSum_la-dcolumnsuma.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libSum_la-drowsuma.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libSum_la-dsuma.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libSum_la-scolumnsuma.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libSum_la-srowsuma.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libSum_la-ssuma.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libSum_la-zcolumnsuma.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libSum_la-zrowsuma.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libSum_la-zsuma.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testDoubleSum-testDoubleSum.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testFloatSum-testFloatSum.Po@am__quote@
@@ -356,6 +376,20 @@ libSum_la-ssuma.lo: ssuma.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -c -o libSum_la-ssuma.lo `test -f 'ssuma.c' || echo '$(srcdir)/'`ssuma.c
+libSum_la-srowsuma.lo: srowsuma.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -MT libSum_la-srowsuma.lo -MD -MP -MF $(DEPDIR)/libSum_la-srowsuma.Tpo -c -o libSum_la-srowsuma.lo `test -f 'srowsuma.c' || echo '$(srcdir)/'`srowsuma.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libSum_la-srowsuma.Tpo $(DEPDIR)/libSum_la-srowsuma.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='srowsuma.c' object='libSum_la-srowsuma.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -c -o libSum_la-srowsuma.lo `test -f 'srowsuma.c' || echo '$(srcdir)/'`srowsuma.c
+
+libSum_la-scolumnsuma.lo: scolumnsuma.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -MT libSum_la-scolumnsuma.lo -MD -MP -MF $(DEPDIR)/libSum_la-scolumnsuma.Tpo -c -o libSum_la-scolumnsuma.lo `test -f 'scolumnsuma.c' || echo '$(srcdir)/'`scolumnsuma.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libSum_la-scolumnsuma.Tpo $(DEPDIR)/libSum_la-scolumnsuma.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scolumnsuma.c' object='libSum_la-scolumnsuma.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -c -o libSum_la-scolumnsuma.lo `test -f 'scolumnsuma.c' || echo '$(srcdir)/'`scolumnsuma.c
+
libSum_la-dsuma.lo: dsuma.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -MT libSum_la-dsuma.lo -MD -MP -MF $(DEPDIR)/libSum_la-dsuma.Tpo -c -o libSum_la-dsuma.lo `test -f 'dsuma.c' || echo '$(srcdir)/'`dsuma.c
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libSum_la-dsuma.Tpo $(DEPDIR)/libSum_la-dsuma.Plo
@@ -363,6 +397,20 @@ libSum_la-dsuma.lo: dsuma.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -c -o libSum_la-dsuma.lo `test -f 'dsuma.c' || echo '$(srcdir)/'`dsuma.c
+libSum_la-drowsuma.lo: drowsuma.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -MT libSum_la-drowsuma.lo -MD -MP -MF $(DEPDIR)/libSum_la-drowsuma.Tpo -c -o libSum_la-drowsuma.lo `test -f 'drowsuma.c' || echo '$(srcdir)/'`drowsuma.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libSum_la-drowsuma.Tpo $(DEPDIR)/libSum_la-drowsuma.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drowsuma.c' object='libSum_la-drowsuma.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -c -o libSum_la-drowsuma.lo `test -f 'drowsuma.c' || echo '$(srcdir)/'`drowsuma.c
+
+libSum_la-dcolumnsuma.lo: dcolumnsuma.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -MT libSum_la-dcolumnsuma.lo -MD -MP -MF $(DEPDIR)/libSum_la-dcolumnsuma.Tpo -c -o libSum_la-dcolumnsuma.lo `test -f 'dcolumnsuma.c' || echo '$(srcdir)/'`dcolumnsuma.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libSum_la-dcolumnsuma.Tpo $(DEPDIR)/libSum_la-dcolumnsuma.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dcolumnsuma.c' object='libSum_la-dcolumnsuma.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -c -o libSum_la-dcolumnsuma.lo `test -f 'dcolumnsuma.c' || echo '$(srcdir)/'`dcolumnsuma.c
+
libSum_la-csuma.lo: csuma.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -MT libSum_la-csuma.lo -MD -MP -MF $(DEPDIR)/libSum_la-csuma.Tpo -c -o libSum_la-csuma.lo `test -f 'csuma.c' || echo '$(srcdir)/'`csuma.c
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libSum_la-csuma.Tpo $(DEPDIR)/libSum_la-csuma.Plo
@@ -370,6 +418,20 @@ libSum_la-csuma.lo: csuma.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -c -o libSum_la-csuma.lo `test -f 'csuma.c' || echo '$(srcdir)/'`csuma.c
+libSum_la-crowsuma.lo: crowsuma.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -MT libSum_la-crowsuma.lo -MD -MP -MF $(DEPDIR)/libSum_la-crowsuma.Tpo -c -o libSum_la-crowsuma.lo `test -f 'crowsuma.c' || echo '$(srcdir)/'`crowsuma.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libSum_la-crowsuma.Tpo $(DEPDIR)/libSum_la-crowsuma.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='crowsuma.c' object='libSum_la-crowsuma.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -c -o libSum_la-crowsuma.lo `test -f 'crowsuma.c' || echo '$(srcdir)/'`crowsuma.c
+
+libSum_la-ccolumnsuma.lo: ccolumnsuma.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -MT libSum_la-ccolumnsuma.lo -MD -MP -MF $(DEPDIR)/libSum_la-ccolumnsuma.Tpo -c -o libSum_la-ccolumnsuma.lo `test -f 'ccolumnsuma.c' || echo '$(srcdir)/'`ccolumnsuma.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libSum_la-ccolumnsuma.Tpo $(DEPDIR)/libSum_la-ccolumnsuma.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ccolumnsuma.c' object='libSum_la-ccolumnsuma.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -c -o libSum_la-ccolumnsuma.lo `test -f 'ccolumnsuma.c' || echo '$(srcdir)/'`ccolumnsuma.c
+
libSum_la-zsuma.lo: zsuma.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -MT libSum_la-zsuma.lo -MD -MP -MF $(DEPDIR)/libSum_la-zsuma.Tpo -c -o libSum_la-zsuma.lo `test -f 'zsuma.c' || echo '$(srcdir)/'`zsuma.c
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libSum_la-zsuma.Tpo $(DEPDIR)/libSum_la-zsuma.Plo
@@ -377,6 +439,20 @@ libSum_la-zsuma.lo: zsuma.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -c -o libSum_la-zsuma.lo `test -f 'zsuma.c' || echo '$(srcdir)/'`zsuma.c
+libSum_la-zrowsuma.lo: zrowsuma.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -MT libSum_la-zrowsuma.lo -MD -MP -MF $(DEPDIR)/libSum_la-zrowsuma.Tpo -c -o libSum_la-zrowsuma.lo `test -f 'zrowsuma.c' || echo '$(srcdir)/'`zrowsuma.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libSum_la-zrowsuma.Tpo $(DEPDIR)/libSum_la-zrowsuma.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='zrowsuma.c' object='libSum_la-zrowsuma.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -c -o libSum_la-zrowsuma.lo `test -f 'zrowsuma.c' || echo '$(srcdir)/'`zrowsuma.c
+
+libSum_la-zcolumnsuma.lo: zcolumnsuma.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -MT libSum_la-zcolumnsuma.lo -MD -MP -MF $(DEPDIR)/libSum_la-zcolumnsuma.Tpo -c -o libSum_la-zcolumnsuma.lo `test -f 'zcolumnsuma.c' || echo '$(srcdir)/'`zcolumnsuma.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libSum_la-zcolumnsuma.Tpo $(DEPDIR)/libSum_la-zcolumnsuma.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='zcolumnsuma.c' object='libSum_la-zcolumnsuma.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libSum_la_CFLAGS) $(CFLAGS) -c -o libSum_la-zcolumnsuma.lo `test -f 'zcolumnsuma.c' || echo '$(srcdir)/'`zcolumnsuma.c
+
testDoubleSum-testDoubleSum.o: testDoubleSum.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testDoubleSum_CFLAGS) $(CFLAGS) -MT testDoubleSum-testDoubleSum.o -MD -MP -MF $(DEPDIR)/testDoubleSum-testDoubleSum.Tpo -c -o testDoubleSum-testDoubleSum.o `test -f 'testDoubleSum.c' || echo '$(srcdir)/'`testDoubleSum.c
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/testDoubleSum-testDoubleSum.Tpo $(DEPDIR)/testDoubleSum-testDoubleSum.Po
diff --git a/src/statisticsFunctions/sum/testDoubleSum.c b/src/statisticsFunctions/sum/testDoubleSum.c
index 59ba295b..d8a57fe6 100644
--- a/src/statisticsFunctions/sum/testDoubleSum.c
+++ b/src/statisticsFunctions/sum/testDoubleSum.c
@@ -12,16 +12,21 @@
#include <assert.h>
#include <stdio.h>
+#include <math.h>
#include "sum.h"
/* #define LOCAL_DEBUG */
+#define ERROR(x) printf("diff = %e\n", x)
+
static int dsumsTest(void) {
- double value1 = 3.0f;
- double value2 = 1.123456789f;
+ double value1 = 3.0;
+ double value2 = 1.123456789;
+
+ printf("\n>>>> Sum Double Scalar Test\n");
+ assert(dsums(value1) == 3.0);
+ assert(dsums(value2) == 1.123456789);
- assert(dsums(value1) == 3.0f);
- assert(dsums(value2) == 1.123456789f);
return 0;
}
@@ -33,13 +38,162 @@ static int dsumaTest(void) {
9.186784563,
9.186784563};
+ printf("\n>>>> Sum Double Array Test\n");
assert(dsuma(table1, 3) == 9.0);
-#ifdef LOCAL_DEBUG
- printf("%e\n", dsuma(table2, 5));
- printf("%e\n", 9.186784563 + 9.186784563 + 9.186784563 + 9.186784563 + 9.186784563);
- printf("%e\n", (dsuma(table2, 5) - (9.186784563 + 9.186784563 + 9.186784563 + 9.186784563 + 9.186784563)) / dsuma(table2, 5));
-#endif
- assert((dsuma(table2, 5) - (9.186784563 + 9.186784563 + 9.186784563 + 9.186784563 + 9.186784563)) / dsuma(table2, 5) == 0.0);
+ assert((dsuma(table2, 5) - (9.186784 + 9.186784 + 9.186784 + 9.186784 + 9.186784)) / dsuma(table2, 5) < 1e-6);
+ return 0;
+}
+
+static int dcolumnsumaTest(void) {
+ int i = 0;
+ double table1[9] = {1.0, 4.0, 7.0, 2.0 , 5.0, 8.0, 3.0, 6.0, 9.0};
+ double table2[10] = {1.0, 2.0, 3.0, 4.0 , 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
+ double columnSummedTable1_3_3[3] = {0};
+ double columnSummedTable1_1_9[1] = {0};
+ double columnSummedTable1_9_1[9] = {0};
+ double columnSummedTable2_2_5[2] = {0};
+ double columnSummedTable2_5_2[5] = {0};
+
+ printf("\n>>>> Column Sum Double Array Test\n");
+ /*
+ [ 1 2 3 ]
+ [ 4 5 6 ] => [ 6 15 24 ]
+ [ 7 8 9 ]
+ */
+ dcolumnsuma(table1, 3, 3,columnSummedTable1_3_3);
+ assert(columnSummedTable1_3_3[0] == 6.0);
+ assert(columnSummedTable1_3_3[1] == 15.0);
+ assert(columnSummedTable1_3_3[2] == 24.0);
+
+ /*
+ [ 1 2 3 4 5 6 7 8 9 ] => [ 45 ]
+ */
+ dcolumnsuma(table1, 1, 9,columnSummedTable1_1_9);
+ assert(columnSummedTable1_1_9[0] == 45.0);
+
+ /*
+ [ 1 ]
+ [ 2 ]
+ [ 3 ]
+ [ 4 ]
+ [ 5 ] => [ 1 2 3 4 5 6 7 8 9 ]
+ [ 6 ]
+ [ 7 ]
+ [ 8 ]
+ [ 9 ]
+ */
+ dcolumnsuma(table1, 9, 1,columnSummedTable1_9_1);
+ for ( i = 0 ; i < 9 ; ++i) {
+ printf("columnSummedTable1_9_1[%d] = %e\n", i, columnSummedTable1_9_1[i]);
+ assert(columnSummedTable1_9_1[i] == table1[i]);
+ }
+
+ /*
+ [ 1 3 5 7 9 ]
+ [ 2 4 6 8 10 ] => [ 25 30 ]
+ */
+ dcolumnsuma(table2, 2, 5,columnSummedTable2_2_5);
+ assert(columnSummedTable2_2_5[0] == 25.0);
+ assert(columnSummedTable2_2_5[1] == 30.0);
+ for ( i = 0 ; i < 2 ; ++i) {
+ printf("columnSummedTable2_2_5[%d] = %e\n", i, columnSummedTable2_2_5[i]);
+ }
+
+ /*
+ [ 1 6 ]
+ [ 2 7 ] => [ 7 9 11 13 15 ]
+ [ 3 8 ]
+ [ 4 9 ]
+ [ 5 10 ]
+ */
+ dcolumnsuma(table2, 5, 2,columnSummedTable2_5_2);
+ assert(columnSummedTable2_5_2[0] == 7.0);
+ assert(columnSummedTable2_5_2[1] == 9.0);
+ assert(columnSummedTable2_5_2[2] == 11.0);
+ assert(columnSummedTable2_5_2[3] == 13.0);
+ assert(columnSummedTable2_5_2[4] == 15.0);
+ for ( i = 0 ; i < 5 ; ++i) {
+ printf("columnSummedTable2_5_2[%d] = %e\n", i, columnSummedTable2_5_2[i]);
+ }
+
+ return 0;
+}
+
+static int drowsumaTest(void) {
+ int i = 0;
+ double table1[9] = {1.0, 4.0, 7.0, 2.0 , 5.0, 8.0, 3.0, 6.0, 9.0};
+ double table2[10] = {1.0, 2.0, 3.0, 4.0 , 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
+ double rowSummedTable1_3_3[3] = {0};
+ double rowSummedTable1_1_9[9] = {0};
+ double rowSummedTable1_9_1[1] = {0};
+ double rowSummedTable2_2_5[5] = {0};
+ double rowSummedTable2_5_2[2] = {0};
+
+ printf("\n>>>> Row Sum Double Array Test\n");
+ /*
+ [ 1 2 3 ]
+ [ 4 5 6 ] => [ 12 15 18 ]
+ [ 7 8 9 ]
+ */
+ drowsuma(table1, 3, 3,rowSummedTable1_3_3);
+ for ( i = 0 ; i < 3 ; ++i) {
+ printf("rowSummedTable1_3_3[%d] = %e\n", i, rowSummedTable1_3_3[i]);
+ }
+ assert(rowSummedTable1_3_3[0] == 12.0);
+ assert(rowSummedTable1_3_3[1] == 15.0);
+ assert(rowSummedTable1_3_3[2] == 18.0);
+
+ /*
+ [ 1 ]
+ [ 2 ]
+ [ 3 ]
+ [ 4 ]
+ [ 5 ] => [ 1 2 3 4 5 6 7 8 9 ]
+ [ 6 ]
+ [ 7 ]
+ [ 8 ]
+ [ 9 ]
+ */
+ drowsuma(table1, 1, 9,rowSummedTable1_1_9);
+ for ( i = 0 ; i < 9 ; ++i) {
+ printf("rowSummedTable1_1_9[%d] = %e\n", i, rowSummedTable1_1_9[i]);
+ assert(rowSummedTable1_1_9[i] == table1[i]);
+ }
+
+ /*
+ [ 1 2 3 4 5 6 7 8 9 ] => [ 45 ]
+ */
+ drowsuma(table1, 9, 1,rowSummedTable1_9_1);
+ assert(rowSummedTable1_9_1[0] == 45.0);
+
+ /*
+ [ 1 3 5 7 9 ]
+ [ 2 4 6 8 10 ] => [ 3 7 11 15 19 ]
+ */
+ drowsuma(table2, 2, 5,rowSummedTable2_2_5);
+ assert(rowSummedTable2_2_5[0] == 3.0);
+ assert(rowSummedTable2_2_5[1] == 7.0);
+ assert(rowSummedTable2_2_5[2] == 11.0);
+ assert(rowSummedTable2_2_5[3] == 15.0);
+ assert(rowSummedTable2_2_5[4] == 19.0);
+ for ( i = 0 ; i < 5 ; ++i) {
+ printf("rowSummedTable2_2_5[%d] = %e\n", i, rowSummedTable2_2_5[i]);
+ }
+
+ /*
+ [ 1 6 ]
+ [ 2 7 ] => [ 15 40 ]
+ [ 3 8 ]
+ [ 4 9 ]
+ [ 5 10 ]
+ */
+ drowsuma(table2, 5, 2,rowSummedTable2_5_2);
+ assert(rowSummedTable2_5_2[0] == 15.0);
+ assert(rowSummedTable2_5_2[1] == 40.0);
+ for ( i = 0 ; i < 2 ; ++i) {
+ printf("rowSummedTable2_5_2[%d] = %e\n", i, rowSummedTable2_5_2[i]);
+ }
+
return 0;
}
@@ -47,6 +201,7 @@ static int zsumsTest(void) {
doubleComplex value1 = DoubleComplex(3.0, 3.0);
doubleComplex value2 = DoubleComplex(1.123456789, 1.123456789);
+ printf("\n>>>> Sum Double Complex Scalar Test\n");
assert(zreals(zsums(value1)) == 3.0);
assert(zimags(zsums(value1)) == 3.0);
assert(zreals(zsums(value2)) == 1.123456789);
@@ -57,9 +212,10 @@ static int zsumsTest(void) {
static int zsumaTest(void) {
doubleComplex value1 = DoubleComplex(3.0, 3.0);
doubleComplex table1[3];
- doubleComplex value2 = DoubleComplex(9.186784563, 9.186784563);
+ doubleComplex value2 = DoubleComplex(9.186784563,9.186784563);
doubleComplex table2[5];
+ printf("\n>>>> Sum Double Complex Array Test\n");
table1[0] = value1;
table1[1] = value1;
table1[2] = value1;
@@ -81,25 +237,256 @@ static int zsumaTest(void) {
#endif
assert(zreals(zsuma(table1, 3)) == 9.0);
assert(zimags(zsuma(table1, 3)) == 9.0);
- assert(zreals(zsuma(table2, 5)) == (9.186784563 + 9.186784563 + 9.186784563 + 9.186784563 + 9.186784563));
- assert(zimags(zsuma(table2, 5)) == (9.186784563 + 9.186784563 + 9.186784563 + 9.186784563 + 9.186784563));
+ assert(zreals(zsuma(table2, 5)) == 9.186784563 + 9.186784563 + 9.186784563 + 9.186784563 + 9.186784563);
+ assert(zimags(zsuma(table2, 5)) == 9.186784563 + 9.186784563 + 9.186784563 + 9.186784563 + 9.186784563);
+
+ return 0;
+}
+
+static int zrowsumaTest(void) {
+ int i = 0;
+ doubleComplex in[12];
+ doubleComplex rowSummedIn_4_3[3];
+ doubleComplex rowSummedIn_3_4[4];
+ doubleComplex rowSummedIn_6_2[2];
+ doubleComplex rowSummedIn_2_6[6];
+ doubleComplex rowSummedIn_1_12[12];
+ doubleComplex rowSummedIn_12_1[1];
+
+ printf("\n>>>> Row Sum Double Complex Array Test\n");
+ /* Init input var */
+ for (i = 0 ; i < 12 ; ++i)
+ {
+ in[i] = DoubleComplex((double) i / 10.0, (11.0 - (double) i) / 10.0);
+ }
+
+ /*
+ [ 1.1i 0.4+0.7i 0.8+0.3i ]
+ [ 0.1+i 0.5+0.6i 0.9+0.2i ] => [ 0.6+3.8i 2.2+2.2i 3.8+0.6i ]
+ [ 0.2+0.9i 0.6+0.5i 1+0.1i ]
+ [ 0.3+0.8i 0.7+0.4i 1.1 ]
+ */
+ zrowsuma(in, 4, 3, rowSummedIn_4_3);
+ for (i = 0 ; i < 3 ; ++i) {
+ printf("rowSummedIn_4_3[%d] = %e + %ei\n", i, zreals(rowSummedIn_4_3[i]), zimags(rowSummedIn_4_3[i]));
+ }
+ assert(fabs(zreals(rowSummedIn_4_3[0]) -0.6) < 2e-16);
+ assert(zimags(rowSummedIn_4_3[0]) == 3.8);
+ assert(zreals(rowSummedIn_4_3[1]) == 2.2);
+ assert(fabs(zimags(rowSummedIn_4_3[1]) - 2.2) < 1e-15);
+ assert(fabs(zreals(rowSummedIn_4_3[2]) - 3.8) < 1e-15);
+ assert(zimags(rowSummedIn_4_3[2]) == 0.6);
+
+ /*
+ [ 1.1i 0.3+0.8i 0.6+0.5i 0.9+0.2i ]
+ [ 0.1+i 0.4+0.7i 0.7+0.4i 1+0.1i ] => [ 0.3+3.i 1.2+2.1i 2.1+1.2i 3.+0.3i]
+ [ 0.2+0.9i 0.5+0.6i 0.8+0.3i 1.1 ]
+ */
+ zrowsuma(in, 3, 4, rowSummedIn_3_4);
+ for (i = 0 ; i < 4 ; ++i) {
+ printf("rowSummedIn_3_4[%d] = %e + %ei\n", i, zreals(rowSummedIn_3_4[i]), zimags(rowSummedIn_3_4[i]));
+ }
+ assert(fabs(zreals(rowSummedIn_3_4[0]) - 0.3) < 1e-16);
+ assert(zimags(rowSummedIn_3_4[0]) == 3.0);
+ assert(zreals(rowSummedIn_3_4[1]) == 1.2 && zimags(rowSummedIn_3_4[1]) == 2.1);
+ assert(fabs(zreals(rowSummedIn_3_4[2]) - 2.1) < 1e-15);
+ assert(zimags(rowSummedIn_3_4[2]) == 1.2);
+ assert(zreals(rowSummedIn_3_4[3]) == 3.0);
+ assert(fabs(zimags(rowSummedIn_3_4[3]) - 0.3) < 1e-16);
+
+ /*
+ [ 1.1i 0.6+0.5i ]
+ [ 0.1+i 0.7+0.4i ]
+ [ 0.2+0.9i 0.8+0.3i ] => [ 1.5+5.1i 5.1+1.5i ]
+ [ 0.3+0.8i 0.9+0.2i ]
+ [ 0.4+0.7i 1+0.1i ]
+ [ 0.5+0.6i 1.1 ]
+ */
+ zrowsuma(in, 6, 2, rowSummedIn_6_2);
+ for (i = 0 ; i < 2 ; ++i) {
+ printf("rowSummedIn_6_2[%d] = %e + %ei\n", i, zreals(rowSummedIn_6_2[i]), zimags(rowSummedIn_6_2[i]));
+ }
+ assert(zreals(rowSummedIn_6_2[0]) == 1.5 && zimags(rowSummedIn_6_2[0]) == 5.1);
+ assert(zreals(rowSummedIn_6_2[1]) == 5.1 && zimags(rowSummedIn_6_2[1]) == 1.5);
+
+ /*
+ [ 1.1i 0.2+0.9i 0.4+0.7i 0.6+0.5i 0.8+0.3i 1+0.1i ]
+ [ 0.1+i 0.3+0.8i 0.5+0.6i 0.7+0.4i 0.9+0.2i 1.1 ] => [ 0.1+2.1i 0.5+1.7i 0.9+1.3i 1.3+0.9i 1.7+0.5i 2.1+0.1i ]
+ */
+ zrowsuma(in, 2, 6, rowSummedIn_2_6);
+ for (i = 0 ; i < 6 ; ++i) {
+ printf("rowSummedIn_2_6[%d] = %e + %ei\n", i, zreals(rowSummedIn_2_6[i]), zimags(rowSummedIn_2_6[i]));
+ }
+ assert(zreals(rowSummedIn_2_6[0]) == 0.1 && zimags(rowSummedIn_2_6[0]) == 2.1);
+ assert(zreals(rowSummedIn_2_6[1]) == 0.5);
+ assert(fabs(zimags(rowSummedIn_2_6[1]) == 1.7) < 1e-16);
+ assert(zreals(rowSummedIn_2_6[2]) == 0.9);
+ assert(fabs(zimags(rowSummedIn_2_6[2]) == 1.3) < 1e-16);
+ assert(fabs(zreals(rowSummedIn_2_6[3]) == 1.3) < 1e-16);
+ assert(zimags(rowSummedIn_2_6[3]) == 0.9);
+ assert(fabs(zreals(rowSummedIn_2_6[4]) == 1.7) < 1e-16);
+ assert(zimags(rowSummedIn_2_6[4]) == 0.5);
+ assert(zreals(rowSummedIn_2_6[5]) == 2.1 && zimags(rowSummedIn_2_6[5]) == 0.1);
+
+ /*
+ [ 1.1i 0.1+i 0.2+0.9i 0.3+0.8i 0.4+0.7i 0.5+0.6i 0.6+0.5i 0.7+0.4i 0.8+0.3i 0.9+0.2i 1+0.1i 1.1 ]
+ =>
+ [ 1.1i 0.1+i 0.2+0.9i 0.3+0.8i 0.4+0.7i 0.5+0.6i 0.6+0.5i 0.7+0.4i 0.8+0.3i 0.9+0.2i 1+0.1i 1.1 ]
+ */
+ zrowsuma(in, 1, 12, rowSummedIn_1_12);
+ for (i = 0 ; i < 12 ; ++i) {
+ printf("rowSummedIn_1_12[%d] = %e + %ei\n", i, zreals(rowSummedIn_1_12[i]), zimags(rowSummedIn_1_12[i]));
+ assert(zreals(rowSummedIn_1_12[i]) == zreals(in[i]) && zimags(rowSummedIn_1_12[i]) == zimags(in[i]));
+ }
+
+ /*
+ [ 1.1i ]
+ [ 0.1+i ]
+ [ 0.2+0.9i ]
+ [ 0.3+0.8i ]
+ [ 0.4+0.7i ]
+ [ 0.5+0.6i ]
+ [ 0.6+0.5i ] => [ 6.6+6.6i ]
+ [ 0.7+0.4i ]
+ [ 0.8+0.3i ]
+ [ 0.9+0.2i ]
+ [ 1+0.1i ]
+ [ 1.1 ]
+ */
+ zrowsuma(in, 12, 1, rowSummedIn_12_1);
+ printf("rowSummedIn_12_1[%d] = %e + %ei\n", 0, zreals(rowSummedIn_12_1[0]), zimags(rowSummedIn_12_1[0]));
+ assert(zreals(rowSummedIn_12_1[0]) == 6.6 && zimags(rowSummedIn_12_1[0]) == 6.6);
+
+ return 0;
+}
+
+static int zcolumnsumaTest(void) {
+ int i = 0;
+ doubleComplex in[12];
+ doubleComplex columnSummedIn_4_3[4];
+ doubleComplex columnSummedIn_3_4[3];
+ doubleComplex columnSummedIn_6_2[6];
+ doubleComplex columnSummedIn_2_6[2];
+ doubleComplex columnSummedIn_1_12[1];
+ doubleComplex columnSummedIn_12_1[12];
+
+ printf("\n>>>> ColumnSum Double Complex Array Test\n");
+ /* Init input var */
+ for (i = 0 ; i < 12 ; ++i)
+ {
+ in[i] = DoubleComplex((double) i / 10.0, (11.0 - (double) i) / 10.0);
+ }
+
+ /*
+ [ 1.1i 0.4+0.7i 0.8+0.3i ]
+ [ 0.1+i 0.5+0.6i 0.9+0.2i ] => [ 1.2+2.1i 1.5+1.8i 1.8+1.5i 2.1+1.2i ]
+ [ 0.2+0.9i 0.6+0.5i 1+0.1i ]
+ [ 0.3+0.8i 0.7+0.4i 1.1 ]
+ */
+ zcolumnsuma(in, 4, 3, columnSummedIn_4_3);
+ for (i = 0 ; i < 4 ; ++i) {
+ printf("columnSummedIn_4_3[%d] = %e + %ei\n", i, zreals(columnSummedIn_4_3[i]), zimags(columnSummedIn_4_3[i]));
+ }
+ assert(fabs(zreals(columnSummedIn_4_3[0]) - 1.2) < 1e-15);
+ assert(zimags(columnSummedIn_4_3[0]) == 2.1);
+ assert(zreals(columnSummedIn_4_3[1]) == 1.5 && zimags(columnSummedIn_4_3[1]) == 1.8);
+ assert(zreals(columnSummedIn_4_3[2]) == 1.8 && zimags(columnSummedIn_4_3[2]) == 1.5);
+ assert(zreals(columnSummedIn_4_3[3]) == 2.1);
+ assert(fabs(zimags(columnSummedIn_4_3[3]) - 1.2) < 1e-15);
+
+ /*
+ [ 1.1i 0.3+0.8i 0.6+0.5i 0.9+0.2i ]
+ [ 0.1+i 0.4+0.7i 0.7+0.4i 1+0.1i ] => [ 1.8+2.6i 2.2+2.2i 2.6+1.8i ]
+ [ 0.2+0.9i 0.5+0.6i 0.8+0.3i 1.1 ]
+ */
+ zcolumnsuma(in, 3, 4, columnSummedIn_3_4);
+ for (i = 0 ; i < 3 ; ++i) {
+ printf("columnSummedIn_3_4[%d] = %e + %ei\n", i, zreals(columnSummedIn_3_4[i]), zimags(columnSummedIn_3_4[i]));
+ }
+ assert(fabs(zreals(columnSummedIn_3_4[0]) - 1.8) < 1e-15);
+ assert(fabs(zimags(columnSummedIn_3_4[0]) - 2.6) < 1e-15);
+ assert(zreals(columnSummedIn_3_4[1]) == 2.2 && zimags(columnSummedIn_3_4[1]) == 2.2);
+ assert(zreals(columnSummedIn_3_4[2]) == 2.6 && zimags(columnSummedIn_3_4[2]) == 1.8);
+
+ /*
+ [ 1.1i 0.6+0.5i ]
+ [ 0.1+i 0.7+0.4i ]
+ [ 0.2+0.9i 0.8+0.3i ] => [ 0.6+1.6i 0.8+1.4i 1+1.2i 1.2+i 1.4+0.8i 1.6+0.6i ]
+ [ 0.3+0.8i 0.9+0.2i ]
+ [ 0.4+0.7i 1+0.1i ]
+ [ 0.5+0.6i 1.1 ]
+ */
+ zcolumnsuma(in, 6, 2, columnSummedIn_6_2);
+ for (i = 0 ; i < 6 ; ++i) {
+ printf("columnSummedIn_6_2[%d] = %e + %ei\n", i, zreals(columnSummedIn_6_2[i]), zimags(columnSummedIn_6_2[i]));
+ }
+ assert(zreals(columnSummedIn_6_2[0]) == 0.6 && zimags(columnSummedIn_6_2[0]) == 1.6);
+ assert(fabs(zreals(columnSummedIn_6_2[1]) - 0.8) < 1e-15);
+ assert(zimags(columnSummedIn_6_2[1]) == 1.4);
+ assert(zreals(columnSummedIn_6_2[2]) == 1.0 && zimags(columnSummedIn_6_2[2]) == 1.2);
+ assert(zreals(columnSummedIn_6_2[3]) == 1.2 && zimags(columnSummedIn_6_2[3]) == 1.0);
+ assert(zreals(columnSummedIn_6_2[4]) == 1.4);
+ assert(fabs(zimags(columnSummedIn_6_2[4]) - 0.8) < 1e-15);
+ assert(zreals(columnSummedIn_6_2[5]) == 1.6 && zimags(columnSummedIn_6_2[5]) == 0.6);
+
+ /*
+ [ 1.1i 0.2+0.9i 0.4+0.7i 0.6+0.5i 0.8+0.3i 1+0.1i ]
+ [ 0.1+i 0.3+0.8i 0.5+0.6i 0.7+0.4i 0.9+0.2i 1.1 ] => [ 3+3.6i 3.6+3i ]
+ */
+ zcolumnsuma(in, 2, 6, columnSummedIn_2_6);
+ for (i = 0 ; i < 2 ; ++i) {
+ printf("columnSummedIn_2_6[%d] = %e + %ei\n", i, zreals(columnSummedIn_2_6[i]), zimags(columnSummedIn_2_6[i]));
+ }
+ assert(zreals(columnSummedIn_2_6[0]) == 3.0 && zimags(columnSummedIn_2_6[0]) == 3.6);
+ assert(zreals(columnSummedIn_2_6[1]) == 3.6 && zimags(columnSummedIn_2_6[1]) == 3.0);
+
+ /*
+ [ 1.1i 0.1+i 0.2+0.9i 0.3+0.8i 0.4+0.7i 0.5+0.6i 0.6+0.5i 0.7+0.4i 0.8+0.3i 0.9+0.2i 1+0.1i 1.1 ]
+ =>
+ [ 6.6+6.6i ]
+ */
+ zcolumnsuma(in, 1, 12, columnSummedIn_1_12);
+ printf("columnSummedIn_1_12[%d] = %e + %ei\n", 0, zreals(columnSummedIn_1_12[0]), zimags(columnSummedIn_1_12[0]));
+ assert(zreals(columnSummedIn_1_12[0]) == 6.6 && zimags(columnSummedIn_1_12[0]) == 6.6);
+
+
+ /*
+ [ 1.1i ]
+ [ 0.1+i ]
+ [ 0.2+0.9i ]
+ [ 0.3+0.8i ]
+ [ 0.4+0.7i ]
+ [ 0.5+0.6i ]
+ [ 0.6+0.5i ] => [ 1.1i 0.1+i 0.2+0.9i 0.3+0.8i 0.4+0.7i 0.5+0.6i 0.6+0.5i 0.7+0.4i 0.8+0.3i 0.9+0.2i 1+0.1i 1.1 ]
+ [ 0.7+0.4i ]
+ [ 0.8+0.3i ]
+ [ 0.9+0.2i ]
+ [ 1+0.1i ]
+ [ 1.1 ]
+ */
+ zcolumnsuma(in, 12, 1, columnSummedIn_12_1);
+ for (i = 0 ; i < 12 ; ++i) {
+ printf("columnSummedIn_12_1[%d] = %e + %ei\n", i, zreals(columnSummedIn_12_1[i]), zimags(columnSummedIn_12_1[i]));
+ assert(zreals(columnSummedIn_12_1[i]) == zreals(in[i]) && zimags(columnSummedIn_12_1[i]) == zimags(in[i]));
+ }
return 0;
}
static int testSum(void) {
- printf("\n>>>> Sum Tests\n");
dsumsTest();
dsumaTest();
+ drowsumaTest();
+ dcolumnsumaTest();
zsumsTest();
zsumaTest();
+ zrowsumaTest();
+ zcolumnsumaTest();
return 0;
}
-
-
int main(void) {
assert(testSum() == 0);
return 0;
diff --git a/src/statisticsFunctions/sum/testFloatSum.c b/src/statisticsFunctions/sum/testFloatSum.c
index 45c11419..090075c7 100644
--- a/src/statisticsFunctions/sum/testFloatSum.c
+++ b/src/statisticsFunctions/sum/testFloatSum.c
@@ -12,6 +12,7 @@
#include <assert.h>
#include <stdio.h>
+#include <math.h>
#include "sum.h"
/* #define LOCAL_DEBUG */
@@ -20,8 +21,10 @@ static int ssumsTest(void) {
float value1 = 3.0f;
float value2 = 1.123456789f;
+ printf("\n>>>> Sum Float Scalar Test\n");
assert(ssums(value1) == 3.0f);
assert(ssums(value2) == 1.123456789f);
+
return 0;
}
@@ -33,20 +36,170 @@ static int ssumaTest(void) {
9.186784563f,
9.186784563f};
+ printf("\n>>>> Sum Float Array Test\n");
assert(ssuma(table1, 3) == 9.0f);
-#ifdef LOCAL_DEBUG
- printf("%e\n",ssuma(table2, 5));
- printf("%e\n", 9.186784f + 9.186784f + 9.186784f + 9.186784f + 9.186784f);
- printf("%e\n", (ssuma(table2, 5) - (9.186784f + 9.186784f + 9.186784f + 9.186784f + 9.186784f)) / ssuma(table2, 5));
-#endif
assert((ssuma(table2, 5) - (9.186784f + 9.186784f + 9.186784f + 9.186784f + 9.186784f)) / ssuma(table2, 5) < 1e-6);
return 0;
}
+static int scolumnsumaTest(void) {
+ int i = 0;
+ float table1[9] = {1.0f, 4.0f, 7.0f, 2.0f , 5.0f, 8.0f, 3.0f, 6.0f, 9.0f};
+ float table2[10] = {1.0f, 2.0f, 3.0f, 4.0f , 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f};
+ float columnSummedTable1_3_3[3] = {0};
+ float columnSummedTable1_1_9[1] = {0};
+ float columnSummedTable1_9_1[9] = {0};
+ float columnSummedTable2_2_5[2] = {0};
+ float columnSummedTable2_5_2[5] = {0};
+
+ printf("\n>>>> Column Sum Float Array Test\n");
+ /*
+ [ 1 2 3 ]
+ [ 4 5 6 ] => [ 6 15 24 ]
+ [ 7 8 9 ]
+ */
+ scolumnsuma(table1, 3, 3,columnSummedTable1_3_3);
+ assert(columnSummedTable1_3_3[0] == 6.0f);
+ assert(columnSummedTable1_3_3[1] == 15.0f);
+ assert(columnSummedTable1_3_3[2] == 24.0f);
+
+ /*
+ [ 1 2 3 4 5 6 7 8 9 ] => [ 45 ]
+ */
+ scolumnsuma(table1, 1, 9,columnSummedTable1_1_9);
+ assert(columnSummedTable1_1_9[0] == 45.0f);
+
+ /*
+ [ 1 ]
+ [ 2 ]
+ [ 3 ]
+ [ 4 ]
+ [ 5 ] => [ 1 2 3 4 5 6 7 8 9 ]
+ [ 6 ]
+ [ 7 ]
+ [ 8 ]
+ [ 9 ]
+ */
+ scolumnsuma(table1, 9, 1,columnSummedTable1_9_1);
+ for ( i = 0 ; i < 9 ; ++i) {
+ printf("columnSummedTable1_9_1[%d] = %e\n", i, columnSummedTable1_9_1[i]);
+ assert(columnSummedTable1_9_1[i] == table1[i]);
+ }
+
+ /*
+ [ 1 3 5 7 9 ]
+ [ 2 4 6 8 10 ] => [ 25 30 ]
+ */
+ scolumnsuma(table2, 2, 5,columnSummedTable2_2_5);
+ assert(columnSummedTable2_2_5[0] == 25.0f);
+ assert(columnSummedTable2_2_5[1] == 30.0f);
+ for ( i = 0 ; i < 2 ; ++i) {
+ printf("columnSummedTable2_2_5[%d] = %e\n", i, columnSummedTable2_2_5[i]);
+ }
+
+ /*
+ [ 1 6 ]
+ [ 2 7 ] => [ 7 9 11 13 15 ]
+ [ 3 8 ]
+ [ 4 9 ]
+ [ 5 10 ]
+ */
+ scolumnsuma(table2, 5, 2,columnSummedTable2_5_2);
+ assert(columnSummedTable2_5_2[0] == 7.0f);
+ assert(columnSummedTable2_5_2[1] == 9.0f);
+ assert(columnSummedTable2_5_2[2] == 11.0f);
+ assert(columnSummedTable2_5_2[3] == 13.0f);
+ assert(columnSummedTable2_5_2[4] == 15.0f);
+ for ( i = 0 ; i < 5 ; ++i) {
+ printf("columnSummedTable2_5_2[%d] = %e\n", i, columnSummedTable2_5_2[i]);
+ }
+
+ return 0;
+}
+
+static int srowsumaTest(void) {
+ int i = 0;
+ float table1[9] = {1.0f, 4.0f, 7.0f, 2.0f , 5.0f, 8.0f, 3.0f, 6.0f, 9.0f};
+ float table2[10] = {1.0f, 2.0f, 3.0f, 4.0f , 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f};
+ float rowSummedTable1_3_3[3] = {0};
+ float rowSummedTable1_1_9[9] = {0};
+ float rowSummedTable1_9_1[1] = {0};
+ float rowSummedTable2_2_5[5] = {0};
+ float rowSummedTable2_5_2[2] = {0};
+
+ printf("\n>>>> Row Sum Float Array Test\n");
+ /*
+ [ 1 2 3 ]
+ [ 4 5 6 ] => [ 12 15 18 ]
+ [ 7 8 9 ]
+ */
+ srowsuma(table1, 3, 3,rowSummedTable1_3_3);
+ for ( i = 0 ; i < 3 ; ++i) {
+ printf("rowSummedTable1_3_3[%d] = %e\n", i, rowSummedTable1_3_3[i]);
+ }
+ assert(rowSummedTable1_3_3[0] == 12.0f);
+ assert(rowSummedTable1_3_3[1] == 15.0f);
+ assert(rowSummedTable1_3_3[2] == 18.0f);
+
+ /*
+ [ 1 ]
+ [ 2 ]
+ [ 3 ]
+ [ 4 ]
+ [ 5 ] => [ 1 2 3 4 5 6 7 8 9 ]
+ [ 6 ]
+ [ 7 ]
+ [ 8 ]
+ [ 9 ]
+ */
+ srowsuma(table1, 1, 9,rowSummedTable1_1_9);
+ for ( i = 0 ; i < 9 ; ++i) {
+ printf("rowSummedTable1_1_9[%d] = %e\n", i, rowSummedTable1_1_9[i]);
+ assert(rowSummedTable1_1_9[i] == table1[i]);
+ }
+
+ /*
+ [ 1 2 3 4 5 6 7 8 9 ] => [ 45 ]
+ */
+ srowsuma(table1, 9, 1,rowSummedTable1_9_1);
+ assert(rowSummedTable1_9_1[0] == 45.0f);
+
+ /*
+ [ 1 3 5 7 9 ]
+ [ 2 4 6 8 10 ] => [ 3 7 11 15 19 ]
+ */
+ srowsuma(table2, 2, 5,rowSummedTable2_2_5);
+ assert(rowSummedTable2_2_5[0] == 3.0f);
+ assert(rowSummedTable2_2_5[1] == 7.0f);
+ assert(rowSummedTable2_2_5[2] == 11.0f);
+ assert(rowSummedTable2_2_5[3] == 15.0f);
+ assert(rowSummedTable2_2_5[4] == 19.0f);
+ for ( i = 0 ; i < 5 ; ++i) {
+ printf("rowSummedTable2_2_5[%d] = %e\n", i, rowSummedTable2_2_5[i]);
+ }
+
+ /*
+ [ 1 6 ]
+ [ 2 7 ] => [ 15 40 ]
+ [ 3 8 ]
+ [ 4 9 ]
+ [ 5 10 ]
+ */
+ srowsuma(table2, 5, 2,rowSummedTable2_5_2);
+ assert(rowSummedTable2_5_2[0] == 15.0f);
+ assert(rowSummedTable2_5_2[1] == 40.0f);
+ for ( i = 0 ; i < 2 ; ++i) {
+ printf("rowSummedTable2_5_2[%d] = %e\n", i, rowSummedTable2_5_2[i]);
+ }
+
+ return 0;
+}
+
static int csumsTest(void) {
floatComplex value1 = FloatComplex(3.0f, 3.0f);
floatComplex value2 = FloatComplex(1.123456789f, 1.123456789f);
+ printf("\n>>>> Sum Float Complex Scalar Test\n");
assert(creals(csums(value1)) == 3.0f);
assert(cimags(csums(value1)) == 3.0f);
assert(creals(csums(value2)) == 1.123456789f);
@@ -60,6 +213,7 @@ static int csumaTest(void) {
floatComplex value2 = FloatComplex(9.186784563f,9.186784563f);
floatComplex table2[5];
+ printf("\n>>>> Sum Float Complex Array Test\n");
table1[0] = value1;
table1[1] = value1;
table1[2] = value1;
@@ -87,13 +241,236 @@ static int csumaTest(void) {
return 0;
}
+static int crowsumaTest(void) {
+ int i = 0;
+ floatComplex in[12];
+ floatComplex rowSummedIn_4_3[3];
+ floatComplex rowSummedIn_3_4[4];
+ floatComplex rowSummedIn_6_2[2];
+ floatComplex rowSummedIn_2_6[6];
+ floatComplex rowSummedIn_1_12[12];
+ floatComplex rowSummedIn_12_1[1];
+
+ printf("\n>>>> Row Sum Float Complex Array Test\n");
+ /* Init input var */
+ for (i = 0 ; i < 12 ; ++i)
+ {
+ in[i] = FloatComplex((float) i / 10.0f, (11.0f - (float) i) / 10.0f);
+ }
+
+ /*
+ [ 1.1i 0.4+0.7i 0.8+0.3i ]
+ [ 0.1+i 0.5+0.6i 0.9+0.2i ] => [ 0.6+3.8i 2.2+2.2i 3.8+0.6i ]
+ [ 0.2+0.9i 0.6+0.5i 1+0.1i ]
+ [ 0.3+0.8i 0.7+0.4i 1.1 ]
+ */
+ crowsuma(in, 4, 3, rowSummedIn_4_3);
+ for (i = 0 ; i < 3 ; ++i) {
+ printf("rowSummedIn_4_3[%d] = %e + %ei\n", i, creals(rowSummedIn_4_3[i]), cimags(rowSummedIn_4_3[i]));
+ }
+ assert(creals(rowSummedIn_4_3[0]) == 0.6f && cimags(rowSummedIn_4_3[0]) == 3.8f);
+ assert(creals(rowSummedIn_4_3[1]) == 2.2f && cimags(rowSummedIn_4_3[1]) == 2.2f);
+ assert(fabs(creals(rowSummedIn_4_3[2]) - 3.8f) < 1e-06);
+ assert(cimags(rowSummedIn_4_3[2]) == 0.6f);
+
+ /*
+ [ 1.1i 0.3+0.8i 0.6+0.5i 0.9+0.2i ]
+ [ 0.1+i 0.4+0.7i 0.7+0.4i 1+0.1i ] => [ 0.3+3.i 1.2+2.1i 2.1+1.2i 3.+0.3i]
+ [ 0.2+0.9i 0.5+0.6i 0.8+0.3i 1.1 ]
+ */
+ crowsuma(in, 3, 4, rowSummedIn_3_4);
+ for (i = 0 ; i < 4 ; ++i) {
+ printf("rowSummedIn_3_4[%d] = %e + %ei\n", i, creals(rowSummedIn_3_4[i]), cimags(rowSummedIn_3_4[i]));
+ }
+ assert(creals(rowSummedIn_3_4[0]) == 0.3f && cimags(rowSummedIn_3_4[0]) == 3.0f);
+ assert(creals(rowSummedIn_3_4[1]) == 1.2f && cimags(rowSummedIn_3_4[1]) == 2.1f);
+ assert(creals(rowSummedIn_3_4[2]) == 2.1f && cimags(rowSummedIn_3_4[2]) == 1.2f);
+ assert(creals(rowSummedIn_3_4[3]) == 3.0f && cimags(rowSummedIn_3_4[3]) == 0.3f);
+
+ /*
+ [ 1.1i 0.6+0.5i ]
+ [ 0.1+i 0.7+0.4i ]
+ [ 0.2+0.9i 0.8+0.3i ] => [ 1.5+5.1i 5.1+1.5i ]
+ [ 0.3+0.8i 0.9+0.2i ]
+ [ 0.4+0.7i 1+0.1i ]
+ [ 0.5+0.6i 1.1 ]
+ */
+ crowsuma(in, 6, 2, rowSummedIn_6_2);
+ for (i = 0 ; i < 2 ; ++i) {
+ printf("rowSummedIn_6_2[%d] = %e + %ei\n", i, creals(rowSummedIn_6_2[i]), cimags(rowSummedIn_6_2[i]));
+ }
+ assert(creals(rowSummedIn_6_2[0]) == 1.5f && cimags(rowSummedIn_6_2[0]) == 5.1f);
+ assert(creals(rowSummedIn_6_2[1]) == 5.1f);
+ assert(fabs(cimags(rowSummedIn_6_2[1]) - 1.5f) < 1e-06);
+
+ /*
+ [ 1.1i 0.2+0.9i 0.4+0.7i 0.6+0.5i 0.8+0.3i 1+0.1i ]
+ [ 0.1+i 0.3+0.8i 0.5+0.6i 0.7+0.4i 0.9+0.2i 1.1 ] => [ 0.1+2.1i 0.5+1.7i 0.9+1.3i 1.3+0.9i 1.7+0.5i 2.1+0.1i ]
+ */
+ crowsuma(in, 2, 6, rowSummedIn_2_6);
+ for (i = 0 ; i < 6 ; ++i) {
+ printf("rowSummedIn_2_6[%d] = %e + %ei\n", i, creals(rowSummedIn_2_6[i]), cimags(rowSummedIn_2_6[i]));
+ }
+ assert(creals(rowSummedIn_2_6[0]) == 0.1f && cimags(rowSummedIn_2_6[0]) == 2.1f);
+ assert(creals(rowSummedIn_2_6[1]) == 0.5f && cimags(rowSummedIn_2_6[1]) == 1.7f);
+ assert(creals(rowSummedIn_2_6[2]) == 0.9f && cimags(rowSummedIn_2_6[2]) == 1.3f);
+ assert(creals(rowSummedIn_2_6[3]) == 1.3f && cimags(rowSummedIn_2_6[3]) == 0.9f);
+ assert(creals(rowSummedIn_2_6[4]) == 1.7f && cimags(rowSummedIn_2_6[4]) == 0.5f);
+ assert(creals(rowSummedIn_2_6[5]) == 2.1f && cimags(rowSummedIn_2_6[5]) == 0.1f);
+
+ /*
+ [ 1.1i 0.1+i 0.2+0.9i 0.3+0.8i 0.4+0.7i 0.5+0.6i 0.6+0.5i 0.7+0.4i 0.8+0.3i 0.9+0.2i 1+0.1i 1.1 ]
+ =>
+ [ 1.1i 0.1+i 0.2+0.9i 0.3+0.8i 0.4+0.7i 0.5+0.6i 0.6+0.5i 0.7+0.4i 0.8+0.3i 0.9+0.2i 1+0.1i 1.1 ]
+ */
+ crowsuma(in, 1, 12, rowSummedIn_1_12);
+ for (i = 0 ; i < 12 ; ++i) {
+ printf("rowSummedIn_1_12[%d] = %e + %ei\n", i, creals(rowSummedIn_1_12[i]), cimags(rowSummedIn_1_12[i]));
+ assert(creals(rowSummedIn_1_12[i]) == creals(in[i]) && cimags(rowSummedIn_1_12[i]) == cimags(in[i]));
+ }
+
+ /*
+ [ 1.1i ]
+ [ 0.1+i ]
+ [ 0.2+0.9i ]
+ [ 0.3+0.8i ]
+ [ 0.4+0.7i ]
+ [ 0.5+0.6i ]
+ [ 0.6+0.5i ] => [ 6.6+6.6i ]
+ [ 0.7+0.4i ]
+ [ 0.8+0.3i ]
+ [ 0.9+0.2i ]
+ [ 1+0.1i ]
+ [ 1.1 ]
+ */
+ crowsuma(in, 12, 1, rowSummedIn_12_1);
+ printf("rowSummedIn_12_1[%d] = %e + %ei\n", 0, creals(rowSummedIn_12_1[0]), cimags(rowSummedIn_12_1[0]));
+ assert(creals(rowSummedIn_12_1[0]) == 6.6f && cimags(rowSummedIn_12_1[0]) == 6.6f);
+
+ return 0;
+}
+
+static int ccolumnsumaTest(void) {
+ int i = 0;
+ floatComplex in[12];
+ floatComplex columnSummedIn_4_3[4];
+ floatComplex columnSummedIn_3_4[3];
+ floatComplex columnSummedIn_6_2[6];
+ floatComplex columnSummedIn_2_6[2];
+ floatComplex columnSummedIn_1_12[1];
+ floatComplex columnSummedIn_12_1[12];
+
+ printf("\n>>>> ColumnSum Float Complex Array Test\n");
+ /* Init input var */
+ for (i = 0 ; i < 12 ; ++i)
+ {
+ in[i] = FloatComplex((float) i / 10.0f, (11.0f - (float) i) / 10.0f);
+ }
+
+ /*
+ [ 1.1i 0.4+0.7i 0.8+0.3i ]
+ [ 0.1+i 0.5+0.6i 0.9+0.2i ] => [ 1.2+2.1i 1.5+1.8i 1.8+1.5i 2.1+1.2i ]
+ [ 0.2+0.9i 0.6+0.5i 1+0.1i ]
+ [ 0.3+0.8i 0.7+0.4i 1.1 ]
+ */
+ ccolumnsuma(in, 4, 3, columnSummedIn_4_3);
+ for (i = 0 ; i < 4 ; ++i) {
+ printf("columnSummedIn_4_3[%d] = %e + %ei\n", i, creals(columnSummedIn_4_3[i]), cimags(columnSummedIn_4_3[i]));
+ }
+ assert(creals(columnSummedIn_4_3[0]) == 1.2f && cimags(columnSummedIn_4_3[0]) == 2.1f);
+ assert(creals(columnSummedIn_4_3[1]) == 1.5f);
+ assert(fabs(cimags(columnSummedIn_4_3[1]) - 1.8f) < 1e-06);
+ assert(creals(columnSummedIn_4_3[2]) == 1.8f && cimags(columnSummedIn_4_3[2]) == 1.5f);
+ assert(creals(columnSummedIn_4_3[3]) == 2.1f && cimags(columnSummedIn_4_3[3]) == 1.2f);
+
+ /*
+ [ 1.1i 0.3+0.8i 0.6+0.5i 0.9+0.2i ]
+ [ 0.1+i 0.4+0.7i 0.7+0.4i 1+0.1i ] => [ 1.8+2.6i 2.2+2.2i 2.6+1.8i ]
+ [ 0.2+0.9i 0.5+0.6i 0.8+0.3i 1.1 ]
+ */
+ ccolumnsuma(in, 3, 4, columnSummedIn_3_4);
+ for (i = 0 ; i < 3 ; ++i) {
+ printf("columnSummedIn_3_4[%d] = %e + %ei\n", i, creals(columnSummedIn_3_4[i]), cimags(columnSummedIn_3_4[i]));
+ }
+ assert(creals(columnSummedIn_3_4[0]) == 1.8f);
+ assert(fabs(cimags(columnSummedIn_3_4[0]) - 2.6f) < 1e-06);
+ assert(creals(columnSummedIn_3_4[1]) == 2.2f && cimags(columnSummedIn_3_4[1]) == 2.2f);
+ assert(creals(columnSummedIn_3_4[2]) == 2.6f && cimags(columnSummedIn_3_4[2]) == 1.8f);
+
+ /*
+ [ 1.1i 0.6+0.5i ]
+ [ 0.1+i 0.7+0.4i ]
+ [ 0.2+0.9i 0.8+0.3i ] => [ 0.6+1.6i 0.8+1.4i 1+1.2i 1.2+i 1.4+0.8i 1.6+0.6i ]
+ [ 0.3+0.8i 0.9+0.2i ]
+ [ 0.4+0.7i 1+0.1i ]
+ [ 0.5+0.6i 1.1 ]
+ */
+ ccolumnsuma(in, 6, 2, columnSummedIn_6_2);
+ for (i = 0 ; i < 6 ; ++i) {
+ printf("columnSummedIn_6_2[%d] = %e + %ei\n", i, creals(columnSummedIn_6_2[i]), cimags(columnSummedIn_6_2[i]));
+ }
+ assert(creals(columnSummedIn_6_2[0]) == 0.6f && cimags(columnSummedIn_6_2[0]) == 1.6f);
+ assert(creals(columnSummedIn_6_2[1]) == 0.8f && cimags(columnSummedIn_6_2[1]) == 1.4f);
+ assert(creals(columnSummedIn_6_2[2]) == 1.0f && cimags(columnSummedIn_6_2[2]) == 1.2f);
+ assert(creals(columnSummedIn_6_2[3]) == 1.2f && cimags(columnSummedIn_6_2[3]) == 1.0f);
+ assert(creals(columnSummedIn_6_2[4]) == 1.4f && cimags(columnSummedIn_6_2[4]) == 0.8f);
+ assert(creals(columnSummedIn_6_2[5]) == 1.6f && cimags(columnSummedIn_6_2[5]) == 0.6f);
+
+ /*
+ [ 1.1i 0.2+0.9i 0.4+0.7i 0.6+0.5i 0.8+0.3i 1+0.1i ]
+ [ 0.1+i 0.3+0.8i 0.5+0.6i 0.7+0.4i 0.9+0.2i 1.1 ] => [ 3+3.6i 3.6+3i ]
+ */
+ ccolumnsuma(in, 2, 6, columnSummedIn_2_6);
+ for (i = 0 ; i < 2 ; ++i) {
+ printf("columnSummedIn_2_6[%d] = %e + %ei\n", i, creals(columnSummedIn_2_6[i]), cimags(columnSummedIn_2_6[i]));
+ }
+ assert(creals(columnSummedIn_2_6[0]) == 3.0f && cimags(columnSummedIn_2_6[0]) == 3.6f);
+ assert(creals(columnSummedIn_2_6[1]) == 3.6f);
+ assert(fabs(cimags(columnSummedIn_2_6[1]) -3.0f) < 1e-06);
+
+ /*
+ [ 1.1i 0.1+i 0.2+0.9i 0.3+0.8i 0.4+0.7i 0.5+0.6i 0.6+0.5i 0.7+0.4i 0.8+0.3i 0.9+0.2i 1+0.1i 1.1 ]
+ =>
+ [ 6.6+6.6i ]
+ */
+ ccolumnsuma(in, 1, 12, columnSummedIn_1_12);
+ printf("columnSummedIn_1_12[%d] = %e + %ei\n", 0, creals(columnSummedIn_1_12[0]), cimags(columnSummedIn_1_12[0]));
+ assert(creals(columnSummedIn_1_12[0]) == 6.6f && cimags(columnSummedIn_1_12[0]) == 6.6f);
+
+
+ /*
+ [ 1.1i ]
+ [ 0.1+i ]
+ [ 0.2+0.9i ]
+ [ 0.3+0.8i ]
+ [ 0.4+0.7i ]
+ [ 0.5+0.6i ]
+ [ 0.6+0.5i ] => [ 1.1i 0.1+i 0.2+0.9i 0.3+0.8i 0.4+0.7i 0.5+0.6i 0.6+0.5i 0.7+0.4i 0.8+0.3i 0.9+0.2i 1+0.1i 1.1 ]
+ [ 0.7+0.4i ]
+ [ 0.8+0.3i ]
+ [ 0.9+0.2i ]
+ [ 1+0.1i ]
+ [ 1.1 ]
+ */
+ ccolumnsuma(in, 12, 1, columnSummedIn_12_1);
+ for (i = 0 ; i < 12 ; ++i) {
+ printf("columnSummedIn_12_1[%d] = %e + %ei\n", i, creals(columnSummedIn_12_1[i]), cimags(columnSummedIn_12_1[i]));
+ assert(creals(columnSummedIn_12_1[i]) == creals(in[i]) && cimags(columnSummedIn_12_1[i]) == cimags(in[i]));
+ }
+
+ return 0;
+}
+
static int testSum(void) {
- printf("\n>>>> Sum Tests\n");
ssumsTest();
ssumaTest();
+ srowsumaTest();
+ scolumnsumaTest();
csumsTest();
csumaTest();
+ crowsumaTest();
+ ccolumnsumaTest();
return 0;
}