// SetNum sets the numerator of z returning z // // NB this isn't part of math/big which uses Num().Set() for this // purpose. In gmp Num() returns a copy hence the need for a SetNum() // method. func (z *Rat) SetNum(a *Int) *Rat { z.doinit() a.doinit() C.mpq_set_num(&z.i[0], &a.i[0]) C.mpq_canonicalize(&z.i[0]) return z }
// SetFrac sets z to a/b and returns z. func (z *Rat) SetFrac(a, b *Int) *Rat { z.doinit() a.doinit() b.doinit() // FIXME copying? or referencing? C.mpq_set_num(&z.i[0], &a.i[0]) C.mpq_set_den(&z.i[0], &b.i[0]) C.mpq_canonicalize(&z.i[0]) return z }
func (q *Rat) SetNum(n *Int) *Rat { q.doinit() n.doinit() C.mpq_set_num(&q.i[0], &n.i[0]) return q }