diff options
Diffstat (limited to 'src/type/testDoubleComplex.c')
-rw-r--r-- | src/type/testDoubleComplex.c | 38 |
1 files changed, 28 insertions, 10 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; } |