diff options
Diffstat (limited to 'src/auxiliaryFunctions')
-rw-r--r-- | src/auxiliaryFunctions/abs/Makefile.am | 9 | ||||
-rw-r--r-- | src/auxiliaryFunctions/abs/Makefile.in | 9 | ||||
-rw-r--r-- | src/auxiliaryFunctions/abs/cabss.c | 19 | ||||
-rw-r--r-- | src/auxiliaryFunctions/abs/testAbs.c | 70 | ||||
-rw-r--r-- | src/auxiliaryFunctions/abs/testAbs.h | 30 | ||||
-rw-r--r-- | src/auxiliaryFunctions/abs/zabss.c | 19 | ||||
-rw-r--r-- | src/auxiliaryFunctions/includes/abs.h | 23 |
7 files changed, 172 insertions, 7 deletions
diff --git a/src/auxiliaryFunctions/abs/Makefile.am b/src/auxiliaryFunctions/abs/Makefile.am index 49ca836a..531add54 100644 --- a/src/auxiliaryFunctions/abs/Makefile.am +++ b/src/auxiliaryFunctions/abs/Makefile.am @@ -5,13 +5,14 @@ ## Made by Bruno JOFRET <bruno.jofret@inria.fr> ## ## Started on Fri Jan 5 10:19:16 2007 jofret -## Last update Fri Apr 20 16:35:05 2007 jofret +## Last update Mon Apr 23 17:21:00 2007 jofret ## ## Copyright INRIA 2007 ## AM_CFLAGS = -I ../../type \ - -I ../includes + -I ../includes \ + -I ../../elementaryFunctions/includes instdir = $(top_builddir)/lib @@ -36,7 +37,8 @@ HEAD = ../includes/abs.h # Checking Part #### -check_INCLUDES = -I $(top_builddir)/elementaryFunctions/includes \ +check_INCLUDES = -I $(top_builddir)/auxiliaryFunctions/includes \ + -I $(top_builddir)/elementaryFunctions/includes \ -I $(top_builddir)/type check_PROGRAMS = testAbs @@ -51,4 +53,5 @@ testAbs_CFLAGS = $(check_INCLUDES) testAbs_LDADD = $(top_builddir)/lib/libDoubleComplex.a \ $(top_builddir)/lib/libFloatComplex.a \ $(top_builddir)/lib/libAbs.a \ + $(top_builddir)/lib/libSqrt.a \ @LIBMATH@ diff --git a/src/auxiliaryFunctions/abs/Makefile.in b/src/auxiliaryFunctions/abs/Makefile.in index 56470b66..51affe23 100644 --- a/src/auxiliaryFunctions/abs/Makefile.in +++ b/src/auxiliaryFunctions/abs/Makefile.in @@ -70,7 +70,7 @@ am_testAbs_OBJECTS = testAbs-testAbs.$(OBJEXT) testAbs_OBJECTS = $(am_testAbs_OBJECTS) testAbs_DEPENDENCIES = $(top_builddir)/lib/libDoubleComplex.a \ $(top_builddir)/lib/libFloatComplex.a \ - $(top_builddir)/lib/libAbs.a + $(top_builddir)/lib/libAbs.a $(top_builddir)/lib/libSqrt.a DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/includes depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__depfiles_maybe = depfiles @@ -179,7 +179,8 @@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ AM_CFLAGS = -I ../../type \ - -I ../includes + -I ../includes \ + -I ../../elementaryFunctions/includes instdir = $(top_builddir)/lib inst_LIBRARIES = libAbs.a @@ -199,7 +200,8 @@ HEAD = ../includes/abs.h #### # Checking Part #### -check_INCLUDES = -I $(top_builddir)/elementaryFunctions/includes \ +check_INCLUDES = -I $(top_builddir)/auxiliaryFunctions/includes \ + -I $(top_builddir)/elementaryFunctions/includes \ -I $(top_builddir)/type TESTS = testAbs @@ -212,6 +214,7 @@ testAbs_CFLAGS = $(check_INCLUDES) testAbs_LDADD = $(top_builddir)/lib/libDoubleComplex.a \ $(top_builddir)/lib/libFloatComplex.a \ $(top_builddir)/lib/libAbs.a \ + $(top_builddir)/lib/libSqrt.a \ @LIBMATH@ all: all-am diff --git a/src/auxiliaryFunctions/abs/cabss.c b/src/auxiliaryFunctions/abs/cabss.c index e69de29b..a9826990 100644 --- a/src/auxiliaryFunctions/abs/cabss.c +++ b/src/auxiliaryFunctions/abs/cabss.c @@ -0,0 +1,19 @@ +/* +** -*- C -*- +** +** cabss.c +** Made by Bruno JOFRET <bruno.jofret@inria.fr> +** +** Started on Mon Apr 23 17:08:52 2007 jofret +** Last update Mon Apr 23 17:10:22 2007 jofret +** +** Copyright INRIA 2007 +*/ + +#include "abs.h" + +float cabss(floatComplex in) { + float real = creals(in); + float imag = cimags(in); + return (ssqrts( (real*real) + (imag*imag) )); +} diff --git a/src/auxiliaryFunctions/abs/testAbs.c b/src/auxiliaryFunctions/abs/testAbs.c new file mode 100644 index 00000000..6cacc953 --- /dev/null +++ b/src/auxiliaryFunctions/abs/testAbs.c @@ -0,0 +1,70 @@ +/* +** -*- C -*- +** +** testAbs.c +** Made by Bruno JOFRET <bruno.jofret@inria.fr> +** +** Started on Wed Feb 14 15:50:15 2007 jofret +** Last update Mon Apr 23 17:40:12 2007 jofret +** +** Copyright INRIA 2007 +*/ + +#include "testAbs.h" + +int sabssTest() { + printf(">> Floats \n"); + float value1 = -123456.789; + float value2 = 987654.321; + assert(sabss(value1) == -value1); + assert(sabss(value2) == value2); + assert(sabss(0) == 0); + assert(sabss(-1) == 1); + assert(sabss(1) == 1); + return 0; +} + +int dabssTest() { + printf(">> Doubles \n"); + double value1 = -123456.789; + double value2 = 987654.321; + assert(dabss(value1) == -value1); + assert(dabss(value2) == value2); + assert(dabss(0) == 0); + assert(dabss(-1) == 1); + assert(dabss(1) == 1); + return 0; +} + +int cabssTest() { + printf(">> Float Complex \n"); + floatComplex value1 = FloatComplex(4,3); + assert(cabss(value1) == 5); + return 0; +} + +int zabssTest() { + printf(">> Double Complex \n"); + doubleComplex value1 = DoubleComplex(4,3); + assert(zabss(value1) == 5); + return 0; +} + +int testAbs() { + int sabssStatus, dabssStatus = 0; + int cabssStatus, zabssStatus = 0; + + printf(">>>> Abs Tests\n"); + sabssStatus = sabssTest(); + dabssStatus = dabssTest(); + cabssStatus = cabssTest(); + zabssStatus = zabssTest(); + + return (sabssStatus + dabssStatus + + cabssStatus + zabssStatus); +} + +int main(void) { + assert(testAbs() == 0); + return 0; +} diff --git a/src/auxiliaryFunctions/abs/testAbs.h b/src/auxiliaryFunctions/abs/testAbs.h new file mode 100644 index 00000000..cb153970 --- /dev/null +++ b/src/auxiliaryFunctions/abs/testAbs.h @@ -0,0 +1,30 @@ +/* +** -*- C -*- +** +** testAbs.h +** Made by Bruno JOFRET <bruno.jofret@inria.fr> +** +** Started on Mon Apr 23 16:26:14 2007 jofret +** Last update Mon Apr 23 16:34:43 2007 jofret +** +** Copyright INRIA 2007 +*/ +#ifndef _TESTABS_H_ +#define _TESTABS_H_ + +#include <stdio.h> +#include <assert.h> + +#include "abs.h" + +int sabssTest(void); + +int dabssTest(void); + +int cabssTest(void); + +int zabssTest(void); + +int testAbs(void); + +#endif /* ! _TESTABS_H_ */ diff --git a/src/auxiliaryFunctions/abs/zabss.c b/src/auxiliaryFunctions/abs/zabss.c index e69de29b..6a82b6d2 100644 --- a/src/auxiliaryFunctions/abs/zabss.c +++ b/src/auxiliaryFunctions/abs/zabss.c @@ -0,0 +1,19 @@ +/* +** -*- C -*- +** +** zabss.c +** Made by Bruno JOFRET <bruno.jofret@inria.fr> +** +** Started on Mon Apr 23 17:03:36 2007 jofret +** Last update Mon Apr 23 17:16:05 2007 jofret +** +** Copyright INRIA 2007 +*/ + +#include "abs.h" + +double zabss(doubleComplex in) { + double real = zreals(in); + double imag = zimags(in); + return (dsqrts( (real*real) + (imag*imag) )); +} diff --git a/src/auxiliaryFunctions/includes/abs.h b/src/auxiliaryFunctions/includes/abs.h index fa302db6..3cb6bf85 100644 --- a/src/auxiliaryFunctions/includes/abs.h +++ b/src/auxiliaryFunctions/includes/abs.h @@ -5,7 +5,7 @@ ** Made by Bruno JOFRET <bruno.jofret@inria.fr> ** ** Started on Thu Feb 8 10:12:17 2007 jofret -** Last update Fri Apr 20 15:53:57 2007 jofret +** Last update Mon Apr 23 17:10:57 2007 jofret ** ** Copyright INRIA 2007 */ @@ -13,6 +13,11 @@ #ifndef __ABS_H__ #define __ABS_H__ +#include "floatComplex.h" +#include "doubleComplex.h" +#include "sqrt.h" + + /** ** \brief Float Absolute Value function ** Determine the absolute value of in. @@ -29,4 +34,20 @@ float sabss(float in); **/ double dabss(double in); +/** + ** \brief Float Complex Absolute Value function + ** Determine the absolute value of in. + ** \param in : the float complex we must determine abs i.e. module. + ** \return -in or in depending on the sign of in. + **/ +float cabss(floatComplex in); + +/** + ** \brief Double Absolute Value function + ** Determine the absolute value of in. + ** \param in : the double we must determine abs i.e. module. + ** \return -in or +in depending on the abs of in. + **/ +double zabss(doubleComplex in); + #endif /* !__ABS_H__ */ |