These are chat archives for bluescarni/piranha

26th
Jul 2016
Srajan Garg
@srajangarg
Jul 26 2016 11:18
@bluescarni is there an inplace function for multiplying a poly with a scalar (say a rational) likemath::scale (like math::negate?)
Francesco Biscani
@bluescarni
Jul 26 2016 11:19
you can use the in-place multiplication operator
x *= 2_q should work
Srajan Garg
@srajangarg
Jul 26 2016 11:19
Right thanks
Francesco Biscani
@bluescarni
Jul 26 2016 11:19
sure np
Srajan Garg
@srajangarg
Jul 26 2016 14:43
What is the analogous of piranha::integer::_get_mpz_ptr() for the rational case? Seems like _get_mpq_ptr() is not defined
Francesco Biscani
@bluescarni
Jul 26 2016 14:46
well the integer class is backed by an mpz integer (when using dynamic storage), but the rational class is not
rational is just a pair of integer
so in some sense integer is built on top of mpz but rational is not built on top of mpq
the closest thing you can do is to get mpz_ptrs for numerator and denominator
what do you need the mpq_ptr for?
Srajan Garg
@srajangarg
Jul 26 2016 14:50
I needed it for converting our flint::rational wrapper to piranha::rational, as there is directly fmpq_get_mpq. But I can get the mpq from flint and construct piranha::rational from that right?
Francesco Biscani
@bluescarni
Jul 26 2016 14:51
yep that would work
Srajan Garg
@srajangarg
Jul 26 2016 14:52
piranha::rational x;
mpq_wrapper s;
fmpq_get_mpq(s.get_mpq_t(), i.get_fmpq_t());
return x(s.get_mpq_t());
Francesco Biscani
@bluescarni
Jul 26 2016 14:53
you can just do return rational(s.get_mpq_t());
Srajan Garg
@srajangarg
Jul 26 2016 14:53
Okay the problem is that I dont' have mpq_wrapper defined
because the integer class is piranha
mpq_ptr s;
fmpq_get_mpq(s, i.get_fmpq_t());
return rational_class(s);
Is this safe^
Francesco Biscani
@bluescarni
Jul 26 2016 14:55
mpq_ptr is supposed to be mpq_t?
Srajan Garg
@srajangarg
Jul 26 2016 14:56
I don't know, it's not defined anywhere
Francesco Biscani
@bluescarni
Jul 26 2016 14:57
if you can get an mpq_t out of flint then you can use it to construct a piranha ratioanl
it's safe from the point of view of piranha, but you will need to take care of managing the mpq_t yourself (init / free)
I need to run, can talk later
Srajan Garg
@srajangarg
Jul 26 2016 14:58
That's what fmpq_get_mpq does, I'll check if it's directly possible
Okay
thanks
Srajan Garg
@srajangarg
Jul 26 2016 18:13
Can I set the num/den separately