These are chat archives for symengine/symengine

23rd
May 2016
myluszczak
@myluszczak
May 23 2016 02:45
@isuruf #913 contains MultivariateExprPolynomial, which is a wrapper class with overloaded operators for MultivariatePolynomial. #925 does not.
myluszczak
@myluszczak
May 23 2016 02:52
@isuruf Also, James is currently working on rewriting MultivariatePolynomial and MultivariateExprPolynomial so that the implementation will be associated with MultivariateExprPolynomial with MultivariatePolynomial being a wrapper class. Should he be working off of PR #913 or #925?
Isuru Fernando
@isuruf
May 23 2016 03:12
#925
I'm going to go over #925 once more and merge it in today
Charles Chen
@chenchfort
May 23 2016 04:03
Would the commit history need to be cleaned?
myluszczak
@myluszczak
May 23 2016 04:16
@isuruf There are a couple of things I'd like to discuss before merging #925. Firstly, I'd like MultivariatePolynomial to be able to have negative exponents; this should be easy to do and this change could be made either before merging or in a new PR after merging. More importantly, we were planning to move the implementation of MultivariatePolynomial to MultivariateExprPolynomial in order to make MultivariateExprPolynomial mutable; this implementation seems to make that significantly trickier.
Iris Lui
@irislq
May 23 2016 04:18
@isuruf I took notes on UnivariateExprPolynomial here https://github.com/symengine/symengine/wiki/Univariate-Series-expansion-benchmarks but is there any reason why subtraction is slower than addition?
myluszczak
@myluszczak
May 23 2016 04:18
@isuruf I'll write more extensively in the PR.
Isuru Fernando
@isuruf
May 23 2016 04:49
@myluszczak, I commented on the PR. If you have any concerns, let me know
@irislq, For epq *= epq you can special case epq being just a coefficient.
Iris Lui
@irislq
May 23 2016 04:53
I did, I think you're talking about ep *= e where e is a monomial
Isuru Fernando
@isuruf
May 23 2016 04:54
Alright. subtraction is slower I think because it cancels out terms and removing that entry from the dictionary is expensive
Charles Chen
@chenchfort
May 23 2016 08:10
@isuruf Right now if I want to create a UnivariateExprPolynomial from a vector of Expression, I’ll have to do it through UnivariatePolynomial, but UnivariatePolynomial::from_vec requires a variable. Should we add from_vec to UnivariateExprPolynomial?
Isuru Fernando
@isuruf
May 23 2016 08:11
Sure and then modify UnivariatePolynomial::from_vec
Rajith Vidanaarachchi
@rajithv
May 23 2016 15:48

I'm writing the Ruby wrapper for the Complex numbers. The SymEngine::Complex.new() is supposed to take a Ruby Complex as input.

I'm taking this as a VALUE and then assign it to a

When I run some sample code

a = 1 + 2i
SymEngine::Complex.new(a)

I get the error

TypeError: wrong argument type Object (expected Data)
    from (irb):4:in `initialize'
    from (irb):4:in `new'

First, what's the best way to find out where exactly this fails?

Second, what line may be the one responsible for the error:

VALUE ccomplex_init(VALUE self, VALUE comp_value) {
    basic_struct *this;
    basic_struct *real_basic = basic_new_heap();
    basic_struct *imag_basic = basic_new_heap();

    Data_Get_Struct(self, basic_struct, this);

    VALUE real, imag;
    real = rb_funcall(comp_value, rb_intern("real"), 0, NULL);
    imag = rb_funcall(comp_value, rb_intern("imaginary"), 0, NULL);

    crational_init(real_basic, real);
    crational_init(imag_basic, imag);

    complex_set(this, real_basic, imag_basic);

    basic_free_heap(real_basic);
    basic_free_heap(imag_basic);

    return self;
}
@isuruf @abinashmeher999
Isuru Fernando
@isuruf
May 23 2016 16:24
Data_Get_Struct(self, basic_struct, this); what is this line trying to do?
Also, you shouldn't create a Complex directly, because Complex.new(2) is not a Complex, it is an integer
Rajith Vidanaarachchi
@rajithv
May 23 2016 17:03
that line makes the struct from the ruby object, right?
Isuru Fernando
@isuruf
May 23 2016 17:05
No, that will try to retrieve a basic_struct from self. self is the class Complex right?
Rajith Vidanaarachchi
@rajithv
May 23 2016 17:06
yes
Isuru Fernando
@isuruf
May 23 2016 17:08
You shouldn't create a Complex directly
Rajith Vidanaarachchi
@rajithv
May 23 2016 17:08
should be looking at something more like a struct of a struct?
because Complex is a struct of two Rationals?
Isuru Fernando
@isuruf
May 23 2016 17:09
I don't get you
Rajith Vidanaarachchi
@rajithv
May 23 2016 17:10
that is for the earlier message.
I understood that the Complex shouldn't be created directly
I will make checks before creating it
Isuru Fernando
@isuruf
May 23 2016 17:12
Error you are getting is because of crational_init(real_basic, real);
Rajith Vidanaarachchi
@rajithv
May 23 2016 17:14
is there a way to find which line is giving the error?
Isuru Fernando
@isuruf
May 23 2016 17:14
I have no idea
You should first fix this issue, symengine/symengine.rb#19
crational_init should be removed
For debugging, @abinashmeher999 can help you
Rajith Vidanaarachchi
@rajithv
May 23 2016 17:15
okay.. I'll try and give an update