passagemath-gap-pkg-float 10.8.1a4__cp311-cp311-macosx_13_0_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. gap/pkg/float/COPYING +340 -0
  2. gap/pkg/float/PackageInfo.g +109 -0
  3. gap/pkg/float/README.md +76 -0
  4. gap/pkg/float/THANKS +1 -0
  5. gap/pkg/float/TODO +9 -0
  6. gap/pkg/float/bin/x86_64-apple-darwin24-default64-kv10/float.so +0 -0
  7. gap/pkg/float/build-aux/compile +348 -0
  8. gap/pkg/float/build-aux/config.guess~ +1748 -0
  9. gap/pkg/float/build-aux/config.sub~ +1884 -0
  10. gap/pkg/float/build-aux/depcomp +791 -0
  11. gap/pkg/float/build-aux/install-sh +541 -0
  12. gap/pkg/float/build-aux/install-sh~ +541 -0
  13. gap/pkg/float/build-aux/ltmain.sh +11524 -0
  14. gap/pkg/float/build-aux/missing +215 -0
  15. gap/pkg/float/config.h.in +105 -0
  16. gap/pkg/float/init.g +51 -0
  17. gap/pkg/float/lib/cxsc.gi +604 -0
  18. gap/pkg/float/lib/float.gd +187 -0
  19. gap/pkg/float/lib/fplll.gi +27 -0
  20. gap/pkg/float/lib/mpc.gi +243 -0
  21. gap/pkg/float/lib/mpfi.gi +270 -0
  22. gap/pkg/float/lib/mpfr.gi +328 -0
  23. gap/pkg/float/lib/pickle.g +131 -0
  24. gap/pkg/float/lib/polynomial.gi +12 -0
  25. gap/pkg/float/lib/pslq.gi +431 -0
  26. gap/pkg/float/libtool +12190 -0
  27. gap/pkg/float/makedoc.g +11 -0
  28. gap/pkg/float/read.g +46 -0
  29. gap/pkg/float/tst/arithmetic.tst +35 -0
  30. gap/pkg/float/tst/fplll.tst +19 -0
  31. gap/pkg/float/tst/polynomials.tst +30 -0
  32. gap/pkg/float/tst/testall.g +63 -0
  33. passagemath_gap_pkg_float/.dylibs/libfplll.9.dylib +0 -0
  34. passagemath_gap_pkg_float/.dylibs/libgmp.10.dylib +0 -0
  35. passagemath_gap_pkg_float/.dylibs/libmpc.3.dylib +0 -0
  36. passagemath_gap_pkg_float/.dylibs/libmpfi.0.dylib +0 -0
  37. passagemath_gap_pkg_float/.dylibs/libmpfr.6.dylib +0 -0
  38. passagemath_gap_pkg_float/__init__.py +3 -0
  39. passagemath_gap_pkg_float-10.8.1a4.dist-info/METADATA +92 -0
  40. passagemath_gap_pkg_float-10.8.1a4.dist-info/METADATA.bak +93 -0
  41. passagemath_gap_pkg_float-10.8.1a4.dist-info/RECORD +46 -0
  42. passagemath_gap_pkg_float-10.8.1a4.dist-info/WHEEL +6 -0
  43. passagemath_gap_pkg_float-10.8.1a4.dist-info/top_level.txt +2 -0
  44. sage/all__sagemath_gap_pkg_float.py +1 -0
  45. sage/libs/all__sagemath_gap_pkg_float.py +1 -0
  46. sage/libs/gap_pkg_float.cpython-311-darwin.so +0 -0
