[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Native Complex numbers for LuaJIT-2 [was Re: Benchmark shootout shows LuaJIT 2.0]
- From: Leo Razoumov <slonik.az@...>
- Date: Mon, 2 Nov 2009 10:15:43 -0500
On 2009-11-02, Klaus Ripke <firstname.lastname@example.org> wrote:
> On Mon, Nov 02, 2009 at 09:15:03AM -0500, Leo Razoumov wrote:
> > Also I am a bit worried about function dispatch. Adding two doubles is
> > a native Lua opcode and it does not go through the trouble of
> > metamethods. Using __add, __mul, etc metamethods dispatch for complex
> > numbers is slow. Could it be avoided?
> Hmm, I reckon where you want fast complex numbers,
> you might prefer a VM with complex as the basic numeric type?
> After all others are just special cases.
Actually not! There is a lot of sense in keeping basic numeric type
as double and having complex as an additional numeric type. I do not
think that x86 and x86-64 have any complex number registers.
Therefore, complex number operations are implemented in floating point
registers separately for real and imaginary parts. Treating all
numbers as complex would add unnecessary overhead in too many cases.
Secondly, the entire math library will have to be reimplemented, for
it uses double numbers exclusively.