[Gambas-user] gb.gsl: pseudo-complex Vectors make different cross product

Tobias Boege taboege at ...626...
Fri Feb 14 18:20:24 CET 2014


On Fri, 14 Feb 2014, Beno?t Minisini wrote:
> Le 11/02/2014 21:15, Tobias Boege a ?crit :
> > Hi Benoit,
> >
> > a strange thing this time. Using gb.gsl, we noticed that there is a way to
> > compute the cross product of two Vector objects in "complex" mode - but
> > without any complex numbers in them - which yields a different result than
> > other methods to compute it. Attached is a project that shows what I mean.
> >
> > Note that everything is fine if we don't force the Vector to be complex and
> > also everything is fine if we don't insist on computing the components in
> > separate Float variables, as said in the comments.
> >
> > Oh, and for the record, the Y component is wrong. It should be -18 every
> > time but using that special method above, we get +18. The vectors are
> > immediately taken from an application, seemingly nothing special about them.
> >
> > I also noticed that wrapping each product of components into a CFloat() call
> > yields the correct result again... I tried that because even the debugger
> > didn't seem to get the type of hA[iIndex] figured out...
> >
> > What may be going on there?
> >
> > Regards,
> > Tobi
> >
> 
> Arf... This is because Complex to Float conversion takes the modulus 
> value, so -18 as a complex becomes +18.
> 
> Mmm... that was a weird choice. We can even call that a bug.
> 
> I must leave now, but I think I will replace that by taking the real 
> part of the complex number if the imaginary part is zero, and raising a 
> conversion error instead.
> 

I second that. Thanks.

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list