Corrections and additions Re: [PEAR-DEV] Proposal for new classes: Math_Complex and Math_TrigOp
| From: | Jesus M. Castagnetto | Date: | Wed, 20 Nov 2002 19:11:07 +0000 |
| Subject: | Corrections and additions Re: [PEAR-DEV] Proposal for new classes: Math_Complex and Math_TrigOp | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-10964@lists.php.net to get a copy of this message | ||
OOPs, I put an old broken tarball for Math_Complex. Fixed that and the tarball
should have the correct classes there. Confirmed that by reinstalling them from
that URL to my machine.
In case you need some sample testing script, here is one:
[testcomplex.php]
<?php
require_once 'Math/ComplexOp.php';
$a = new Math_Complex(2.0,-1.0);
$b = new Math_Complex(1,-2);
$c = new Math_Complex (1.455347, -0.3435607);
echo "a: ".$a->toString()."\n";
echo "b: ".$b->toString()."\n";
echo "c: ".$c->toString()."\n";
echo "abs(a): ".$a->abs()." arg(a): ".$a->arg()."\n";
echo "real(a): ".$a->getReal()." imag(a): ".$a->getIm()."\n";
$d = Math_ComplexOp::sqrt($a);
echo "sqrt: ".$d->toString()."\n";
$e = Math_ComplexOp::exp($a);
echo "exp: ".$e->toString()."\n";
$e = Math_ComplexOp::log($a);
echo "log: ".$e->toString()."\n";
$e = Math_ComplexOp::log10($a);
echo "log10: ".$e->toString()."\n";
$e = Math_ComplexOp::conjugate($a);
echo "conjugate: ".$e->toString()."\n";
$e = Math_ComplexOp::negative($a);
echo "negative: ".$e->toString()."\n";
$e = Math_ComplexOp::multReal($a, M_PI);
echo "z * real: ".$e->toString()."\n";
if (!Math_ComplexOp::areEqual($a, Math_ComplexOp::negative($a))) {echo "a and
neg(a) are different\n";}
$t=Math_ComplexOp::negative($a);
echo "Neg(a) is ".$t->toString()."\n";
$t=Math_ComplexOp::conjugate($a);
echo "Conj(a) is ".$t->toString()."\n";
$t=Math_ComplexOp::sin($a);
echo "Sin(a) is ".$t->toString()."\n";
$t=Math_ComplexOp::cos($a);
echo "Cos(a) is ".$t->toString()."\n";
$t=Math_ComplexOp::tan($a);
echo "Tan(a) is ".$t->toString()."\n";
echo "====\n";
$v = Math_ComplexOp::mult($c,$c);
echo "test c*c: ".$v->toString()."\n";
$t=Math_ComplexOp::sqrt($a);
echo "sqrt(a): ".$t->toString()."\n";
$t=Math_ComplexOp::sqrt($b);
$v = Math_ComplexOp::mult($t,$t);
echo "sqrt(b): ".$t->toString()."\n";
echo "test sqrt(b)*sqrt(b): ".$v->toString()."\n";
$t=Math_ComplexOp::mult($a,$b);
echo "a*b: ".$t->toString()."\n";
$t=Math_ComplexOp::div($a,$b);
echo "a/b: ".$t->toString()."\n";
$t=Math_ComplexOp::add($a,$b);
echo "a+b: ".$t->toString()."\n";
$t=Math_ComplexOp::sub($a,$b);
echo "a-b: ".$t->toString()."\n";
$t=Math_ComplexOp::sub($b,$a);
echo "b-a: ".$t->toString()."\n";
$t=Math_ComplexOp::sub($b,Math_ComplexOp::conjugate($a));
echo "b-a': ".$t->toString()."\n";
$v=Math_ComplexOp::conjugate($b);
$t=Math_ComplexOp::sub($v,$a);
echo "b'-a: ".$t->toString()."\n";
$v=Math_ComplexOp::conjugate($b);
$t=Math_ComplexOp::sub($v,Math_ComplexOp::conjugate($a));
echo "b'-a': ".$t->toString()."\n";
?>
--- "Jesus M. Castagnetto" <jcastagnetto@yahoo.com> wrote:
> Now that I got some time, I am finishing converting some of the classes I
> made
> for numPHP (ages ago).
>
> Just converted one that implements supplementary trigonometric functions
> (Math_TrigOp), one that defines Complex numbers (Math_Complex) and another
> that
> defines methods to operate on Math_Complex objects (Math_ComplexOp).
>
> Get them from:
>
> http://www.scripps.edu/~jesusmc/stuff/Math_TrigOp-1.0.tgz
>
> and
>
> http://www.scripps.edu/~jesusmc/stuff/Math_Complex-0.8.tgz
>
> respectively. The Math_Complex package uses Math_TrigOp, so install that one
> first.
>
> You can just do:
>
> $ pear install URL
>
> where URL is one of the above.
>
> Alternatively, download them and install them as usual.
>
> Opinions, suggestions, bug reports, etc. are welcomed.
>
> Will wait for +1's or -1's to tally them up and see if these can go into
> PEAR's
> CVS.
>
> Cheers.
>
>
> =====
> --- Jesus M. Castagnetto (jcastagnetto@yahoo.com)
>
> Research:
> http://metallo.scripps.edu/
> Personal: http://www.castagnetto.org/
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Web Hosting - Let the expert host your site
> http://webhosting.yahoo.com
>
> --
> PEAR Development Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
=====
--- Jesus M. Castagnetto (jcastagnetto@yahoo.com)
Research:
http://metallo.scripps.edu/
Personal: http://www.castagnetto.org/
__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com