A
Axel Etzold
Dear all,
I'd like some advice about extending Ruby with C via SWIG ....
I've got
a.) a bunch of files written in C doing some form of division with
remainder on a set of algebraic objects,
b.) a bunch of code in Ruby determining which object from the
set above to divide by which other next.
Now I could use SWIG to write a C extension of Ruby to connect
the two. I've read tutorials about that and it seems to
work, tentatively.
But I've got an additional issue.
The algebraic objects are polynomials, i.e., objects
a_0 + a_i x + ... + a_n x^n, where the coefficients a_i can so far
only be integers (big numbers allowed), according to the existing C code.
But I must be able to use other coefficients as well, such as
fractions (adding them needs common denominators), floats,
and complex numbers.
What do you think is an economical way of telling C about
Ruby Rational(x,y) or Complex(x,y) or Float coefficients and
returning the results ?
Thank you very much!
Best regards,
Axel
I'd like some advice about extending Ruby with C via SWIG ....
I've got
a.) a bunch of files written in C doing some form of division with
remainder on a set of algebraic objects,
b.) a bunch of code in Ruby determining which object from the
set above to divide by which other next.
Now I could use SWIG to write a C extension of Ruby to connect
the two. I've read tutorials about that and it seems to
work, tentatively.
But I've got an additional issue.
The algebraic objects are polynomials, i.e., objects
a_0 + a_i x + ... + a_n x^n, where the coefficients a_i can so far
only be integers (big numbers allowed), according to the existing C code.
But I must be able to use other coefficients as well, such as
fractions (adding them needs common denominators), floats,
and complex numbers.
What do you think is an economical way of telling C about
Ruby Rational(x,y) or Complex(x,y) or Float coefficients and
returning the results ?
Thank you very much!
Best regards,
Axel