forked from flintlib/flint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fmpz_poly_q.h
182 lines (123 loc) · 5.96 KB
/
fmpz_poly_q.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*=============================================================================
This file is part of FLINT.
FLINT is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
FLINT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FLINT; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=============================================================================*/
/******************************************************************************
Copyright (C) 2009, 2010, 2011 Sebastian Pancratz
******************************************************************************/
#ifndef FMPZ_POLY_Q_H
#define FMPZ_POLY_Q_H
#undef ulong /* interferes with system includes */
#include <stdlib.h>
#define ulong unsigned long
#include "flint.h"
#include "fmpz.h"
#include "fmpz_poly.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
fmpz_poly_struct *num;
fmpz_poly_struct *den;
} fmpz_poly_q_struct;
typedef fmpz_poly_q_struct fmpz_poly_q_t[1];
/* Accessing numerator and denominator ***************************************/
#define fmpz_poly_q_numref(op) ((op)->num)
#define fmpz_poly_q_denref(op) ((op)->den)
void fmpz_poly_q_canonicalise(fmpz_poly_q_t rop);
int fmpz_poly_q_is_canonical(const fmpz_poly_q_t op);
/* Memory management *********************************************************/
void fmpz_poly_q_init(fmpz_poly_q_t rop);
void fmpz_poly_q_clear(fmpz_poly_q_t rop);
/* Randomisation *************************************************************/
void fmpz_poly_q_randtest(fmpz_poly_q_t poly, flint_rand_t state,
long len1, mp_bitcnt_t bits1,
long len2, mp_bitcnt_t bits2);
void fmpz_poly_q_randtest_not_zero(fmpz_poly_q_t poly, flint_rand_t state,
long len1, mp_bitcnt_t bits1,
long len2, mp_bitcnt_t bits2);
/* Assignment ****************************************************************/
void fmpz_poly_q_set(fmpz_poly_q_t rop, const fmpz_poly_q_t op);
void fmpz_poly_q_set_si(fmpz_poly_q_t rop, long op);
void fmpz_poly_q_swap(fmpz_poly_q_t op1, fmpz_poly_q_t op2);
static __inline__
void fmpz_poly_q_zero(fmpz_poly_q_t rop)
{
fmpz_poly_zero(rop->num);
fmpz_poly_set_si(rop->den, 1);
}
static __inline__
void fmpz_poly_q_one(fmpz_poly_q_t rop)
{
fmpz_poly_set_si(rop->num, 1);
fmpz_poly_set_si(rop->den, 1);
}
static __inline__
void fmpz_poly_q_neg(fmpz_poly_q_t rop, const fmpz_poly_q_t op)
{
fmpz_poly_neg(rop->num, op->num);
fmpz_poly_set(rop->den, op->den);
}
void fmpz_poly_q_inv(fmpz_poly_q_t rop, const fmpz_poly_q_t op);
/* Comparison ****************************************************************/
static __inline__
int fmpz_poly_q_is_zero(const fmpz_poly_q_t op)
{
return fmpz_poly_is_zero(op->num);
}
static __inline__
int fmpz_poly_q_is_one(const fmpz_poly_q_t op)
{
return fmpz_poly_is_one(op->num) && fmpz_poly_is_one(op->den);
}
static __inline__
int fmpz_poly_q_equal(const fmpz_poly_q_t op1, const fmpz_poly_q_t op2)
{
return fmpz_poly_equal(op1->num, op2->num) && fmpz_poly_equal(op1->den, op2->den);
}
/* Addition and subtraction **************************************************/
void fmpz_poly_q_add_in_place(fmpz_poly_q_t rop, const fmpz_poly_q_t op);
void fmpz_poly_q_sub_in_place(fmpz_poly_q_t rop, const fmpz_poly_q_t op);
void fmpz_poly_q_add(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2);
void fmpz_poly_q_sub(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2);
void fmpz_poly_q_addmul(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2);
void fmpz_poly_q_submul(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2);
/* Scalar multiplication and division ****************************************/
void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x);
void fmpz_poly_q_scalar_mul_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x);
void fmpz_poly_q_scalar_mul_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x);
void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x);
void fmpz_poly_q_scalar_div_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x);
void fmpz_poly_q_scalar_div_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x);
/* Multiplication and division ***********************************************/
void fmpz_poly_q_mul(fmpz_poly_q_t rop,
const fmpz_poly_q_t op1, const fmpz_poly_q_t op2);
void fmpz_poly_q_div(fmpz_poly_q_t rop,
const fmpz_poly_q_t op1, const fmpz_poly_q_t op2);
/* Powering ******************************************************************/
void fmpz_poly_q_pow(fmpz_poly_q_t rop, const fmpz_poly_q_t op, ulong exp);
/* Derivative ****************************************************************/
void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op);
/* Evaluation ****************************************************************/
int fmpz_poly_q_evaluate(mpq_t rop, const fmpz_poly_q_t f, const mpq_t a);
/* Input and output **********************************************************/
int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s);
char * fmpz_poly_q_get_str(const fmpz_poly_q_t op);
char * fmpz_poly_q_get_str_pretty(const fmpz_poly_q_t op, const char *x);
int fmpz_poly_q_print(const fmpz_poly_q_t op);
int fmpz_poly_q_print_pretty(const fmpz_poly_q_t op, const char *x);
#ifdef __cplusplus
}
#endif
#endif