@@ -60,15 +60,85 @@ cdef class FlintContext:
60
60
flint_set_num_threads(num)
61
61
62
62
def extraprec (self , n ):
63
+ """
64
+ Adds n bits of precision to the current flint context.
65
+
66
+ >>> from flint import arb, ctx
67
+ >>> with ctx.extraprec(5): x = arb(2).sqrt().str()
68
+ >>> x
69
+ '[1.414213562373095 +/- 5.53e-17]'
70
+
71
+ This function also works as a wrapper:
72
+
73
+ >>> from flint import arb, ctx
74
+ >>> @ctx.extraprec(10)
75
+ ... def f(x):
76
+ ... return x.sqrt().str()
77
+ >>> f(arb(2))
78
+ '[1.41421356237309505 +/- 1.46e-18]'
79
+ """
63
80
return self .workprec(n + self .prec)
64
81
65
82
def extradps (self , n ):
83
+ """
84
+ Adds n digits of precision to the current flint context.
85
+
86
+ >>> from flint import arb, ctx
87
+ >>> with ctx.extradps(5): x = arb(2).sqrt().str()
88
+ >>> x
89
+ '[1.4142135623730950488 +/- 2.76e-21]'
90
+
91
+ This function also works as a wrapper:
92
+
93
+ >>> from flint import arb, ctx
94
+ >>> @ctx.extradps(10)
95
+ ... def f(x):
96
+ ... return x.sqrt().str()
97
+ >>> f(arb(2))
98
+ '[1.414213562373095048801689 +/- 3.13e-25]'
99
+ """
66
100
return self .workdps(n + self .dps)
67
101
68
102
def workprec (self , n ):
103
+ """
104
+ Sets the working precision for the current flint context,
105
+ using a python context manager.
106
+
107
+ >>> from flint import arb, ctx
108
+ >>> with ctx.workprec(5): x = arb(2).sqrt().str()
109
+ >>> x
110
+ '[1e+0 +/- 0.438]'
111
+
112
+ This function also works as a wrapper:
113
+
114
+ >>> from flint import arb, ctx
115
+ >>> @ctx.workprec(24)
116
+ ... def f(x):
117
+ ... return x.sqrt().str()
118
+ >>> f(arb(2))
119
+ '[1.41421 +/- 3.66e-6]'
120
+ """
69
121
return PrecisionManager(self , eprec = n)
70
122
71
123
def workdps (self , n ):
124
+ """
125
+ Sets the working precision in digits for the current
126
+ flint context, using a python context manager.
127
+
128
+ >>> from flint import arb, ctx
129
+ >>> with ctx.workdps(5): x = arb(2).sqrt().str()
130
+ >>> x
131
+ '[1.4142 +/- 1.51e-5]'
132
+
133
+ This function also works as a wrapper:
134
+
135
+ >>> from flint import arb, ctx
136
+ >>> @ctx.workdps(10)
137
+ ... def f(x):
138
+ ... return x.sqrt().str()
139
+ >>> f(arb(2))
140
+ '[1.414213562 +/- 3.85e-10]'
141
+ """
72
142
return PrecisionManager(self , edps = n)
73
143
74
144
def __repr__ (self ):
0 commit comments