|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Try the following. Both printed lines should be identical (or at least
almost identical). However, only the first one is the correct answer. The
second one is buggy:
$Z = <-.32, -1.97>;
$Z2 = cmult(Z,Z);
#debug concat("cmult(<",str(creal(Z),10,10),",",str(cimag(Z),10,10),">) = ")
#debug concat("<",str(creal(Z2),10,10),",",str(cimag(Z2),10,10),">\n")
$Z2 = csqr(Z);
#debug concat(" csqr(<",str(creal(Z),10,10),",",str(cimag(Z),10,10),">) = ")
#debug concat("<",str(creal(Z2),10,10),",",str(cimag(Z2),10,10),">\n")
In this Solaris 7 it outputs the following:
cmult(<-0.3200000000,-1.9700000000>) = <-3.7785000000,1.2608000000>
csqr(<-0.3200000000,-1.9700000000>) = <-3.7785000000,14.8872900000>
--
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Btw, I seriously think someone should check _all_ the complex functions
to see if they have bugs. Tried 3 functions (cpow, csqr, cmult) and 2 of
them didn't work correctly. That's a too high percentage.
--
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Warp <war### [at] tagpovrayorg> wrote in message news:39229ca2@news.povray.org...
> Try the following. Both printed lines should be identical (or at least
> almost identical). However, only the first one is the correct answer. The
> second one is buggy:
>
> $Z = <-.32, -1.97>;
> $Z2 = cmult(Z,Z);
> #debug concat("cmult(<",str(creal(Z),10,10),",",str(cimag(Z),10,10),">) =
")
> #debug concat("<",str(creal(Z2),10,10),",",str(cimag(Z2),10,10),">\n")
> $Z2 = csqr(Z);
> #debug concat(" csqr(<",str(creal(Z),10,10),",",str(cimag(Z),10,10),">) =
")
> #debug concat("<",str(creal(Z2),10,10),",",str(cimag(Z2),10,10),">\n")
>
> In this Solaris 7 it outputs the following:
>
> cmult(<-0.3200000000,-1.9700000000>) = <-3.7785000000,1.2608000000>
> csqr(<-0.3200000000,-1.9700000000>) = <-3.7785000000,14.8872900000>
Yes, csqr(Z) has a bug.
The source-level fix is to replace a line in express.c.
===== the bug ===========================
/*****************************************/
case CSQR_TOKEN:
#ifdef UnofficialBlocking
parseUnofficialFeature(40);
#endif
Parse_Vector_Param(Vect);
/**** Replace the next line:*****/
Make_Vector(Vect,Vect[0]*Vect[0]-Vect[1]*Vect[1],2*Vect[0]*Vect[1],0.0);
/**********************/
break;
===== a fix ========================
case CSQR_TOKEN:
#ifdef UnofficialBlocking
parseUnofficialFeature(40);
#endif
Parse_Vector_Param(Vect);
/***** Replacement lines*********/
cmplx2.x=Vect[0];cmplx2.y=Vect[1];
Make_Vector(Vect,cmplx2.x*cmplx2.x-cmplx2.y*cmplx2.y,2*cmplx2.x*cmplx2.y,0.0
);
/*****************************/
break;
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
david sharp <dsh### [at] interportnet> wrote:
: Yes, csqr(Z) has a bug.
Ok. It's good to know that it's not just me... :)
--
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
|
|
| |
| |
|
|
|
|
| |
|
|