@@ -0,0 +1,270 @@
1
+ #############################################################################
2
+ ##
3
+ #W mpfi.gi GAP library Laurent Bartholdi
4
+ ##
5
+ #Y Copyright (C) 2008 Laurent Bartholdi
6
+ ##
7
+ ## This file deals with interval floats
8
+ ##
9
+
10
+ ################################################################
11
+ # viewers
12
+ ################################################################
13
+ InstallMethod(ViewString, "float", [IsMPFIFloat],
14
+ function(obj)
15
+ return VIEWSTRING_MPFI(obj,FLOAT.VIEW_DIG);
16
+ end);
17
+
18
+ InstallMethod(String, "float, int", [IsMPFIFloat, IsInt],
19
+ function(obj,len)
20
+ return STRING_MPFI(obj,len);
21
+ end);
22
+
23
+ InstallMethod(String, "float", [IsMPFIFloat],
24
+ obj->STRING_MPFI(obj,0));
25
+
26
+ BindGlobal("MPFIBITS@", function(obj)
27
+ local s;
28
+ s := ValueOption("bits");
29
+ if IsInt(s) then return s; fi;
30
+ if IsMPFIFloat(obj) then return PrecisionFloat(obj); fi;
31
+ return MPFI.constants.MANT_DIG;
32
+ end);
33
+
34
+ BindGlobal("MPFIFLOAT_STRING", s->MPFI_STRING(s,MPFIBITS@(fail)));
35
+
36
+ ################################################################
37
+ # constants
38
+ ################################################################
39
+ EAGER_FLOAT_LITERAL_CONVERTERS.i := MPFIFLOAT_STRING;
40
+
41
+ DeclareCategory("IsMPFIPseudoField", IsFloatPseudoField);
42
+ BindGlobal("MPFI_PSEUDOFIELD",
43
+ Objectify(NewType(CollectionsFamily(MPFIFloatsFamily),
44
+ IsMPFIPseudoField and IsAttributeStoringRep),rec()));
45
+ SetName(MPFI_PSEUDOFIELD, Concatenation("(",FLOAT_REAL_STRING,",",FLOAT_REAL_STRING,")"));
46
+
47
+ SetLeftActingDomain(MPFI_PSEUDOFIELD,Rationals);
48
+ SetCharacteristic(MPFI_PSEUDOFIELD,0);
49
+ SetDimension(MPFI_PSEUDOFIELD,infinity);
50
+ SetSize(MPFI_PSEUDOFIELD,infinity);
51
+ SetIsWholeFamily(MPFI_PSEUDOFIELD,true);
52
+ SetZero(MPFI_PSEUDOFIELD,MPFI_INT(0));
53
+ SetOne(MPFI_PSEUDOFIELD,MPFI_INT(1));
54
+ InstallMethod( \in, [IsMPFIFloat,IsMPFIPseudoField], ReturnTrue);
55
+
56
+ SetIsUFDFamily(MPFIFloatsFamily,true);
57
+ SetZero(MPFIFloatsFamily,MPFI_INT(0));
58
+ SetOne(MPFIFloatsFamily,MPFI_INT(1));
59
+
60
+ InstallValue(MPFI, rec(
61
+ creator := MPFIFLOAT_STRING,
62
+ eager := 'i',
63
+ filter := IsMPFIFloat,
64
+ field := MPFI_PSEUDOFIELD,
65
+ constants := rec(INFINITY := MPFI_MAKEINFINITY(1),
66
+ NINFINITY := MPFI_MAKEINFINITY(-1),
67
+ VIEW_DIG := 6,
68
+ MANT_DIG := 100,
69
+ NAN := MPFI_MAKENAN(1),
70
+ recompute := function(r,prec)
71
+ r.PI := MPFI_PI(prec);
72
+ r.1_PI := Inverse(r.PI);
73
+ r.2PI := MPFI_INT(2)*r.PI;
74
+ r.2_PI := MPFI_INT(2)*r.1_PI;
75
+ r.2_SQRTPI := MPFI_INT(2)/Sqrt(r.PI);
76
+ r.PI_2 := r.PI/MPFI_INT(2);
77
+ r.PI_4 := r.PI_2/MPFI_INT(2);
78
+
79
+ r.SQRT2 := Sqrt(MPFI_INTPREC(2,prec));
80
+ r.1_SQRT2 := Inverse(r.SQRT2);
81
+
82
+ r.E := Exp(MPFI_INTPREC(1,prec));
83
+ r.LN2 := Log(MPFI_INTPREC(2,prec));
84
+ r.LN10 := Log(MPFI_INTPREC(10,prec));
85
+ r.LOG10E := Inverse(r.LN10);
86
+ r.LOG2E := Inverse(r.LN2);
87
+ end)));
88
+
89
+ InstallMethod(ObjByExtRep, [IsMPFIFloatFamily,IsCyclotomicCollection],
90
+ function(family,obj)
91
+ return OBJBYEXTREP_MPFI(obj);
92
+ end);
93
+
94
+ ################################################################
95
+ # unary operations
96
+ ################################################################
97
+ CallFuncList(function(arg)
98
+ local i;
99
+ for i in arg do
100
+ InstallOtherMethod(VALUE_GLOBAL(i[1]), "MPFI float", [IsMPFIFloat], i[2]);
101
+ od;
102
+ end, [["AdditiveInverseSameMutability",AINV_MPFI],
103
+ ["AdditiveInverseMutable",AINV_MPFI],
104
+ ["InverseMutable",INV_MPFI],
105
+ ["InverseSameMutability",INV_MPFI],
106
+ ["Int",INT_MPFI],
107
+ ["AbsoluteValue",ABS_MPFI],
108
+ ["ZeroMutable",ZERO_MPFI],
109
+ ["ZeroImmutable",ZERO_MPFI],
110
+ ["ZeroSameMutability",ZERO_MPFI],
111
+ ["OneMutable",ONE_MPFI],
112
+ ["OneImmutable",ONE_MPFI],
113
+ ["OneSameMutability",ONE_MPFI],
114
+ ["Sqrt",SQRT_MPFI],
115
+ ["Cos",COS_MPFI],
116
+ ["Sin",SIN_MPFI],
117
+ ["Tan",TAN_MPFI],
118
+ ["Sec",SEC_MPFI],
119
+ ["Csc",CSC_MPFI],
120
+ ["Cot",COT_MPFI],
121
+ ["Asin",ASIN_MPFI],
122
+ ["Acos",ACOS_MPFI],
123
+ ["Atan",ATAN_MPFI],
124
+ ["Cosh",COSH_MPFI],
125
+ ["Sinh",SINH_MPFI],
126
+ ["Tanh",TANH_MPFI],
127
+ ["Sech",SECH_MPFI],
128
+ ["Csch",CSCH_MPFI],
129
+ ["Coth",COTH_MPFI],
130
+ ["Asinh",ASINH_MPFI],
131
+ ["Acosh",ACOSH_MPFI],
132
+ ["Atanh",ATANH_MPFI],
133
+ ["Log",LOG_MPFI],
134
+ ["Log2",LOG2_MPFI],
135
+ ["Log10",LOG10_MPFI],
136
+ ["Exp",EXP_MPFI],
137
+ ["Exp2",EXP2_MPFI],
138
+ ["Exp10",EXP10_MPFI],
139
+ ["CubeRoot",CBRT_MPFI],
140
+ ["Square",SQR_MPFI],
141
+ ["Inf", LEFT_MPFI],
142
+ ["Sup", RIGHT_MPFI],
143
+ ["Mid", MID_MPFI],
144
+ ["AbsoluteDiameter", DIAM_MPFI],
145
+ ["RelativeDiameter", DIAM_REL_MPFI],
146
+ ["BisectInterval", BISECT_MPFI],
147
+ ["Ceil",CEIL_MPFI],
148
+ ["Floor",FLOOR_MPFI],
149
+ ["Round",ROUND_MPFI],
150
+ ["Trunc",TRUNC_MPFI],
151
+ ["Frac",FRAC_MPFI],
152
+ ["FrExp",FREXP_MPFI],
153
+ ["Norm",SQR_MPFI],
154
+ ["Argument",ZERO_MPFI],
155
+ ["SignFloat",SIGN_MPFI],
156
+ ["IsXInfinity",ISXINF_MPFI],
157
+ ["IsPInfinity",ISPINF_MPFI],
158
+ ["IsNInfinity",ISNINF_MPFI],
159
+ ["IsFinite",ISNUMBER_MPFI],
160
+ ["IsNaN",ISNAN_MPFI],
161
+ ["IsZero",ISZERO_MPFI],
162
+ ["IsEmpty",ISEMPTY_MPFI],
163
+ ["ExtRepOfObj",EXTREPOFOBJ_MPFI],
164
+ ["RealPart",x->x],
165
+ ["ImaginaryPart",ZERO_MPFI],
166
+ ["ComplexConjugate",x->x],
167
+ ["PrecisionFloat",PREC_MPFI]]);
168
+
169
+ ################################################################
170
+ # binary operations
171
+ ################################################################
172
+ CallFuncList(function(arg)
173
+ local i;
174
+ for i in arg do
175
+ InstallMethod(VALUE_GLOBAL(i), "MPFI float, MPFI float", [IsMPFIFloat, IsMPFIFloat],
176
+ VALUE_GLOBAL(Concatenation(i,"_MPFI")));
177
+ InstallMethod(VALUE_GLOBAL(i), "MPFI float, MPFR float", [IsMPFIFloat, IsMPFRFloat],
178
+ VALUE_GLOBAL(Concatenation(i,"_MPFI_MPFR")));
179
+ InstallMethod(VALUE_GLOBAL(i), "MPFR float, MPFI float", [IsMPFRFloat, IsMPFIFloat],
180
+ VALUE_GLOBAL(Concatenation(i,"_MPFR_MPFI")));
181
+ od;
182
+ end, ["SUM","DIFF","QUO","PROD","LQUO","EQ","LT"]);
183
+
184
+ InstallMethod(LdExp, "MPFI float, int", [IsMPFIFloat, IsInt], LDEXP_MPFI);
185
+ InstallMethod(Atan2, "float", [IsMPFIFloat, IsMPFIFloat], ATAN2_MPFI);
186
+
187
+ InstallMethod(\^, "float, rat", [IsMPFIFloat, IsRat],
188
+ function(f,r)
189
+ if DenominatorRat(r)=1 then
190
+ TryNextMethod();
191
+ fi;
192
+ if NumeratorRat(r)<>1 then
193
+ f := f^NumeratorRat(r);
194
+ fi;
195
+ return ROOT_MPFI(f,DenominatorRat(r));
196
+ end);
197
+
198
+ InstallMethod(IsSubset, [IsMPFIFloat, IsMPFIFloat], ISINSIDE_MPFI);
199
+ InstallMethod(IN, [IsMPFIFloat, IsMPFIFloat], SUM_FLAGS, ISINSIDE_MPFI);
200
+ InstallMethod(IN, [IsMPFRFloat, IsMPFIFloat], SUM_FLAGS, ISINSIDE_MPFRMPFI);
201
+ InstallMethod(Intersection2, [IsMPFIFloat, IsMPFIFloat], INTERSECT_MPFI);
202
+ InstallMethod(Union2, [IsMPFIFloat, IsMPFIFloat], UNION_MPFI);
203
+ InstallMethod(IncreaseInterval, [IsMPFIFloat, IsMPFRFloat], BLOWUP_MPFI);
204
+ InstallMethod(IncreaseInterval, [IsMPFIFloat, IsMPFIFloat],
205
+ function(x,y) return INCREASE_MPFI(x,Sup(y)); end);
206
+ InstallMethod(BlowupInterval, [IsMPFIFloat, IsMPFIFloat], BLOWUP_MPFI);
207
+ InstallMethod(BlowupInterval, [IsMPFIFloat, IsMPFIFloat],
208
+ function(x,y) return BLOWUP_MPFI(x,Sup(y)); end);
209
+
210
+ ################################################################
211
+ # constructor
212
+ ################################################################
213
+
214
+ INSTALLFLOATCREATOR("for list", [IsMPFIFloat,IsList],
215
+ function(filter,list)
216
+ return OBJBYEXTREP_MPFI(list);
217
+ end);
218
+
219
+ INSTALLFLOATCREATOR("for integers", [IsMPFIFloat,IsInt], 20,
220
+ function(filter,int)
221
+ return MPFI_INTPREC(int,MPFIBITS@(filter));
222
+ end);
223
+
224
+ INSTALLFLOATCREATOR("for rationals", [IsMPFIFloat,IsRat], 10,
225
+ function(filter,rat)
226
+ local n, d, prec;
227
+ n := NumeratorRat(rat);
228
+ d := DenominatorRat(rat);
229
+ prec := MPFIBITS@(filter);
230
+ return MPFI_INTPREC(n,prec)/MPFI_INTPREC(d,prec);
231
+ end);
232
+
233
+ INSTALLFLOATCREATOR("for strings", [IsMPFIFloat,IsString],
234
+ function(filter,s)
235
+ return MPFI_STRING(s,MPFIBITS@(filter));
236
+ end);
237
+
238
+ INSTALLFLOATCREATOR("for MPFI float", [IsMPFIFloat,IsMPFIFloat],
239
+ function(filter,obj)
240
+ return MPFI_MPFIPREC(obj,MPFIBITS@(filter));
241
+ end);
242
+
243
+ INSTALLFLOATCREATOR("for MPFR float", [IsMPFIFloat,IsMPFRFloat],
244
+ function(filter,obj)
245
+ return MPFI_MPFR(obj);
246
+ end);
247
+
248
+ DECLAREFLOATCREATOR(IsMPFIFloat,IsMPFRFloat,IsMPFRFloat);
249
+ INSTALLFLOATCREATOR("for 2 MPFR floats", [IsMPFIFloat,IsMPFRFloat,IsMPFRFloat],
250
+ function(filter,re,im)
251
+ return MPFI_2MPFR(re,im);
252
+ end);
253
+
254
+ DECLAREFLOATCREATOR(IsMPFIFloat,IsInt,IsInt);
255
+ INSTALLFLOATCREATOR("for 2 ints", [IsMPFIFloat,IsInt,IsInt],
256
+ function(filter,re,im)
257
+ return MPFI_2MPFR(MPFR_INT(re),MPFR_INT(im));
258
+ end);
259
+
260
+ INSTALLFLOATCREATOR("for macfloat", [IsMPFIFloat,IsIEEE754FloatRep],
261
+ function(filter,obj)
262
+ return MPFI_MPFR(MPFR_MACFLOAT(obj));
263
+ end);
264
+
265
+ INSTALLFLOATCONSTRUCTORS(MPFI);
266
+ MPFI.constants.recompute(MPFI.constants,MPFI.constants.MANT_DIG);
267
+
268
+ #############################################################################
269
+ ##
270
+ #E
@@ -0,0 +1,328 @@
1
+ #############################################################################
2
+ ##
3
+ #W mpfr.gi GAP library Laurent Bartholdi
4
+ ##
5
+ #Y Copyright (C) 2008 Laurent Bartholdi
6
+ ##
7
+ ## This file deals with floats
8
+ ##
9
+
10
+ ################################################################
11
+ # viewers
12
+ ################################################################
13
+ BindGlobal("MPFRBITS@", function(obj)
14
+ local s;
15
+ s := ValueOption("bits");
16
+ if IsInt(s) then return s; fi;
17
+ if IsMPFRFloat(obj) then return PrecisionFloat(obj); fi;
18
+ return MPFR.constants.MANT_DIG;
19
+ end);
20
+
21
+ InstallMethod(ViewString, "float", [IsMPFRFloat],
22
+ function(obj)
23
+ return STRING_MPFR(obj,FLOAT.VIEW_DIG);
24
+ end);
25
+
26
+ InstallMethod(String, "float, int", [IsMPFRFloat, IsInt],
27
+ function(obj,len)
28
+ return STRING_MPFR(obj,len);
29
+ end);
30
+
31
+ InstallMethod(String, "float", [IsMPFRFloat],
32
+ obj->STRING_MPFR(obj,0));
33
+
34
+ BindGlobal("MPFRFLOAT_STRING", s->MPFR_STRING(s,MPFRBITS@(fail)));
35
+
36
+ ################################################################
37
+ # constants
38
+ ################################################################
39
+ EAGER_FLOAT_LITERAL_CONVERTERS.r := MPFRFLOAT_STRING;
40
+
41
+ DeclareCategory("IsMPFRPseudoField", IsFloatPseudoField);
42
+ BindGlobal("MPFR_PSEUDOFIELD",
43
+ Objectify(NewType(CollectionsFamily(MPFRFloatsFamily),
44
+ IsMPFRPseudoField and IsAttributeStoringRep),rec()));
45
+ SetName(MPFR_PSEUDOFIELD, FLOAT_REAL_STRING);
46
+
47
+ SetLeftActingDomain(MPFR_PSEUDOFIELD,Rationals);
48
+ SetCharacteristic(MPFR_PSEUDOFIELD,0);
49
+ SetDimension(MPFR_PSEUDOFIELD,infinity);
50
+ SetSize(MPFR_PSEUDOFIELD,infinity);
51
+ SetIsWholeFamily(MPFR_PSEUDOFIELD,true);
52
+ SetZero(MPFR_PSEUDOFIELD,MPFR_INT(0));
53
+ SetOne(MPFR_PSEUDOFIELD,MPFR_INT(1));
54
+ InstallMethod( \in, [IsMPFRFloat,IsMPFRPseudoField], ReturnTrue);
55
+
56
+ SetIsUFDFamily(MPFRFloatsFamily,true);
57
+ SetZero(MPFRFloatsFamily,MPFR_INT(0));
58
+ SetOne(MPFRFloatsFamily,MPFR_INT(1));
59
+
60
+ InstallValue(MPFR, rec(
61
+ creator := MPFRFLOAT_STRING,
62
+ eager := 'r',
63
+ filter := IsMPFRFloat,
64
+ field := MPFR_PSEUDOFIELD,
65
+ constants := rec(INFINITY := MPFR_MAKEINFINITY(1),
66
+ NINFINITY := MPFR_MAKEINFINITY(-1),
67
+ VIEW_DIG := 6,
68
+ DECIMAL_DIG := 30,
69
+ MANT_DIG := 100,
70
+ NAN := MPFR_MAKENAN(1),
71
+ recompute := function(r,prec)
72
+ r.PI := MPFR_PI(prec);
73
+ r.1_PI := Inverse(r.PI);
74
+ r.2PI := MPFR_INT(2)*r.PI;
75
+ r.2_PI := MPFR_INT(2)*r.1_PI;
76
+ r.2_SQRTPI := MPFR_INT(2)/Sqrt(r.PI);
77
+ r.PI_2 := r.PI/MPFR_INT(2);
78
+ r.PI_4 := r.PI_2/MPFR_INT(2);
79
+
80
+ r.SQRT2 := Sqrt(MPFR_INTPREC(2,prec));
81
+ r.1_SQRT2 := Inverse(r.SQRT2);
82
+
83
+ r.E := Exp(MPFR_INTPREC(1,prec));
84
+ r.LN2 := Log(MPFR_INTPREC(2,prec));
85
+ r.LN10 := Log(MPFR_INTPREC(10,prec));
86
+ r.LOG10E := Inverse(r.LN10);
87
+ r.LOG2E := Inverse(r.LN2);
88
+ end)));
89
+
90
+ InstallMethod(ObjByExtRep, [IsMPFRFloatFamily,IsCyclotomicCollection],
91
+ function(family,obj)
92
+ return OBJBYEXTREP_MPFR(obj);
93
+ end);
94
+
95
+ ################################################################
96
+ # unary operations
97
+ ################################################################
98
+ CallFuncList(function(arg)
99
+ local i;
100
+ for i in arg do
101
+ InstallOtherMethod(VALUE_GLOBAL(i[1]), "MPFR float", [IsMPFRFloat], i[2]);
102
+ od;
103
+ end, [["AdditiveInverseSameMutability",AINV_MPFR],
104
+ ["AdditiveInverseMutable",AINV_MPFR],
105
+ ["InverseMutable",INV_MPFR],
106
+ ["InverseImmutable",INV_MPFR],
107
+ ["InverseSameMutability",INV_MPFR],
108
+ ["Int",INT_MPFR],
109
+ ["AbsoluteValue",ABS_MPFR],
110
+ ["ZeroMutable",ZERO_MPFR],
111
+ ["ZeroImmutable",ZERO_MPFR],
112
+ ["ZeroSameMutability",ZERO_MPFR],
113
+ ["OneMutable",ONE_MPFR],
114
+ ["OneImmutable",ONE_MPFR],
115
+ ["OneSameMutability",ONE_MPFR],
116
+ ["Sqrt",SQRT_MPFR],
117
+ ["Cos",COS_MPFR],
118
+ ["Sin",SIN_MPFR],
119
+ ["SinCos",SINCOS_MPFR],
120
+ ["Tan",TAN_MPFR],
121
+ ["Sec",SEC_MPFR],
122
+ ["Csc",CSC_MPFR],
123
+ ["Cot",COT_MPFR],
124
+ ["Asin",ASIN_MPFR],
125
+ ["Acos",ACOS_MPFR],
126
+ ["Atan",ATAN_MPFR],
127
+ ["Cosh",COSH_MPFR],
128
+ ["Sinh",SINH_MPFR],
129
+ ["Tanh",TANH_MPFR],
130
+ ["Sech",SECH_MPFR],
131
+ ["Csch",CSCH_MPFR],
132
+ ["Coth",COTH_MPFR],
133
+ ["Asinh",ASINH_MPFR],
134
+ ["Acosh",ACOSH_MPFR],
135
+ ["Atanh",ATANH_MPFR],
136
+ ["Log",LOG_MPFR],
137
+ ["Log2",LOG2_MPFR],
138
+ ["Log10",LOG10_MPFR],
139
+ ["Log1p",LOG1P_MPFR],
140
+ ["Exp",EXP_MPFR],
141
+ ["Exp2",EXP2_MPFR],
142
+ ["Exp10",EXP10_MPFR],
143
+ ["Expm1",EXPM1_MPFR],
144
+ ["CubeRoot",CBRT_MPFR],
145
+ ["Square",SQR_MPFR],
146
+ ["Ceil",CEIL_MPFR],
147
+ ["Floor",FLOOR_MPFR],
148
+ ["Round",ROUND_MPFR],
149
+ ["Trunc",TRUNC_MPFR],
150
+ ["Frac",FRAC_MPFR],
151
+ ["FrExp",FREXP_MPFR],
152
+ ["Norm",SQR_MPFR],
153
+ ["Argument",ZERO_MPFR],
154
+ ["SignFloat",SIGN_MPFR],
155
+ ["SignBit",SIGNBIT_MPFR],
156
+ ["IsXInfinity",ISXINF_MPFR],
157
+ ["IsPInfinity",ISPINF_MPFR],
158
+ ["IsNInfinity",ISNINF_MPFR],
159
+ ["IsFinite",ISNUMBER_MPFR],
160
+ ["IsNaN",ISNAN_MPFR],
161
+ ["ExtRepOfObj",EXTREPOFOBJ_MPFR],
162
+ ["RealPart",x->x],
163
+ ["ImaginaryPart",ZERO_MPFR],
164
+ ["ComplexConjugate",x->x],
165
+ ["PrecisionFloat",PREC_MPFR]]);
166
+
167
+ ################################################################
168
+ # binary operations
169
+ ################################################################
170
+ CallFuncList(function(arg)
171
+ local i;
172
+ for i in arg do
173
+ InstallMethod(VALUE_GLOBAL(i), "float", [IsMPFRFloat, IsMPFRFloat],
174
+ VALUE_GLOBAL(Concatenation(i,"_MPFR")));
175
+ od;
176
+ end, ["SUM","DIFF","QUO","PROD","LQUO","MOD","POW","EQ","LT"]);
177
+
178
+ InstallMethod(EqFloat, "float, float", [IsMPFRFloat, IsMPFRFloat], EQ_MPFR);
179
+
180
+ InstallMethod(\^, "float, rat", [IsMPFRFloat, IsRat],
181
+ function(f,r)
182
+ if DenominatorRat(r)=1 then
183
+ TryNextMethod();
184
+ fi;
185
+ if NumeratorRat(r)<>1 then
186
+ f := f^NumeratorRat(r);
187
+ fi;
188
+ return ROOT_MPFR(f,DenominatorRat(r));
189
+ end);
190
+
191
+ InstallMethod(Atan2, "MPFR float, MPFR float", [IsMPFRFloat, IsMPFRFloat], ATAN2_MPFR);
192
+ InstallMethod(Hypothenuse, "MPFR float, MPFR float", [IsMPFRFloat, IsMPFRFloat], HYPOT_MPFR);
193
+ InstallMethod(LdExp, "MPFR float, int", [IsMPFRFloat, IsInt], LDEXP_MPFR);
194
+
195
+ if not IsBound(ROOTPOLY_MPC) then
196
+ ROOTPOLY_MPC := fail; # shut up parser
197
+ else
198
+ InstallMethod(RootsFloatOp, "MPFR float list, MPFR float",
199
+ [IsList,IsMPFRFloat],
200
+ function(coeff,tag)
201
+ local roots, i, j, r, lone;
202
+
203
+ if not ForAll(coeff,IsMPFRFloat) then
204
+ TryNextMethod();
205
+ fi;
206
+ roots := ROOTPOLY_MPC(List(coeff,x->NewFloat(IsMPCFloat,x)),MPFRBITS@(fail));
207
+ for i in [1..Length(roots)] do
208
+ # ugly and mathematically wrong!
209
+ if AbsoluteValue(ImaginaryPart(roots[i]))<1.e-10_r then
210
+ roots[i] := RealPart(roots[i]);
211
+ # else
212
+ # Unbind(roots[i]); # should we remove complex roots?
213
+ fi;
214
+ continue;
215
+
216
+ # following code tries to find out which roots are real, but is too
217
+ # slow (O(n^2))
218
+ r := 10.0_r*Norm(ImaginaryPart(roots[i]));
219
+ lone := true;
220
+ for j in [1..Length(roots)] do
221
+ if i<>j and Norm(roots[i]-roots[j]) <= r then
222
+ lone := false;
223
+ break;
224
+ fi;
225
+ od;
226
+ if lone then
227
+ roots[i] := RealPart(roots[i]);
228
+ fi;
229
+ od;
230
+ return Compacted(roots);
231
+ end);
232
+ fi;
233
+ if ROOTPOLY_MPC=fail then Unbind(ROOTPOLY_MPC); fi;
234
+
235
+ ################################################################
236
+ # constructor
237
+ ################################################################
238
+
239
+ INSTALLFLOATCREATOR("for list", [IsMPFRFloat,IsList],
240
+ function(filter,list)
241
+ return OBJBYEXTREP_MPFR(list);
242
+ end);
243
+
244
+ INSTALLFLOATCREATOR("for integers", [IsMPFRFloat,IsInt], 20,
245
+ function(filter,int)
246
+ return MPFR_INTPREC(int,MPFRBITS@(filter));
247
+ end);
248
+
249
+ INSTALLFLOATCREATOR("for rationals", [IsMPFRFloat,IsRat], 10,
250
+ function(filter,rat)
251
+ local n, d, prec;
252
+ n := NumeratorRat(rat);
253
+ d := DenominatorRat(rat);
254
+ prec := MPFRBITS@(filter);
255
+ return MPFR_INTPREC(n,prec)/MPFR_INTPREC(d,prec);
256
+ end);
257
+
258
+ INSTALLFLOATCREATOR("for strings", [IsMPFRFloat,IsString],
259
+ function(filter,s)
260
+ return MPFR_STRING(s,MPFRBITS@(filter));
261
+ end);
262
+
263
+ INSTALLFLOATCREATOR("for float", [IsMPFRFloat,IsMPFRFloat],
264
+ function(filter,obj)
265
+ return MPFR_MPFRPREC(obj,MPFRBITS@(filter));
266
+ end);
267
+
268
+ INSTALLFLOATCREATOR("for float and precision", [IsMPFRFloat,IsMPFRFloat,IsInt],
269
+ function(filter,obj,prec)
270
+ return MPFR_MPFRPREC(obj,prec);
271
+ end);
272
+
273
+ INSTALLFLOATCREATOR("for macfloat", [IsMPFRFloat,IsIEEE754FloatRep],
274
+ function(filter,obj)
275
+ return MPFR_MACFLOAT(obj);
276
+ end);
277
+
278
+ INSTALLFLOATCREATOR("for macfloat and precision", [IsMPFRFloat,IsIEEE754FloatRep,IsInt],
279
+ function(filter,obj,prec)
280
+ return MPFR_MPFRPREC(MPFR_MACFLOAT(obj),prec);
281
+ end);
282
+
283
+ INSTALLFLOATCREATOR("for float", [IsIEEE754FloatRep,IsMPFRFloat],
284
+ function(filter,obj)
285
+ return MACFLOAT_MPFR(obj);
286
+ end);
287
+
288
+ InstallMethod(Rat, "float", [IsMPFRFloat],
289
+ function (x)
290
+ local M, a_i, i, sign, maxdenom, maxpartial, prec;
291
+
292
+ prec := PrecisionFloat(x);
293
+ x := NewFloat(IsMPFRFloat,x,prec+2);
294
+ i := 0; M := [[1,0],[0,1]];
295
+ maxdenom := ValueOption("maxdenom");
296
+ maxpartial := ValueOption("maxpartial");
297
+ if maxpartial=fail then maxpartial := 10000; fi;
298
+ if maxdenom=fail then maxdenom := 2^QuoInt(prec,2); fi;
299
+
300
+ if x < 0.0_r then sign := -1; x := -x; else sign := 1; fi;
301
+ repeat
302
+ a_i := Int(x);
303
+ if i >= 1 and a_i > maxpartial then break; fi;
304
+ M := M * [[a_i,1],[1,0]];
305
+ if x = Float(a_i) then break; fi;
306
+ x := 1.0_r / (x - a_i);
307
+ i := i+1;
308
+ until M[2][1] > maxdenom;
309
+ return sign * M[1][1]/M[2][1];
310
+ end);
311
+
312
+ INSTALLFLOATCREATOR("for cyc", [IsMPFRFloat,IsCyc], -2,
313
+ function(filter,obj)
314
+ local l, z;
315
+ if obj<>ComplexConjugate(obj) then
316
+ return fail;
317
+ fi;
318
+ l := ExtRepOfObj(obj);
319
+ z := 2.0_r*MPFR_PI(MPFRBITS@(filter))/Length(l);
320
+ return l*List([0..Length(l)-1],i->Cos(z*i));
321
+ end);
322
+
323
+ INSTALLFLOATCONSTRUCTORS(MPFR);
324
+ MPFR.constants.recompute(MPFR.constants,MPFR.constants.MANT_DIG);
325
+
326
+ #############################################################################
327
+ ##
328
+ #E