blob: 8a2fc7ad066f2392a4c1bc0caa422df429944582 [file] [log] [blame]
Austin Schuhdace2a62020-08-18 10:56:48 -07001/* Reference rational routines.
2
3Copyright 2001 Free Software Foundation, Inc.
4
5This file is part of the GNU MP Library test suite.
6
7The GNU MP Library test suite is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 3 of the License,
10or (at your option) any later version.
11
12The GNU MP Library test suite is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15Public License for more details.
16
17You should have received a copy of the GNU General Public License along with
18the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */
19
20#include "gmp-impl.h"
21#include "tests.h"
22
23
24void
25refmpq_add (mpq_ptr w, mpq_srcptr x, mpq_srcptr y)
26{
27 mpz_mul (mpq_numref(w), mpq_numref(x), mpq_denref(y));
28 mpz_addmul (mpq_numref(w), mpq_denref(x), mpq_numref(y));
29 mpz_mul (mpq_denref(w), mpq_denref(x), mpq_denref(y));
30 mpq_canonicalize (w);
31}
32
33void
34refmpq_sub (mpq_ptr w, mpq_srcptr x, mpq_srcptr y)
35{
36 mpz_mul (mpq_numref(w), mpq_numref(x), mpq_denref(y));
37 mpz_submul (mpq_numref(w), mpq_denref(x), mpq_numref(y));
38 mpz_mul (mpq_denref(w), mpq_denref(x), mpq_denref(y));
39 mpq_canonicalize (w);
40}