[ruby-core:88889] [Ruby trunk Feature#15066] Documentation and providing better API for accessing Complex numbers functions in C extensions

From: sameer.deshmukh93@...
Date: 2018-09-07 13:48:54 UTC
List: ruby-core #88889
Issue #15066 has been updated by v0dro (Sameer Deshmukh).



> 
> > > Isn't it enough to just use rb_funcall() to call Ruby methods on Complex numbers?
> 
> > Calling Ruby methods in C extensions defeats the purpose of writing a C extension since a non-trivial number of Ruby method calls take up significant time.
> 
> What APIs do you need?
> A concrete list, please.

As Benoit says (rightly), I don't think we need a very elaborate API. Therefore the following functions would be sufficient:

* Constructor from double: Something like `rb_complex_new(double real, double imag)`.
* Access real and imag parts: Something like `rb_complex_get_real(VALUE complex_number)` and `rb_complex_get_imag(VALUE complex_number)`.
* Basic operations: complement, addition, subtraction, multiplication and division.

----------------------------------------
Feature #15066: Documentation and providing better API for accessing Complex numbers functions in C extensions
https://bugs.ruby-lang.org/issues/15066#change-73931

* Author: v0dro (Sameer Deshmukh)
* Status: Feedback
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Currently there is absolutely no documentation for working with Complex numbers at the level of the C API.

Apart from two macros defined [[here](https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1079)] for setting the real and imag
values of Complex numbers there is no 'official' way of working with Complex numbers at the level of the C API.

I propose two things:
* Fully document existing Complex number routines.
* Provide a robust and efficient API for dealing with complex numbers from C extensions.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next