summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/type/doubleComplex.c26
-rw-r--r--src/type/doubleComplex.h2
-rw-r--r--src/type/testDoubleComplex.c11
-rw-r--r--src/type/testFloatComplex.c11
4 files changed, 48 insertions, 2 deletions
diff --git a/src/type/doubleComplex.c b/src/type/doubleComplex.c
index 753e9e35..02976237 100644
--- a/src/type/doubleComplex.c
+++ b/src/type/doubleComplex.c
@@ -55,9 +55,33 @@ double zreals(doubleComplex z) {
double zimags(doubleComplex z) {
return cimag(z);
}
+#endif
+/*
+** \function creala
+** \brief Return a Complex Real Part array.
+*/
+void zreala(doubleComplex* z, int size, double* out) {
+ int i = 0;
-#endif
+ for (i = 0 ; i < size ; ++i)
+ {
+ out[i] = zreals(z[i]);
+ }
+}
+
+/*
+** \function cimaga
+** \brief Return a Complex Imaginary Part array.
+*/
+void zimaga(doubleComplex* z, int size, double* out) {
+ int i = 0;
+
+ for (i = 0 ; i < size ; ++i)
+ {
+ out[i] = zimags(z[i]);
+ }
+}
/*
** \function DoubleComplex
diff --git a/src/type/doubleComplex.h b/src/type/doubleComplex.h
index 30dea12f..bf5b34f6 100644
--- a/src/type/doubleComplex.h
+++ b/src/type/doubleComplex.h
@@ -58,7 +58,7 @@ typedef double complex doubleComplex;
double zreals(doubleComplex);
double zimags(doubleComplex);
void zreala(doubleComplex *in, int size, double *out);
-void zimaga(doubleComplex *in, int size, doubleg *out);
+void zimaga(doubleComplex *in, int size, double *out);
doubleComplex DoubleComplex(double, double);
doubleComplex* DoubleComplexMatrix(double*, double*, int);
bool zisreals(doubleComplex);
diff --git a/src/type/testDoubleComplex.c b/src/type/testDoubleComplex.c
index 4e51cd18..fa40f627 100644
--- a/src/type/testDoubleComplex.c
+++ b/src/type/testDoubleComplex.c
@@ -24,6 +24,8 @@ int matrixCreation(void) {
double imag[size];
doubleComplex *Z;
+ double extractedReal[size];
+ double extractedImag[size];
int i = 0;
@@ -43,6 +45,15 @@ int matrixCreation(void) {
assert(zimags(Z[i]) == size - i);
}
+ zreala(Z, size, extractedReal);
+ zimaga(Z, size, extractedImag);
+ for (i = 0; i < size; ++i)
+ {
+ printf("Partie reelle = %f\n", extractedReal[i]);
+ assert(extractedReal[i] == i);
+ printf("Partie imaginaire = %f\n", extractedImag[i]);
+ assert(extractedImag[i] == size - i);
+ }
return 0;
}
diff --git a/src/type/testFloatComplex.c b/src/type/testFloatComplex.c
index 464783eb..4dab9977 100644
--- a/src/type/testFloatComplex.c
+++ b/src/type/testFloatComplex.c
@@ -26,6 +26,8 @@ int matrixCreation(void) {
float imag[size];
floatComplex *Z;
+ float extractedReal[size];
+ float extractedImag[size];
int i = 0;
@@ -45,6 +47,15 @@ int matrixCreation(void) {
assert(cimags(Z[i]) == size - i);
}
+ creala(Z, size, extractedReal);
+ cimaga(Z, size, extractedImag);
+ for (i = 0; i < size; ++i)
+ {
+ printf("Partie reelle = %f\n", extractedReal[i]);
+ assert(extractedReal[i] == i);
+ printf("Partie imaginaire = %f\n", extractedImag[i]);
+ assert(extractedImag[i] == size - i);
+ }
return 0;
}