diff options
-rw-r--r-- | src/type/Makefile | 32 | ||||
-rw-r--r-- | src/type/doubleComplex.c | 41 | ||||
-rw-r--r-- | src/type/doubleComplex.h | 28 | ||||
-rw-r--r-- | src/type/main.c | 23 |
4 files changed, 124 insertions, 0 deletions
diff --git a/src/type/Makefile b/src/type/Makefile new file mode 100644 index 00000000..8b34532e --- /dev/null +++ b/src/type/Makefile @@ -0,0 +1,32 @@ +## +## -*- makefile -*- +## +## Makefile +## 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 +## +## Copyright INRIA 2006 +## + +NAME = dummy +RM = rm -f +CC = gcc +CFLAGS = -Wall -pedantic + +SRC = doubleComplex.c \ + main.c + +HEADERS = doubleComplex.h + +OBJ = $(SRC:.c=.o) + +all: $(SRC) $(HEADERS) $(OBJ) + $(CC) $(CFLAGS) $(OBJ) -o $(NAME) + +clean: + $(RM) $(OBJ) + +distclean: clean + $(RM) $(NAME)
\ No newline at end of file diff --git a/src/type/doubleComplex.c b/src/type/doubleComplex.c new file mode 100644 index 00000000..b05ca0d0 --- /dev/null +++ b/src/type/doubleComplex.c @@ -0,0 +1,41 @@ +/* +** -*- C -*- +** +** doubleComplex.c +** 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 +** +** Copyright INRIA 2006 +*/ + +#include "doubleComplex.h" + + +/* +** \function real +** \brief Return a Complex Real Part . +*/ +double real(doubleComplex z) { + return z.real; +} + +/* +** \function imag +** \brief Return a Complex Imaginary Part . +*/ +double imag(doubleComplex z) { + return z.imag; +} + +/* +** \function DoubleComplex +** \brief construct a Double Complex . +*/ +doubleComplex DoubleComplex(double real, double imag) { + doubleComplex z; + z.real = real; + z.imag = imag; + return z; +} diff --git a/src/type/doubleComplex.h b/src/type/doubleComplex.h new file mode 100644 index 00000000..7d96b72f --- /dev/null +++ b/src/type/doubleComplex.h @@ -0,0 +1,28 @@ +/* +** -*- C -*- +** +** doubleComplex.h +** 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 +** +** Copyright INRIA 2006 +*/ + +#ifndef __DOUBLECOMPLEX_H__ +#define __DOUBLECOMPLEX_H__ + +struct double_complex +{ + double real; + double imag; +}; + +typedef struct double_complex doubleComplex; + +double real(doubleComplex); +double imag(doubleComplex); +doubleComplex DoubleComplex(double, double); + +#endif /* !__DOUBLECOMPLEX_H__ */ diff --git a/src/type/main.c b/src/type/main.c new file mode 100644 index 00000000..0372c93a --- /dev/null +++ b/src/type/main.c @@ -0,0 +1,23 @@ +/* +** -*- C -*- +** +** main.c +** Made by Bruno JOFRET <bruno.jofret@inria.fr> +** +** Started on Thu Nov 30 16:59:04 2006 jofret +** Last update Thu Nov 30 17:55:50 2006 jofret +** +** Copyright INRIA 2006 +*/ + +#include <stdio.h> + +#include "doubleComplex.h" + +int main(int argc, char **argv) { + /* z = 1 + %i */ + doubleComplex z = DoubleComplex(-3,25); + printf("Partie reelle = %f\n", real(z)); + printf("Partie imaginaire = %f\n", imag(z)); + return 0; +} |