Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
why3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
119
Issues
119
List
Boards
Labels
Service Desk
Milestones
Merge Requests
16
Merge Requests
16
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Why3
why3
Commits
8c541b3c
Commit
8c541b3c
authored
Aug 20, 2019
by
MARCHE Claude
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
computing with real numbers: use binary128 floats by default
parent
65e37d3f
Changes
2
Hide whitespace changes
Inline
Sidebyside
Showing
2 changed files
with
15 additions
and
18 deletions
+15
18
bench/interp/real.mlw
bench/interp/real.mlw
+6
1
src/mlw/big_real.ml
src/mlw/big_real.ml
+9
17
No files found.
bench/interp/real.mlw
View file @
8c541b3c
...
...
@@ 6,6 +6,11 @@ module R
exception BenchFailure
let bench0 () =
let x : real = 1.0 / 3.0 in
(x, 3.0 * x)
let bench1 ()
(* Tries to calculate sqrt(2) *)
diverges
...
...
@@ 26,6 +31,6 @@ module R
use real.Trigonometry
let bench3 () =
sqrt (pi
)
(pi, sqrt (pi)
)
end
src/mlw/big_real.ml
View file @
8c541b3c
...
...
@@ 4,23 +4,16 @@ exception Undetermined
open
Mlmpfr_wrapper
type
real
=
mpfr_float
*
mpfr_float
(* computationally, a real is represented as an interval of two floatingpoint numbers.
such an interval `[a;b]` represents the set of real numbers between `a` and `b` *)
(* TODO in all the following getting to plus_infinity or to zero on both side of
the interval should always be seen as an error. The precision should be
increased in those cases.
For example, we cannot simplify multiplication of [0; 0] with ]+inf; +inf[
because both may mean that the underlying floats overflow/underflow and the
result can be far from the solutions we get. Example: divide a number by 10 a
lot and then multiply the result by 10 the same number of time + 1. You would
obtain 0 whereas you would like to obtain number * 10.
*)
(* TODO precision cannot be changed once launched the first time. So we need
to init it once. *)
let
init
,
set_exponents
,
get_prec
=
let
emin
=
ref
(

148
)
in
let
emax
=
ref
128
in
let
prec
=
ref
24
in
(*
By default, for approximating real numbers, let's use binary128 floats
*)
let
emin
=
ref
(

16493
)
in
let
emax
=
ref
16384
in
let
prec
=
ref
113
in
(
fun
emin_i
emax_i
prec_i
>
emin
:=
emin_i
;
emax
:=
emax_i
;
...
...
@@ 65,8 +58,7 @@ let mul (xmin, xmax) (ymin, ymax) =
let
inv
(
xmin
,
xmax
)
=
set_exponents
()
;
let
prec
=
get_prec
()
in
(* If 0 is inside the interval we cannot compute the expression. The precision
should be increased. *)
(* If 0 is inside the interval we cannot compute the expression *)
if
signbit
xmin
<>
signbit
xmax
then
raise
Undetermined
else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment