POV-Ray : Newsgroups : povray.unofficial.patches : Bug in cpow? Server Time
1 Nov 2024 21:19:20 EDT (-0400)
  Bug in cpow? (Message 1 to 4 of 4)  
From: Warp
Subject: Bug in cpow?
Date: 17 May 2000 08:49:54
Message: <39229572@news.povray.org>
Try this:

$Z = <2, 0>;
#debug concat(str(creal(Z),10,10), " ", str(cimag(Z),10,10), "\n")
$Z2 = cmult(Z, Z);
#debug concat(str(creal(Z2),10,10), " ", str(cimag(Z2),10,10), "\n")
$Z2 = cpow(Z, 2);
#debug concat(str(creal(Z2),10,10), " ", str(cimag(Z2),10,10), "\n")

  The expected result is that the second and third line should be identical
(or at least almost identical), since 'Z*Z' is the same thing as 'Z^2'.
  However, the cpow() function seems to work extremely buggy. At least
in this Solaris 7 that code outputs the following:

2.0000000000 0.0000000000
4.0000000000 0.0000000000
0.7338278990 3.9321109616

  The second line (ie. the result of cmult(Z,Z)) is ok, but the third
line (result of cpow(Z,2)) seems to be completely wrong.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: david sharp
Subject: Re: Bug in cpow?
Date: 17 May 2000 10:30:57
Message: <3922ad21$1@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote in message news:39229572@news.povray.org...
>   Try this:
>
> $Z = <2, 0>;
> #debug concat(str(creal(Z),10,10), " ", str(cimag(Z),10,10), "\n")
> $Z2 = cmult(Z, Z);
> #debug concat(str(creal(Z2),10,10), " ", str(cimag(Z2),10,10), "\n")
> $Z2 = cpow(Z, 2);
> #debug concat(str(creal(Z2),10,10), " ", str(cimag(Z2),10,10), "\n")
>
>   The expected result is that the second and third line should be
identical
> (or at least almost identical), since 'Z*Z' is the same thing as 'Z^2'.
>   However, the cpow() function seems to work extremely buggy. At least
> in this Solaris 7 that code outputs the following:
>
> 2.0000000000 0.0000000000
> 4.0000000000 0.0000000000
> 0.7338278990 3.9321109616
>
>   The second line (ie. the result of cmult(Z,Z)) is ok, but the third
> line (result of cpow(Z,2)) seems to be completely wrong.

The cpow function needs both arguments to be 'complex';
To do Z^2 with cpow, you need to do cpow(Z,<2,0>)


Post a reply to this message

From: Warp
Subject: Re: Bug in cpow?
Date: 17 May 2000 10:42:11
Message: <3922afc2@news.povray.org>
david sharp <dsh### [at] interportnet> wrote:
: The cpow function needs both arguments to be 'complex';
: To do Z^2 with cpow, you need to do cpow(Z,<2,0>)

  Ah, ok.
  I said this by mail already, but let me say it again here:
  It would be more intuitive if cpow() would accept either a float or
a complex.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: david sharp
Subject: Re: Bug in cpow?
Date: 17 May 2000 12:37:04
Message: <3922cab0$1@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote in message news:3922afc2@news.povray.org...
> david sharp <dsh### [at] interportnet> wrote:
> : The cpow function needs both arguments to be 'complex';
> : To do Z^2 with cpow, you need to do cpow(Z,<2,0>)
>
>   Ah, ok.
>   I said this by mail already, but let me say it again here:
>   It would be more intuitive if cpow() would accept either a float or
> a complex.

That would be helpful, but implementation is complicated
by the way POV-Ray promotes a float (say 2.0) to a VECTOR
(becomes <2.0,2.0,2.0> ) when it is expecting a vector. So
cpow(Z,2) becomes cpow(Z,<2,2>) rather than the desired
cpow(Z,<2,0>). The simplest way to implement float exponents
would be to have a new function (eg crpow(Z,X) )


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.