mruby/mruby — pull request #2435 by AE9RB (2014-07-02 07:46:39+00:00)
Title: Complex numbers

This adds support for the Complex number type as a mrb_value. It has been made optional. Define MRB_COMPLEX to include in the build. Using with MRB_NAN_BOXING, especially on x64, is recommended but it has been tested with all boxing options and also 32-bit builds.

For anyone working with large amounts of complex numbers, which is the typical use case, this will net a substantial performance gain. No longer do we have hundreds or thousands of intermediate values to be garbage collected or are forced to use separate arrays for real and imaginary values.

The full implementation of a Complex class has not yet been done but is a straightforward task. Indeed, it can be done entirely in Ruby, but most methods will be C. I submit this pull request early to solicit feedback.