summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjofret2007-10-22 15:29:58 +0000
committerjofret2007-10-22 15:29:58 +0000
commit5d8ad5b7de0f0ebe614e30cdf2e02d96c6bf0c4f (patch)
tree8777d103de27712adf87717ecf1a027105c8c491 /src
parent4eb65bcbc81b9fdeb9f74f44a10f90b0ba72f303 (diff)
downloadscilab2c-5d8ad5b7de0f0ebe614e30cdf2e02d96c6bf0c4f.tar.gz
scilab2c-5d8ad5b7de0f0ebe614e30cdf2e02d96c6bf0c4f.tar.bz2
scilab2c-5d8ad5b7de0f0ebe614e30cdf2e02d96c6bf0c4f.zip
C99 compliance, or even ISO C 89 one...
Diffstat (limited to 'src')
-rw-r--r--src/type/testDoubleComplex.c38
-rw-r--r--src/type/testFloatComplex.c39
2 files changed, 57 insertions, 20 deletions
diff --git a/src/type/testDoubleComplex.c b/src/type/testDoubleComplex.c
index 4dbefe4f..d287cbc0 100644
--- a/src/type/testDoubleComplex.c
+++ b/src/type/testDoubleComplex.c
@@ -5,7 +5,7 @@
** Made by Bruno JOFRET <bruno.jofret@inria.fr>
**
** Started on Thu Nov 30 16:59:04 2006 jofret
-** Last update Fri Mar 23 14:39:45 2007 jofret
+** Last update Mon Oct 22 10:21:07 2007 bruno
**
** Copyright INRIA 2006
*/
@@ -16,19 +16,37 @@
int main(int argc, char **argv) {
/* z = -3 + 25*%i */
- doubleComplex z = DoubleComplex(-3,25);
- printf("Partie reelle = %f\n", zreals(z));
- assert(zreals(z) == (double)-3);
- printf("Partie imaginaire = %f\n", zimags(z));
- assert(zimags(z) == (double)25);
+ doubleComplex z = DoubleComplex(3,-25);
+ /* y = -3.123456 + 25.123456*%i */
+ doubleComplex y = DoubleComplex(-3.123456,25.123456);
+ /* t = z + y */
+ doubleComplex t = zadds(z,y);
+ /* u = z - y */
+ doubleComplex u = zdiffs(z,y);
+
- /* z = -3.123456 + 25.123456*%i */
- z = DoubleComplex(-3.123456,25.123456);
+ /* z = -3 + 25*%i */
printf("Partie reelle = %f\n", zreals(z));
- assert(zreals(z) == (double)-3.123456);
+ assert(zreals(z) == (double)3);
printf("Partie imaginaire = %f\n", zimags(z));
- assert(zimags(z) == (double)25.123456);
+ assert(zimags(z) == (double)-25);
+
+ /* y = -3.123456 + 25.123456*%i */
+ printf("Partie reelle = %f\n", zreals(y));
+ assert(zreals(y) == (double)-3.123456);
+ printf("Partie imaginaire = %f\n", zimags(y));
+ assert(zimags(y) == (double)25.123456);
+ /* Try to have somme addition */
+ printf("Partie reelle = %f\n", zreals(t));
+ assert(zreals(t) == (double)3 + (double)-3.123456);
+ printf("Partie imaginaire = %f\n", zimags(t));
+ assert(zimags(t) == (double)-25 + (double)25.123456);
+ /* Try to have somme diff */
+ printf("Partie reelle = %f\n", zreals(u));
+ assert(zreals(u) == (double)3 - (double)-3.123456);
+ printf("Partie imaginaire = %f\n", zimags(u));
+ assert(zimags(u) == (double)-25 - (double)25.123456);
return 0;
}
diff --git a/src/type/testFloatComplex.c b/src/type/testFloatComplex.c
index 441de367..253e2d3e 100644
--- a/src/type/testFloatComplex.c
+++ b/src/type/testFloatComplex.c
@@ -5,7 +5,7 @@
** Made by Bruno JOFRET <bruno.jofret@inria.fr>
**
** Started on Thu Nov 30 16:59:04 2006 jofret
-** Last update Fri Mar 23 17:05:00 2007 jofret
+** Last update Mon Oct 22 10:22:19 2007 bruno
**
** Copyright INRIA 2006
*/
@@ -19,19 +19,38 @@
int main(int argc, char **argv) {
/* z = -3 + 25*%i */
- floatComplex z = FloatComplex((float)-3, (float)25);
- printf("Partie reelle = %f\n", creals(z));
- assert(creals(z) == (float)-3.0);
- printf("Partie imaginaire = %f\n", cimags(z));
- assert(cimags(z) == (float)25);
+ floatComplex z = FloatComplex((float)3, (float)-25);
+ /* y = -3.123456 + 25.123456*%i */
+ floatComplex y = FloatComplex((float)-3.123,(float)25.123);
+ /* t = z + y */
+ floatComplex t = cadds(z,y);
+ /* u = z - y */
+ floatComplex u = cdiffs(z,y);
+
- /* z = -3.123456 + 25.123456*%i */
- z = FloatComplex((float)-3.123456,(float)25.123456);
+ /* z = -3 + 25*%i */
printf("Partie reelle = %f\n", creals(z));
- assert(creals(z) == (float)-3.123456);
+ assert(creals(z) == (float)3);
printf("Partie imaginaire = %f\n", cimags(z));
- assert(cimags(z) == (float)25.123456);
+ assert(cimags(z) == (float)-25);
+
+ /* y = -3.123456 + 25.123456*%i */
+ printf("Partie reelle = %f\n", creals(y));
+ assert(creals(y) == (float)-3.123);
+ printf("Partie imaginaire = %f\n", cimags(y));
+ assert(cimags(y) == (float)25.123);
+
+ /* Try to have somme addition */
+ printf("Partie reelle = %f\n", creals(t));
+ assert(creals(t) == (float)3 + (float)-3.123);
+ printf("Partie imaginaire = %f\n", cimags(t));
+ assert(cimags(t) == (float)-25 + (float)25.123);
+ /* Try to have somme diff */
+ printf("Partie reelle = %f\n", creals(u));
+ assert(creals(u) == (float)3 - (float)-3.123);
+ printf("Partie imaginaire = %f\n", cimags(u));
+ assert(cimags(u) == (float)-25 - (float)25.123);
return 0;
}