summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjofret2006-12-01 15:37:45 +0000
committerjofret2006-12-01 15:37:45 +0000
commit06da3df2ff648931ce65ed91bf516062828b2354 (patch)
treec25340cd9bc5b38130cc835751e9ccf9ac7d61ff /src
parentb1c30f678966e6a6edc97b6012a5e89a36a8873f (diff)
downloadscilab2c-06da3df2ff648931ce65ed91bf516062828b2354.tar.gz
scilab2c-06da3df2ff648931ce65ed91bf516062828b2354.tar.bz2
scilab2c-06da3df2ff648931ce65ed91bf516062828b2354.zip
Quite a good DouComplex lib...
Will probably be improved later...
Diffstat (limited to 'src')
-rw-r--r--src/type/Makefile46
-rw-r--r--src/type/doubleComplex.c22
-rw-r--r--src/type/doubleComplex.h6
-rw-r--r--src/type/testDoubleComplex.c (renamed from src/type/main.c)0
4 files changed, 61 insertions, 13 deletions
diff --git a/src/type/Makefile b/src/type/Makefile
index 8b34532e..4894baa8 100644
--- a/src/type/Makefile
+++ b/src/type/Makefile
@@ -5,28 +5,52 @@
## Made by Bruno JOFRET <bruno.jofret@inria.fr>
##
## Started on Thu Nov 30 16:33:40 2006 jofret
-## Last update Thu Nov 30 17:52:34 2006 jofret
+## Last update Fri Dec 1 16:21:12 2006 jofret
##
## Copyright INRIA 2006
##
-NAME = dummy
+NAME = complex
RM = rm -f
CC = gcc
-CFLAGS = -Wall -pedantic
+CFLAGS = -Wall -pedantic -ansi
+AR = ar cru
+RANLIB = ranlib
-SRC = doubleComplex.c \
- main.c
+OBJS = $(DCOBJ) $(FCOBJ)
+LIBS = $(DCLIB) $(FCLIB)
-HEADERS = doubleComplex.h
+### test
-OBJ = $(SRC:.c=.o)
-all: $(SRC) $(HEADERS) $(OBJ)
- $(CC) $(CFLAGS) $(OBJ) -o $(NAME)
+### Double Complex
+DCLIB = libDoubleComplex.a
+DCSRC = doubleComplex.c
+DCHEAD = doubleComplex.h
+DCOBJ = $(DCSRC:.c=.o)
+
+### Float Complex
+FCLIB = libFloatComplex.a
+FCSRC = floatComplex.c
+FCHEAD = floatComplex.h
+FCOBJ = $(FCSRC:.c=.o)
+
+
+all: $(LIBS)
+
+$(DCLIB) : $(DCOBJ)
+ $(AR) $@ $<
+ $(RANLIB) $@
+
+$(FCLIB) : $(FCOBJ)
+ $(AR) $@ $<
+ $(RANLIB) $@
clean:
- $(RM) $(OBJ)
+ $(RM) $(OBJS)
distclean: clean
- $(RM) $(NAME) \ No newline at end of file
+ $(RM) $(NAME) $(LIBS)
+
+test: $(NAME)
+
diff --git a/src/type/doubleComplex.c b/src/type/doubleComplex.c
index b05ca0d0..071553b8 100644
--- a/src/type/doubleComplex.c
+++ b/src/type/doubleComplex.c
@@ -5,7 +5,7 @@
** Made by Bruno JOFRET <bruno.jofret@inria.fr>
**
** Started on Thu Nov 30 16:27:08 2006 jofret
-** Last update Thu Nov 30 17:59:50 2006 jofret
+** Last update Fri Dec 1 15:17:20 2006 jofret
**
** Copyright INRIA 2006
*/
@@ -39,3 +39,23 @@ doubleComplex DoubleComplex(double real, double imag) {
z.imag = imag;
return z;
}
+
+/*
+** \function isreal
+** \brief check if complex is real .
+*/
+bool isreal(doubleComplex z) {
+ if (z.imag == 0)
+ return true;
+ return false;
+}
+
+/*
+** \function isimag
+** \brief check if complex is pure imaginary .
+*/
+bool isimag(doubleComplex z) {
+ if (z.real == 0)
+ return true;
+ return false;
+}
diff --git a/src/type/doubleComplex.h b/src/type/doubleComplex.h
index 7d96b72f..c1943e0e 100644
--- a/src/type/doubleComplex.h
+++ b/src/type/doubleComplex.h
@@ -5,7 +5,7 @@
** Made by Bruno JOFRET <bruno.jofret@inria.fr>
**
** Started on Thu Nov 30 16:50:08 2006 jofret
-** Last update Thu Nov 30 17:53:13 2006 jofret
+** Last update Fri Dec 1 15:17:05 2006 jofret
**
** Copyright INRIA 2006
*/
@@ -13,6 +13,8 @@
#ifndef __DOUBLECOMPLEX_H__
#define __DOUBLECOMPLEX_H__
+#include <stdbool.h>
+
struct double_complex
{
double real;
@@ -24,5 +26,7 @@ typedef struct double_complex doubleComplex;
double real(doubleComplex);
double imag(doubleComplex);
doubleComplex DoubleComplex(double, double);
+bool isreal(doubleComplex);
+bool isimag(doubleComplex);
#endif /* !__DOUBLECOMPLEX_H__ */
diff --git a/src/type/main.c b/src/type/testDoubleComplex.c
index 0372c93a..0372c93a 100644
--- a/src/type/main.c
+++ b/src/type/testDoubleComplex.c