[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
**Subject**: **Re: [ANN] GSL Shell new beta release with anti-gran graphics module**
**From**: Francesco Abbate <gslshell@...>
**Date**: Thu, 3 Dec 2009 18:00:04 +0100

2009/12/3 Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>:
>> > =(1+1i)^2
>> 1.2246063538224e-016+2i
>>
>> The complex module from numlua doesn't have these problems
>
> I get the same results with my lcomplex. We're probably both using cpow.
> Perhaps numlua converts z^2 to z*z (which does give 0+2i).
We can discuss about the algorithm to calculate a power but for me
this is a printing problem. To have a not-exactly zero value can
happen because of how FP values works but in GSL shell I've designed a
smarter system to print a matrix, here an example:
> m = cnew(2,2,|k,j|(k+1i * j)^2) -- create a complex matrix
> =m -- print the matrix
[ 2i -3+4i ]
[ 3+4i 8i ]
As you can see there are no spurious 'almost zero' values.
For me the standard printing method of Lua for printing complex number
should be modified in order to take into account both the magnitude of
imaginary and real parts and to chop to zero the components if :
re_part < eps * z_norm or
im_part < eps * z_norm
where z_norm is sqrt(re_part^2+im_part^2) and eps is something like 10^-8.
Francesco