forked from flintlib/flint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mpfr_poly.h
130 lines (91 loc) · 3.69 KB
/
mpfr_poly.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
/*=============================================================================
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) 2010 William Hart
******************************************************************************/
#ifndef MFPR_POLY_H
#define MPFR_POLY_H
#include <mpir.h>
#include <mpfr.h>
#include "flint.h"
typedef struct
{
__mpfr_struct * coeffs;
long length;
long alloc;
mpfr_prec_t prec;
} mpfr_poly_struct;
/* fmpz_poly_t allows reference-like semantics for fmpz_poly_struct */
typedef mpfr_poly_struct mpfr_poly_t[1];
extern gmp_randstate_t mpfr_poly_randstate;
#define MUL_INPLACE_CUTOFF 1000
void mpfr_poly_init(mpfr_poly_t poly, mpfr_prec_t prec);
void mpfr_poly_init2(mpfr_poly_t poly, long alloc, mpfr_prec_t prec);
void mpfr_poly_realloc(mpfr_poly_t poly, long alloc);
void mpfr_poly_fit_length(mpfr_poly_t poly, long length);
void mpfr_poly_clear(mpfr_poly_t poly);
static __inline__
void _mpfr_poly_set_length(mpfr_poly_t poly, long length)
{
poly->length = length;
}
static __inline__
void mpfr_poly_set_prec(mpfr_poly_t poly, mpfr_prec_t prec)
{
long i;
for (i = 0; i < poly->alloc; i++)
mpfr_prec_round(poly->coeffs + i, prec, GMP_RNDN);
poly->prec = prec;
}
void mpfr_poly_randinit(void);
void mpfr_poly_randclear(void);
void mpfr_poly_randtest(mpfr_poly_t poly, long length);
static __inline__
void mpfr_poly_swap(mpfr_poly_t poly1, mpfr_poly_t poly2)
{
mpfr * tc;
long t;
mpfr_prec_t tp;
tc = poly1->coeffs;
poly1->coeffs = poly2->coeffs;
poly2->coeffs = tc;
t = poly1->length;
poly1->length = poly2->length;
poly2->length = t;
t = poly1->alloc;
poly1->alloc = poly2->alloc;
poly2->alloc = t;
tp = poly1->prec;
poly1->prec = poly2->prec;
poly2->prec = tp;
}
void _mpfr_poly_mul_classical(mpfr * res, mpfr * in1, long len1,
mpfr * in2, long len2, mpfr_prec_t prec);
void mpfr_poly_mul_classical(mpfr_poly_t res, mpfr_poly_t poly1,
mpfr_poly_t poly2);
void _mpfr_poly_FHT(mpfr * coeffs, long n, mpfr_prec_t prec);
void _mpfr_poly_convolution_trans(mpfr * coeffs1,
mpfr * coeffs2, long n, mpfr_prec_t prec);
void _mpfr_poly_revbin(mpfr * coeffs, long n);
void _mpfr_poly_scale(mpfr * coeffs, long n);
void _mpfr_poly_convolution_FHT(mpfr * coeffs1,
mpfr * coeffs2, long n, mpfr_prec_t prec);
void mpfr_poly_mul_FHT(mpfr_poly_t res, mpfr_poly_t poly1,
mpfr_poly_t poly2);
int _mpfr_poly_bound_newton(double * inter, double * slope,
mpfr * poly, long len, mpfr_prec_t prec);
void mpfr_poly_mul(mpfr_poly_t res, mpfr_poly_t poly1,
mpfr_poly_t poly2, mpfr_prec_t fb);
#endif