Skip to content

Commit 261e5fe

Browse files
Pack of tests and fixes (#65)
* run for ltr, release , nightly on all os * Pack of tests and trivial fixes * Introduce `Slong` for C-interface * CI: windows only on nightly (load packages fails) * CI: fixed bug in CompatHelper.yml * removed ambiguities and added test cases * fix `angle` * typo * simplifications and code coverage * tested ArbFloat * ARBReal tested - except string functions * fixed `radius * new ArbTypes.jl, rounding, tests * coverage * coverage `constructors.jl` --------- Co-authored-by: Jeffrey Sarnoff <[email protected]>
1 parent 27b1c8c commit 261e5fe

29 files changed

+925
-974
lines changed

.github/workflows/CI.yml

+10-4
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,20 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
version:
16-
- '1.8.4'
17-
# - 'nightly'
16+
- '1.6'
17+
- '1'
18+
- 'nightly'
1819
os:
1920
- ubuntu-latest
20-
# - macOS-latest
21-
# - windows-latest
21+
- macOS-latest
22+
- windows-latest
2223
arch:
2324
- x64
25+
exclude:
26+
- version: '1.6'
27+
os: windows-latest
28+
- version: '1'
29+
os: windows-latest
2430
steps:
2531
- uses: actions/checkout@v2
2632
- uses: julia-actions/setup-julia@v1

.github/workflows/CompatHelper.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: CompatHelper
33
on:
44
schedule:
5-
- chron 8 3 * * 1,3,5
5+
- cron: 8 3 * * 1,3,5
66
workflow_dispatch:
77
permissions:
88
contents: write

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
*.jl.*.cov
33
*.jl.mem
44
*.jl.*.mem
5+
lcov.info
6+
.vscode
57
Manifest.toml
68
settings.json
79
deps/deps.jl
10+
gen/
11+
src/clang/arblib_api.*

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repo = "https://github.com/JeffreySarnoff/ArbNumerics.jl.git"
44
keywords = ["math", "floating-point", "extended-precision", "accuracy", "precision"]
55
author = "Jeffrey Sarnoff"
66
license = "MIT"
7-
version = "v1.3.5"
7+
version = "v1.4"
88

99
[deps]
1010
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

README.md

+39-44
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#
2-
# ArbNumerics.jl
31

2+
# ArbNumerics.jl
43

54
#### Copyright © 2015-2024 by Jeffrey Sarnoff.
65
#### This work is released under The MIT License.
@@ -9,21 +8,18 @@ For multiprecision numerical computing using values with 25..2,500 digits. With
98

109
This package uses the [Arb C Library](http://arblib.org/index.html), and adapts some C library interface work from [Nemo](https://github.com/wbhart/Nemo.jl) (see [_below_](https://github.com/JeffreySarnoff/ArbNumerics.jl/blob/master/README.md#acknowledgements)). Here is a presentation by the designer and architect of the [Arb C library](https://fredrikj.net/math/oxford2019.pdf).
1110

12-
1311
-----
1412

1513
[![Travis Build Status](https://travis-ci.org/JeffreySarnoff/ArbNumerics.jl.svg?branch=master)](https://travis-ci.org/JeffreySarnoff/ArbNumerics.jl)&nbsp;&nbsp;&nbsp;[![Docs](https://img.shields.io/badge/docs-stable-blue.svg)](http://jeffreysarnoff.github.io/ArbNumerics.jl/stable/)&nbsp;&nbsp;&nbsp;[![Docs](https://img.shields.io/badge/docs-dev-blue.svg)](http://jeffreysarnoff.github.io/ArbNumerics.jl/dev/)
1614

17-
18-
----
15+
-----
1916

2017
## Introduction
2118

2219
ArbNumerics exports three types: `ArbFloat`, `ArbReal`, `ArbComplex`. `ArbFloat` is an extended precision floating point type. Math using `ArbFloat` is expected to be very near the veridical value, and often is the closest value for the precision in use. `ArbReal` is an interval-valued quantity formed of an `ArbFloat` (the midpoint) and a `radius`. Math functions with `ArbReal` are assured to enclose the veridical value. This assurance extends to multiple function applications. `ArbComplex` is an `ArbReal` pair (real, imaginary). The same enclosure assurance applies.
2320

2421
While the bounds of an `ArbReal` or `ArbComplex` are available, the default is to show these values as digit sequences which almost assuredly are accurate, in a round to nearest sense, to the precision displayed. Math with `ArbFloat` does not provide the assurance one gets using `ArbReal`, as an `ArbFloat` is a point value. While some effort has been taken to provide you with more reliable results from math with `ArbFloat` values than would be the case using the underlying library itself, `ArbReal` or `ArbComplex` are suggested for work that is important to you. `ArbFloat` is appropriate when exactness is not required during development, or with applications that are approximating something at increasing precisions.
2522

26-
2723
## Installation
2824

2925
```julia
@@ -38,7 +34,7 @@ When updating ArbNumerics, do `pkg> gc` to prevent accruing a great deal of unus
3834
## StartUp
3935

4036
`using ArbNumerics`
41-
or, if you installed Readables,
37+
or, if you installed Readables,
4238
`using ArbNumerics, Readables`
4339

4440
## Precision
@@ -49,23 +45,23 @@ Otherwise, some extra bits are used to assist with printing values rounded to th
4945

5046
You can set the internal working precision (which is the same as the displayed precision with `setextrabits(0)`) to a given number of bits or a given number of decimal digits:
5147

52-
`setworkingprecision(ArbFloat, bits=250)`, `setworkingprecision(ArbReal, digits=100)`
48+
`setworkingprecision(ArbFloat, bits=250)`, `setworkingprecision(ArbReal, digits=100)`
5349

5450
The type can be any of `ArbFloat`, `ArbReal`, `ArbComplex`. All types share the same precision so interconversion makes sense.
5551

5652
You can set the external displayed precision (which is the the same as the internal precision with `setextrabits(0)`) to a given
5753
number of bits or a given number of decimal digits:
5854

59-
`setprecision(ArbFloat, bits=250)`, `setworkingprecision(ArbReal, digits=100)`
55+
`setprecision(ArbFloat, bits=250)`, `setworkingprecision(ArbReal, digits=100)`
6056

6157
The type can be any of `ArbFloat`, `ArbReal`, `ArbComplex`. All types share the same precision so interconversion makes sense.
6258

63-
64-
## Using ArbFloat
59+
## Using ArbFloat
6560

6661
Reading the sections that follow gives you a good platform from which to develop.
6762

6863
- consider `using ArbNumerics, Readables`
64+
6965
```julia
7066
julia> ArbFloat(pi, digits=30, base=10)
7167
3.14159265358979323846264338328
@@ -82,7 +78,8 @@ Initially, the default precision is set to 106 bits. All ArbNumeric types use t
8278

8379
The precision in use may be set globally, as with BigFloats, or it may be given with the constructor. For most purposes, you should work with a type at one, two, or three precisions. It is helps clarity to convert precisions explicitly, however, it is not necessary.
8480

85-
#### Constructors using the default precision
81+
### Constructors using the default precision
82+
8683
```julia
8784
julia> a = ArbFloat(3)
8885
3.0000000000000000000000000000000
@@ -95,42 +92,39 @@ julia> c = one(ArbComplex)
9592
```
9693

9794
#### Constructors using a specified precision
95+
9896
```julia
9997
julia> BITS = 53;
10098

101-
julia> a = sqrt(ArbFloat(2, BITS))
99+
julia> a = sqrt(ArbFloat(2, bits=BITS))
102100
1.414213562373095
103101

104-
julia> b = ArbReal(pi, BITS)
102+
julia> b = ArbReal(pi, bits=BITS)
105103
3.141592653589793
106104

107-
julia> c = ArbComplex(a, b, BITS)
105+
julia> c = ArbComplex(a, b, bits=BITS)
108106
1.414213562373095 + 3.141592653589793im
109107
```
108+
110109
```julia
111110
julia> DIGITS = 78;
112111

113-
julia> ArbFloat(pi, bits4digits(DIGITS))
112+
julia> ArbFloat(pi, digits=DIGITS)
114113
3.14159265358979323846264338327950288419716939937510582097494459230781640628621
115114

116115
julia> DIGITS == length(string(ans)) - 1 # (-1 for the decimal point)
117116
true
118117
```
118+
119119
### changing precision
120120

121121
```julia
122-
julia> a = ArbFloat(2, 25)
122+
julia> a = ArbFloat(2, bits=25)
123123
2.000000
124-
julia> a = ArbFloat(a, 50)
125-
2.00000000000000
126-
127-
julia> precision = 25
128-
julia> a = ArbFloat(2, precision)
129-
2.000000
130-
julia> precision = 50
131-
julia> a = ArbFloat(a, precision)
124+
julia> a = ArbFloat(a, bits=50)
132125
2.00000000000000
133126
```
127+
134128
### interconversion
135129

136130
```julia
@@ -153,19 +147,19 @@ julia> Float16(c)
153147
Float16(1.414)
154148
```
155149

156-
----
150+
-----
157151

158152
Consider using ArbReals instead of ArbFloats if you want your results to be rock solid. That way you can examine the enclosures for your results with `radius(value)` or `bounds(value)`. This is strongly suggested when working with precisions that you are increasing dynamically.
159153

160-
----
154+
-----
161155

162156
### Math
163157

164158
#### arithmetic functions
165159

166160
- `+`,`-`, `*`, `/`
167161
- `square`, `cube`, `sqrt`, `cbrt`, `hypot`
168-
- `pow(x,i)`, `root(x,i)` _where i is an integer > 0_
162+
- `pow(x, i)`, `root(x, i)` _where i is an integer > 0_
169163
- `factorial`, `doublefactorial`, `risingfactorial`
170164
- `binomial`
171165

@@ -208,6 +202,7 @@ Consider using ArbReals instead of ArbFloats if you want your results to be rock
208202
- `elliptic_zeta`, `elliptic_sigma`
209203

210204
##### elliptic integrals of squared modulus
205+
211206
- `elliptic_e2`, `elliptic_k2`
212207
- `elliptic_p2`, `elliptic_pi2`
213208
- `elliptic_zeta2`, `elliptic_sigma2`
@@ -218,10 +213,10 @@ Consider using ArbReals instead of ArbFloats if you want your results to be rock
218213
- `weierstrass_zeta`, `weierstrass_sigma`
219214

220215
#### hypergeometric functions
221-
216+
222217
- `hypgeom0f1`, `hypgeom1f1`, `hypgeom1f2`
223218
- `hypgeom0f1reg`, `hypgeom1f1reg`, `hypgeom1f2reg` (regularized)
224-
219+
225220
#### other special functions
226221

227222
- `ei`, `si`, `ci`
@@ -241,13 +236,13 @@ Consider using ArbReals instead of ArbFloats if you want your results to be rock
241236
- `dft`, `inverse_dft`
242237
- see docs for use
243238

244-
## Intervals
239+
### Intervals
245240

246241
#### parts
247242

248-
- midpoint, radius
249-
- upperbound, lowerbound, bounds
250-
- upperbound_abs, lowerbound_abs, bounds_abs
243+
- `midpoint`, `radius`
244+
- `upperbound`, `lowerbound`, `bounds`
245+
- `upperbound_abs`, `lowerbound_abs`, `bounds_abs`
251246

252247
#### construction
253248

@@ -267,26 +262,26 @@ The radii are kept using an Arb C library internal structure that has a 30 bit u
267262
268263
When constructing intervals , you should scale the radius to be as small as possible while preserving enclosure.
269264

270-
----
265+
-----
271266

272267
### a caution for BigFloat
273268

274269
```julia
275-
julia> p=64;setprecision(BigFloat,p);
270+
julia> p = 64; setprecision(BigFloat, p);
276271

277-
julia> ArbFloat(pi,p+8)
272+
julia> ArbFloat(pi, bits=p+8)
278273
3.14159265358979323846
279274

280-
julia> ArbFloat(pi,p),BigFloat(pi)
275+
julia> ArbFloat(pi, bits=p), BigFloat(pi)
281276
(3.141592653589793238, 3.14159265358979323851)
282277

283-
julia> [ArbFloat(pi,p), BigFloat(pi)]
284-
2-element Array{ArbFloat{88},1}:
278+
julia> [ArbFloat(pi, bits=p), BigFloat(pi)]
279+
2-element Vector{ArbFloat{88}}:
285280
3.141592653589793238
286281
3.141592653589793239
287282
```
288283

289-
----
284+
-----
290285

291286
## The Arb C library
292287

@@ -300,18 +295,18 @@ julia> [ArbFloat(pi,p), BigFloat(pi)]
300295

301296
- The code is thread-safe, portable, and extensively tested. The library outperforms others.
302297

303-
304298
## Acknowledgements
305299

306300
This work develops parts the Arb C library within Julia. It is entirely dependent on Arb by Fredrik Johansson and would not exist without the good work of William Hart, Tommy Hofmann and the Nemo.jl team. The libraries for `Arb` and `Flint`, and build file are theirs, used with permission.
307301

308-
----
302+
-----
309303

310304
## Alternatives
311305

312306
For a numeric types like `Float64` and `ComplexF64` with about twice their precision, [Quadmath.jl](https://github.com/JuliaMath/Quadmath.jl) exports `Float128` and `ComplexF128`. For almost as much precision with better performance, [DoubleFloats.jl](https://github.com/JuliaMath/DoubleFloats.jl) exports `Double64` and `ComplexDF64`. ValidatedNumerics.jl and other packages available at [JuliaIntervals](https://github.com/JuliaIntervals) provide an alternative approach to developing correctly contained results. Those packages are very good and worthwhile when you do not require multiprecision numerics.
313307

314-
----
308+
-----
309+
315310
## notes
316311

317312
- To propose internal changes, please use pull requests.

src/ArbNumerics.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export ArbNumber,
3737

3838
inf, posinf, neginf, nan,
3939
typemax, typemin, floatmax, floatmin,
40-
magnitude, # complex magnitude, `angle` gives phase
40+
magnitude, csign, # complex magnitude, `angle` gives phase
4141

4242
signs, signbits,
4343
significand_bits, relerror_bits, relaccuracy_bits,
@@ -50,7 +50,7 @@ export ArbNumber,
5050
addmul, submul, mulsub,
5151
square, cube, rsqrt, rcbrt, pow, root, loghypot,
5252
risingfactorial, doublefactorial,
53-
tanpi, cotpi,
53+
tanpi, cotpi, swap!,
5454

5555
# special functions
5656
agm1, agm,
@@ -85,7 +85,7 @@ import Base: IEEEFloat,
8585
Float16, Float32, Float64, float,
8686
UInt8, UInt16, UInt32, UInt64, UInt128,
8787
Int8, Int16, Int32, Int64, Int128,
88-
BigInt, BigFloat, Rational, Complex, real, imag, complex,
88+
BigInt, BigFloat, Rational, Complex, real, imag, isreal, complex, angle,
8989
floatmax, floatmin, typemax, typemin, maxintfloat,
9090
rationalize,
9191

@@ -153,6 +153,8 @@ using Libdl
153153
using Random
154154
using Random: SamplerType, SamplerTrivial, CloseOpen01
155155

156+
include("ArbTypes.jl")
157+
156158
include("support/abstractions.jl")
157159
include("support/matrices.jl")
158160

@@ -169,8 +171,6 @@ include("support/ArblibVector.jl")
169171

170172
include("support/random.jl")
171173

172-
const ArbNumber = Union{ArbFloat, ArbReal, ArbComplex}
173-
174174
include("libarb/ArbMatrix.jl") # must preceed ArbRealMatrix
175175
include("libarb/ArbRealMatrix.jl") # must preceed ArbFloatMatrix
176176
include("libarb/ArbFloatMatrix.jl") # must preceed ArbComplexMatrix

0 commit comments

Comments
 (0)