These are chat archives for symengine/symengine

11th
May 2016
Isuru Fernando
@isuruf
May 11 2016 02:26
A UnivariateExprPolynomial.
Iris Lui
@irislq
May 11 2016 03:00
Really? But why?
Isuru Fernando
@isuruf
May 11 2016 03:13
A UnivariateExprPolynomial would be mutable and it can be used in UnivariateSeries
Iris Lui
@irislq
May 11 2016 06:14
@isuruf I'm about to sleep as it is nighttime here, but I have started making the changes for UnivariatePolynomial and UnivariateExprPolynomial here chenchfort/symengine#9
Shivam Vats
@shivamvats
May 11 2016 07:32
@StoicBronco Don't worry. See you.
@myluszczak Thanks for the update!
Srajan Garg
@srajangarg
May 11 2016 14:59
@isuruf Have you thought about introducing the piranha_integer_class, to decide which coefficients will be used by Piranha, at compile time? Also is there any work to be done on the fmpz_wrapper class?
Isuru Fernando
@isuruf
May 11 2016 15:00
Hmm, I'm not sure I understand
Srajan Garg
@srajangarg
May 11 2016 15:04
Just like integer_class decides which integers SymEngine will use, piranha_integer_class will decide which class SymEngine will use when using Piranha
ie, whherever SymEngine uses Piranha, eg. SeriesPiranha and upcoming PolynomialPiranha, it will decide what coefficients will be used
eg. In URatPSeriesPiranha right now piranha::rational is used
Isuru Fernando
@isuruf
May 11 2016 15:06
You are saying instead of piranha::rational, use rational_class?
Srajan Garg
@srajangarg
May 11 2016 15:06
Ya that can be done too, but that's not I was saying
Umm, If we make a Piranha wrapper for int polynomials, we will have to use some integer class
either piranha::int, or GMP::int or machine ints
Isuru Fernando
@isuruf
May 11 2016 15:07
Why not use integer_class for it?
Srajan Garg
@srajangarg
May 11 2016 15:08
More customizability?
Yes, my initial thoughts were too use integer_class too
Isuru Fernando
@isuruf
May 11 2016 15:09
Adding too many options is not a good idea. We will have to check each one on travis too
Srajan Garg
@srajangarg
May 11 2016 15:09
Oh ok, will default to integer_class then
Isuru Fernando
@isuruf
May 11 2016 15:10
@bluescarni, do you have any optimizations enabled just for piranha::integer when used in polynomials or any integer class would do?
Srajan Garg
@srajangarg
May 11 2016 15:12
He said earlier, for single word size integers FLINT will be the fastest. For 1-2 word size ints, Piranha does have optimizations which work faster than GMP, and for larger numbers it just defaults to GMP routines.
Isuru Fernando
@isuruf
May 11 2016 15:13
Yes, that's not what I meant. I was asking about any optimizations for polynomials when the coefficients are piranha::integer or piranha::rational?
Srajan Garg
@srajangarg
May 11 2016 15:14
I think he meant optimizations in the polynomial manipulation only, or was it integer operations?
Isuru Fernando
@isuruf
May 11 2016 15:15
He meant integer operations
Francesco Biscani
@bluescarni
May 11 2016 15:36
so there are some optimisations for rational and integer, but only those for rational coefficients are "hard-coded"
by this I mean that any integral class can implement the same optimisations, provided it implements certain methods
for instance, when doing polynomial multiplication piranha uses a multiply_accumulate operation on the coefficients, which is faster than doing a = a + b*c
in piranha you can specify specialisations of multiply_accumulate for any class, via template specialisation
so you could write for instance a specialisation of multiply_accumulate that operates on mpz_class
and uses internally mpz_addmul
Francesco Biscani
@bluescarni
May 11 2016 15:43
you would do it roughly like this:
namespace piranha { namespace math {

template <typename T>
struct multiply_accumulate_impl<T,T,T,typename std::enable_if<std::is_same<T,mpz_class>::value>::type>
{
    void operator()(T &x, const T &y, const T &z) const
    {
             mpz_addmul(x.mpz_t(),y.mpz_t(),z.mpz_t());
    }
};
}}
then the multiply_accumulate operation specialised for mpz_class would be used automatically by piranha's poly multiplication routines
the rational coefficients have some optimisations which I haven't gotten around generalising yet. specifically, before doing a polynomial multiplication with rational coefficients, the two polynomial operands' coefficients are reduced to the same denominator, the multiplication is performed over the integers, and at the end the resulting rationals are renormalised via GCD
Isuru Fernando
@isuruf
May 11 2016 16:19
Thanks. We'll implement multiply_accumulate