Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to assign ruby complex types to GSL::Matrix::Complex #38

Merged
merged 2 commits into from
Jun 15, 2016
Merged

Add ability to assign ruby complex types to GSL::Matrix::Complex #38

merged 2 commits into from
Jun 15, 2016

Conversation

envp
Copy link
Member

@envp envp commented Jun 9, 2016

Patch Updates

File changes

ext/gsl_native/complex.c

  • Added a case for T_COMPLEX in rb_gsl_complex_new(1..2) and rb_gsl_obj_to_gsl_complex(1)
  • Currently the ops on ::Complex types are handled via rb_funcall(2..)

test/gsl/complex_test.rb

  • Added a test for creating GSL::Complex by passing Complex type to GSL::Complex#alloc

Why this way?

  • The instance variables @real, @image for the Complex object being used appear to be set to nil (reproducible via IRB)
  • Cannot cast or Get_Struct from the VALUE obj struct RComplex since RComplex is internal to ruby

I would really appreciate a review of the changes. This patch is submitted for #27

…_obj_to_gsl_complex(1)

* Currently the ops on `::Complex` number is handled via rb_funcall(2..)

* Added a test for creating `GSL::Complex` by passing `Complex ` type to `GSL::Complex#alloc`

* There is an added cost due to the call to rb_funcall(2..) being used since the @real, @image ivars appear to be unset, in addition to this, struct RComplex is not publicly exposed and to use TypedData_Get_Struct(3) this struct would need to be replicated along with all its dependants.
@v0dro
Copy link
Member

v0dro commented Jun 10, 2016

Will review in 1-2 days. Little busy right now.

@v0dro v0dro merged commit 4a8ef93 into SciRuby:master Jun 15, 2016
@envp envp deleted the add_complex_27 branch June 15, 2016 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants