Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pack of tests and fixes #65

Merged
merged 16 commits into from
Feb 9, 2024
Merged
14 changes: 10 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@ jobs:
fail-fast: false
matrix:
version:
- '1.8.4'
# - 'nightly'
- '1.6'
- '1'
- 'nightly'
os:
- ubuntu-latest
# - macOS-latest
# - windows-latest
- macOS-latest
- windows-latest
arch:
- x64
exclude:
- version: '1.6'
os: windows-latest
- version: '1'
os: windows-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: CompatHelper
on:
schedule:
- chron 8 3 * * 1,3,5
- cron: 8 3 * * 1,3,5
workflow_dispatch:
permissions:
contents: write
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
*.jl.*.cov
*.jl.mem
*.jl.*.mem
lcov.info
.vscode
Manifest.toml
settings.json
deps/deps.jl
gen/
src/clang/arblib_api.*
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repo = "https://github.com/JeffreySarnoff/ArbNumerics.jl.git"
keywords = ["math", "floating-point", "extended-precision", "accuracy", "precision"]
author = "Jeffrey Sarnoff"
license = "MIT"
version = "v1.3.5"
version = "v1.4"

[deps]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand Down
83 changes: 39 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#
# ArbNumerics.jl

# ArbNumerics.jl

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

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).


-----

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


----
-----

## Introduction

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.

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.


## Installation

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

`using ArbNumerics`
or, if you installed Readables,
or, if you installed Readables,
`using ArbNumerics, Readables`

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

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:

`setworkingprecision(ArbFloat, bits=250)`, `setworkingprecision(ArbReal, digits=100)`
`setworkingprecision(ArbFloat, bits=250)`, `setworkingprecision(ArbReal, digits=100)`

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

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

`setprecision(ArbFloat, bits=250)`, `setworkingprecision(ArbReal, digits=100)`
`setprecision(ArbFloat, bits=250)`, `setworkingprecision(ArbReal, digits=100)`

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


## Using ArbFloat
## Using ArbFloat

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

- consider `using ArbNumerics, Readables`

```julia
julia> ArbFloat(pi, digits=30, base=10)
3.14159265358979323846264338328
Expand All @@ -82,7 +78,8 @@ Initially, the default precision is set to 106 bits. All ArbNumeric types use t

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.

#### Constructors using the default precision
### Constructors using the default precision

```julia
julia> a = ArbFloat(3)
3.0000000000000000000000000000000
Expand All @@ -95,42 +92,39 @@ julia> c = one(ArbComplex)
```

#### Constructors using a specified precision

```julia
julia> BITS = 53;

julia> a = sqrt(ArbFloat(2, BITS))
julia> a = sqrt(ArbFloat(2, bits=BITS))
1.414213562373095

julia> b = ArbReal(pi, BITS)
julia> b = ArbReal(pi, bits=BITS)
3.141592653589793

julia> c = ArbComplex(a, b, BITS)
julia> c = ArbComplex(a, b, bits=BITS)
1.414213562373095 + 3.141592653589793im
```

```julia
julia> DIGITS = 78;

julia> ArbFloat(pi, bits4digits(DIGITS))
julia> ArbFloat(pi, digits=DIGITS)
3.14159265358979323846264338327950288419716939937510582097494459230781640628621

julia> DIGITS == length(string(ans)) - 1 # (-1 for the decimal point)
true
```

### changing precision

```julia
julia> a = ArbFloat(2, 25)
julia> a = ArbFloat(2, bits=25)
2.000000
julia> a = ArbFloat(a, 50)
2.00000000000000

julia> precision = 25
julia> a = ArbFloat(2, precision)
2.000000
julia> precision = 50
julia> a = ArbFloat(a, precision)
julia> a = ArbFloat(a, bits=50)
2.00000000000000
```

### interconversion

```julia
Expand All @@ -153,19 +147,19 @@ julia> Float16(c)
Float16(1.414)
```

----
-----

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.

----
-----

### Math

#### arithmetic functions

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

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

##### elliptic integrals of squared modulus

- `elliptic_e2`, `elliptic_k2`
- `elliptic_p2`, `elliptic_pi2`
- `elliptic_zeta2`, `elliptic_sigma2`
Expand All @@ -218,10 +213,10 @@ Consider using ArbReals instead of ArbFloats if you want your results to be rock
- `weierstrass_zeta`, `weierstrass_sigma`

#### hypergeometric functions

- `hypgeom0f1`, `hypgeom1f1`, `hypgeom1f2`
- `hypgeom0f1reg`, `hypgeom1f1reg`, `hypgeom1f2reg` (regularized)

#### other special functions

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

## Intervals
### Intervals

#### parts

- midpoint, radius
- upperbound, lowerbound, bounds
- upperbound_abs, lowerbound_abs, bounds_abs
- `midpoint`, `radius`
- `upperbound`, `lowerbound`, `bounds`
- `upperbound_abs`, `lowerbound_abs`, `bounds_abs`

#### construction

Expand All @@ -267,26 +262,26 @@ The radii are kept using an Arb C library internal structure that has a 30 bit u

When constructing intervals , you should scale the radius to be as small as possible while preserving enclosure.

----
-----

### a caution for BigFloat

```julia
julia> p=64;setprecision(BigFloat,p);
julia> p = 64; setprecision(BigFloat, p);

julia> ArbFloat(pi,p+8)
julia> ArbFloat(pi, bits=p+8)
3.14159265358979323846

julia> ArbFloat(pi,p),BigFloat(pi)
julia> ArbFloat(pi, bits=p), BigFloat(pi)
(3.141592653589793238, 3.14159265358979323851)

julia> [ArbFloat(pi,p), BigFloat(pi)]
2-element Array{ArbFloat{88},1}:
julia> [ArbFloat(pi, bits=p), BigFloat(pi)]
2-element Vector{ArbFloat{88}}:
3.141592653589793238
3.141592653589793239
```

----
-----

## The Arb C library

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

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


## Acknowledgements

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.

----
-----

## Alternatives

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.

----
-----

## notes

- To propose internal changes, please use pull requests.
Expand Down
10 changes: 5 additions & 5 deletions src/ArbNumerics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export ArbNumber,

inf, posinf, neginf, nan,
typemax, typemin, floatmax, floatmin,
magnitude, # complex magnitude, `angle` gives phase
magnitude, csign, # complex magnitude, `angle` gives phase

signs, signbits,
significand_bits, relerror_bits, relaccuracy_bits,
Expand All @@ -50,7 +50,7 @@ export ArbNumber,
addmul, submul, mulsub,
square, cube, rsqrt, rcbrt, pow, root, loghypot,
risingfactorial, doublefactorial,
tanpi, cotpi,
tanpi, cotpi, swap!,

# special functions
agm1, agm,
Expand Down Expand Up @@ -85,7 +85,7 @@ import Base: IEEEFloat,
Float16, Float32, Float64, float,
UInt8, UInt16, UInt32, UInt64, UInt128,
Int8, Int16, Int32, Int64, Int128,
BigInt, BigFloat, Rational, Complex, real, imag, complex,
BigInt, BigFloat, Rational, Complex, real, imag, isreal, complex, angle,
floatmax, floatmin, typemax, typemin, maxintfloat,
rationalize,

Expand Down Expand Up @@ -153,6 +153,8 @@ using Libdl
using Random
using Random: SamplerType, SamplerTrivial, CloseOpen01

include("ArbTypes.jl")

include("support/abstractions.jl")
include("support/matrices.jl")

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

include("support/random.jl")

const ArbNumber = Union{ArbFloat, ArbReal, ArbComplex}

include("libarb/ArbMatrix.jl") # must preceed ArbRealMatrix
include("libarb/ArbRealMatrix.jl") # must preceed ArbFloatMatrix
include("libarb/ArbFloatMatrix.jl") # must preceed ArbComplexMatrix
Expand Down
Loading
Loading