summaryrefslogtreecommitdiff
path: root/src/type
diff options
context:
space:
mode:
Diffstat (limited to 'src/type')
-rw-r--r--src/type/doubleComplex.c35
-rw-r--r--src/type/doubleComplex.h22
-rw-r--r--src/type/testDoubleComplex.c29
3 files changed, 65 insertions, 21 deletions
diff --git a/src/type/doubleComplex.c b/src/type/doubleComplex.c
index 380be331..db23721b 100644
--- a/src/type/doubleComplex.c
+++ b/src/type/doubleComplex.c
@@ -1,14 +1,14 @@
/*
-** -*- C -*-
-**
-** doubleComplex.c
-** Made by Bruno JOFRET <bruno.jofret@inria.fr>
-**
-** Started on Thu Nov 30 16:27:08 2006 jofret
-** Last update Thu Aug 16 12:25:46 2007 bruno
-**
-** Copyright INRIA 2006
-*/
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2006-2008 - INRIA - Bruno JOFRET
+ *
+ * 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
+ *
+ */
#ifdef __STDC_VERSION__
# ifndef STDC
@@ -75,6 +75,21 @@ doubleComplex DoubleComplex(double real, double imag) {
}
/*
+** \function DoubleComplex
+** \brief construct a Double Complex Matrix.
+*/
+doubleComplex *DoubleComplexMatrix(double* real, double* imag, int size) {
+ doubleComplex *z = malloc((uint) size * sizeof(doubleComplex));
+ int i = 0;
+
+ for(i = 0; i < size; ++i)
+ {
+ z[i] = DoubleComplex(real[i], imag[i]);
+ }
+ return z;
+}
+
+/*
** \function isreal
** \brief check if complex is real .
*/
diff --git a/src/type/doubleComplex.h b/src/type/doubleComplex.h
index e43c8bd0..a8934b50 100644
--- a/src/type/doubleComplex.h
+++ b/src/type/doubleComplex.h
@@ -1,14 +1,14 @@
/*
-** -*- C -*-
-**
-** doubleComplex.h
-** Made by Bruno JOFRET <bruno.jofret@inria.fr>
-**
-** Started on Thu Nov 30 16:50:08 2006 jofret
-** Last update Thu Aug 16 11:57:12 2007 bruno
-**
-** Copyright INRIA 2006
-*/
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2006-2008 - INRIA - Bruno JOFRET
+ *
+ * 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
+ *
+ */
#ifndef __DOUBLECOMPLEX_H__
#define __DOUBLECOMPLEX_H__
@@ -24,6 +24,7 @@
# endif
#endif
+#include <stdlib.h>
#include <stdbool.h>
#ifndef STDC99
@@ -57,6 +58,7 @@ typedef double complex doubleComplex;
double zreals(doubleComplex);
double zimags(doubleComplex);
doubleComplex DoubleComplex(double, double);
+doubleComplex* DoubleComplexMatrix(double*, double*, int);
bool zisreals(doubleComplex);
bool zisimags(doubleComplex);
diff --git a/src/type/testDoubleComplex.c b/src/type/testDoubleComplex.c
index 4e3d94f3..1a2a0ada 100644
--- a/src/type/testDoubleComplex.c
+++ b/src/type/testDoubleComplex.c
@@ -14,7 +14,28 @@
#include <assert.h>
#include "doubleComplex.h"
-int main(void) {
+int matrixCreation(void);
+int addAndDiff(void);
+
+int matrixCreation(void) {
+ double real[6] = {1., 2., 3., 4., 5., 6.};
+ double imag[6] = {6., 5., 4., 3., 2., 1.};
+
+ doubleComplex *Z = DoubleComplexMatrix(real, imag, 6);
+
+ int i = 0;
+
+ for (i = 0; i < 6; ++i)
+ {
+ printf("Partie reelle = %f\n", zreals(Z[i]));
+ printf("Partie imaginaire = %f\n", zimags(Z[i]));
+ }
+
+
+ return 0;
+}
+
+int addAndDiff(void) {
/* z = -3 + 25*%i */
doubleComplex z = DoubleComplex(3,-25);
/* y = -3.123456 + 25.123456*%i */
@@ -50,3 +71,9 @@ int main(void) {
assert(zimags(u) == (double)-25 - (double)25.123456);
return 0;
}
+
+int main(void) {
+ addAndDiff();
+ matrixCreation();
+ return 0;
+}