These are chat archives for symengine/symengine

12th
Jun 2016
Srajan Garg
@srajangarg
Jun 12 2016 08:58
@isuruf I can't get a reference to integer_class from a flint polynomial, as internally they are stored as fmpzxx. What can be done? One is to keep the std::pair as is
Isuru Fernando
@isuruf
Jun 12 2016 09:38
Yeah, when INTEGER_CLASS==flint it is possible, but otherwise it is not
Srajan Garg
@srajangarg
Jun 12 2016 09:45
One other possibility is that get_coeff returns reference of the native type, but we use to_integer_class everywhere else (eg. in as_symbolic etc) It won't affect performance (will be the same), but will have to use to_integer_class(it->second) instead of just it->second everywhere
Isuru Fernando
@isuruf
Jun 12 2016 09:46
+1
to_integer_class(const integer_class &a) works right?
Srajan Garg
@srajangarg
Jun 12 2016 09:57
I'll add it, I don't think it's there right now
Srajan Garg
@srajangarg
Jun 12 2016 10:33
@isuruf we should stick to the current implementation. Returning references is becoming a problem. Flint return references, but not of type flint:fmpzxx but an expression template. We anyways will have to convert it to flint:fmpzxx, so there's no point of the reference.
Isuru Fernando
@isuruf
Jun 12 2016 10:35
static_cast<fmpz_wrapper &>(fmpz_poly_get_coeff_ptr(p._poly(), n))
Srajan Garg
@srajangarg
Jun 12 2016 10:38
or
static_cast<flint::fmpzxx &>(fmpz_poly_get_coeff_ptr(p._poly(), n))
Isuru Fernando
@isuruf
Jun 12 2016 10:40
I don't think that would work
Srajan Garg
@srajangarg
Jun 12 2016 10:41
I'll try it out and get back to you. Do you know how to get const reference to piranha polys' coefficients?
Isuru Fernando
@isuruf
Jun 12 2016 10:47
Check piranha's find_cf method's implementation find_cf_impl
Isuru Fernando
@isuruf
Jun 12 2016 14:03
@srajangarg, commented on the PR
get_coeff_ref should throw an error if the term is not found
Isuru Fernando
@isuruf
Jun 12 2016 14:14
For now let's go with the global variable approach.
Make that a static local variable