diff options
author | jofret | 2007-08-30 06:49:13 +0000 |
---|---|---|
committer | jofret | 2007-08-30 06:49:13 +0000 |
commit | 1374a55b159ad3f28396be147f3ed6482d72888b (patch) | |
tree | 1ce6ff49ef869b2bb3c2993216d63d8a290d8a5f /src/type | |
parent | 44b3cb9f6a6cee4e186c8e42c92fc99581eecab4 (diff) | |
download | scilab2c-1374a55b159ad3f28396be147f3ed6482d72888b.tar.gz scilab2c-1374a55b159ad3f28396be147f3ed6482d72888b.tar.bz2 scilab2c-1374a55b159ad3f28396be147f3ed6482d72888b.zip |
Adding Complex operation
Diffstat (limited to 'src/type')
-rw-r--r-- | src/type/doubleComplex.c | 51 | ||||
-rw-r--r-- | src/type/doubleComplex.h | 6 | ||||
-rw-r--r-- | src/type/floatComplex.h | 7 |
3 files changed, 61 insertions, 3 deletions
diff --git a/src/type/doubleComplex.c b/src/type/doubleComplex.c index 9884f417..380be331 100644 --- a/src/type/doubleComplex.c +++ b/src/type/doubleComplex.c @@ -5,7 +5,7 @@ ** Made by Bruno JOFRET <bruno.jofret@inria.fr> ** ** Started on Thu Nov 30 16:27:08 2006 jofret -** Last update Fri Mar 23 14:41:36 2007 jofret +** Last update Thu Aug 16 12:25:46 2007 bruno ** ** Copyright INRIA 2006 */ @@ -93,3 +93,52 @@ bool zisimags(doubleComplex z) { return true; return false; } + +/* +** Operators +** { +*/ + +/* +** \function zadds +** \brief add 2 Complex numbers. +*/ +doubleComplex zadds(doubleComplex z1, doubleComplex z2) { +#ifndef STDC99 + return DoubleComplex(z1.real + z2.real, z1.imag + z2.imag); +#else + return z1 + z2; +#endif +} + +/* +** \function zdiffs +** \brief diff 2 Complex numbers. +*/ +doubleComplex zdiffs(doubleComplex z1, doubleComplex z2) { +#ifndef STDC99 + return DoubleComplex(z1.real - z2.real, z1.imag - z2.imag); +#else + return z1 - z2; +#endif +} + +/* +** \function ztimess +** \brief Multiply 2 Complex numbers. +*/ +doubleComplex ztimess(doubleComplex z1, doubleComplex z2) { +#ifndef STDC99 + return DoubleComplex(z1.real*z2.real - z1.imag*z2.imag, + z1.real*z2.imag + z2.real*z1.imag); +#else + return z1 * z2; +#endif +} + + + + +/* +** } +*/ diff --git a/src/type/doubleComplex.h b/src/type/doubleComplex.h index 5f2ce544..e43c8bd0 100644 --- a/src/type/doubleComplex.h +++ b/src/type/doubleComplex.h @@ -5,7 +5,7 @@ ** Made by Bruno JOFRET <bruno.jofret@inria.fr> ** ** Started on Thu Nov 30 16:50:08 2006 jofret -** Last update Fri Mar 23 16:59:54 2007 jofret +** Last update Thu Aug 16 11:57:12 2007 bruno ** ** Copyright INRIA 2006 */ @@ -60,4 +60,8 @@ doubleComplex DoubleComplex(double, double); bool zisreals(doubleComplex); bool zisimags(doubleComplex); +doubleComplex zadds(doubleComplex, doubleComplex); +doubleComplex zdiffs(doubleComplex, doubleComplex); +doubleComplex ztimess(doubleComplex, doubleComplex); +doubleComplex zdevides(doubleComplex, doubleComplex); #endif /* !__DOUBLECOMPLEX_H__ */ diff --git a/src/type/floatComplex.h b/src/type/floatComplex.h index 0d85ca78..64afed90 100644 --- a/src/type/floatComplex.h +++ b/src/type/floatComplex.h @@ -5,7 +5,7 @@ ** Made by Bruno JOFRET <bruno.jofret@inria.fr> ** ** Started on Thu Nov 30 16:50:08 2006 jofret -** Last update Fri Mar 23 17:01:43 2007 jofret +** Last update Thu Aug 16 12:14:57 2007 bruno ** ** Copyright INRIA 2006 */ @@ -61,4 +61,9 @@ floatComplex FloatComplex(float, float); bool cisreals(floatComplex); bool cisimags(floatComplex); +floatComplex cadds(floatComplex, floatComplex); +floatComplex cdiffs(floatComplex, floatComplex); +floatComplex ctimess(floatComplex, floatComplex); +floatComplex cdevides(floatComplex, floatComplex); + #endif /* !__FLOATCOMPLEX_H__ */ |