These are chat archives for symengine/symengine

31st
May 2016
Srajan Garg
@srajangarg
May 31 2016 04:23 UTC
Looks nice!
Rajith Vidanaarachchi
@rajithv
May 31 2016 17:37 UTC

I am about to implement Complex MPC and Real MPFR in the ruby wrappers.. I thought of the following:

  • get Ruby's BigDecimals to convert to MPFR from convert (sympify) function, while having a new function to construct MPFRs from either BigDecimal or Float.
  • For Complex MPC, just have a constructor which will take two MPFRs and return a MPC.
  • For both, have to_f and to_c methods to convert into Ruby BigDecimal and Complex.

What are your ideas on this? @abinashmeher999 @isuruf

Abinash Meher
@abinashmeher999
May 31 2016 17:45 UTC
In the second point, isn't there already a constructor for Complex MPC?
Rajith Vidanaarachchi
@rajithv
May 31 2016 17:46 UTC
I meant in the Ruby wrapper
Abinash Meher
@abinashmeher999
May 31 2016 17:47 UTC
So accordingly you will have to pass Float or BigDecimal to the constructor
Rajith Vidanaarachchi
@rajithv
May 31 2016 17:48 UTC
I was thinking of passing SymEngine::ComplexMPCs or Ruby BigDecimals .. because if it is Float, it's the same as SymEngine::ComplexDouble
Abinash Meher
@abinashmeher999
May 31 2016 17:48 UTC
In the first point having a new method will lead to same problems we had with rational.
According to that, 1.000 should give a SymEngine::Integer
Isuru Fernando
@isuruf
May 31 2016 17:49 UTC
ComplexDouble and Complex don't have constructors right? So, there's no need for ComplexMPC
1.000 shouldn't give a SymEngine::Integer
Rajith Vidanaarachchi
@rajithv
May 31 2016 17:50 UTC
aha. okay.. so should we go with convert functions for all... because ultimately everything should be able to fall down to something else?
Abinash Meher
@abinashmeher999
May 31 2016 17:50 UTC
Any specific reasoning that I am missing here?
Isuru Fernando
@isuruf
May 31 2016 17:53 UTC
@abinashmeher999, are you asking about 1.000?
Abinash Meher
@abinashmeher999
May 31 2016 17:55 UTC
Yes
Isuru Fernando
@isuruf
May 31 2016 17:55 UTC
Because 1.000 is a floating point value, not an integer
Abinash Meher
@abinashmeher999
May 31 2016 17:56 UTC
But shouldn't it fall back? The way it happened with Rational 2/1
Isuru Fernando
@isuruf
May 31 2016 17:57 UTC
No, because 1.000 is an inexact value and 1 is an exact value. 1.000 represents a range of values while 1 represents only one value
Abinash Meher
@abinashmeher999
May 31 2016 17:59 UTC
Ah, I see. Thanks. So we will need the new method for RealMPFR
Isuru Fernando
@isuruf
May 31 2016 18:01 UTC
@rajithv, a constructor for RealMPFR should take in a string as well
Rajith Vidanaarachchi
@rajithv
May 31 2016 18:02 UTC

Aha okay (y)

A similar approach would be okay for ComplexMPC, a convert can convert a Complex made up with BigDecimal or it should have a new method taking two SymEngine::MPFRs as input.. sounds good?

Isuru Fernando
@isuruf
May 31 2016 18:07 UTC
just convert would be enough
Rajith Vidanaarachchi
@rajithv
May 31 2016 18:07 UTC
okay then