mirror of
https://github.com/storytold/craft-libs.git
synced 2026-12-01 10:48:15 +01:00
Merge #647 (fix/linesweeper-sweep-doc-ratio-overflow) into integration/linesweeper
This commit is contained in:
commit
24b2d44641
3 files changed
+20
-5
No files matched your search
Vendored
+6
@@ -60,6 +60,9 @@ names, which is archived; its README says development moved off GitHub.
|
||||
`824b0791a750f7b27b8edcbb6c6244d0e629875e`. That commit is not in the GitHub repository the manifest
|
||||
names, which is archived; its README says development moved off GitHub.
|
||||
|
||||
`824b0791a750f7b27b8edcbb6c6244d0e629875e`. That commit is not in the GitHub repository the manifest
|
||||
names, which is archived; its README says development moved off GitHub.
|
||||
|
||||
Every file here except this one, `SOURCE.json` and the files under Local changes is byte for byte the
|
||||
file in the `.crate` archive. `SOURCE.json` records the hash of the `.crate` download
|
||||
(`source_archive_sha256`) and, for every file kept, the hash in the package (`source_sha256`) and the
|
||||
@@ -88,6 +91,9 @@ Every change here updates this table and `SOURCE.json` in the same commit.
|
||||
Every change here updates this table and `SOURCE.json` in the same commit. To take a new linesweeper
|
||||
release, unpack the crates.io package, carry these changes over, regenerate `SOURCE.json`, and run the
|
||||
tests below.
|
||||
| The floating-point ratio lemma assumes `fl(y_1 - y_0)` is finite and `y_0 < y_1`, and its proof bounds `fl(y_1 - y_0)` instead of `fl(y + y_0)`; the x-coordinate accuracy lemma takes `M` as a floating-point number and shows both assumptions hold | `Craft patch (ratio lemma)` | `docs/sweep.typ` | None (documentation only) |
|
||||
|
||||
Every change here updates this table and `SOURCE.json` in the same commit.
|
||||
|
||||
`omitted_files` lists the 43 files of the package left out here, with their hashes:
|
||||
|
||||
|
||||
Vendored
+2
@@ -21,6 +21,7 @@
|
||||
"In `src/position.rs`, `compute_positions` sets each output segment's `last_y` to the segment's start height before queuing it. It started at 0, so a segment starting at `y < 0` was skipped at its first queue entry and close segments there were not put in order: with `Correctness::ReallyCorrect`, two lenses 0.001 apart at `dy = 100` gave 48 corrected quadratics, and the same lenses at `dy = -100` gave 20 uncorrected cubics. `position::tests::correct_positions_at_negative_y` checks both heights."
|
||||
"`Segment::lower` and `Segment::upper` bound a horizontal line by both of its endpoints. In the package, `local_bbox` takes both x values from `at_y`, which returns the right end of a horizontal line, and `lower` returns the right end minus `eps`."
|
||||
"The `visualize_op` example draws its two input paths with `fill-rule=\"evenodd\"`. Its `binary_op` call uses `FillRule::EvenOdd`, and the SVG default fill rule is nonzero."
|
||||
"In `docs/sweep.typ`, the floating-point ratio lemma assumes `y_0 < y_1` and a finite `fl(y_1 - y_0)`, and its proof bounds `fl(y_1 - y_0)` where it wrote `fl(y + y_0)`. The ordering alone does not rule out overflow: with `y_0 = -1e308`, `y = 0` and `y_1 = 1e308` the computed ratio is 0. The x-coordinate accuracy lemma that uses it takes `M` as a floating-point number, and its proof shows both assumptions hold for a segment that is not horizontal."
|
||||
],
|
||||
"files": [
|
||||
{ "path": ".cargo_vcs_info.json", "source_sha256": "47fba6a9dbdf445a5c97f783c9be62093035f9d5e5cdc2cf3216ad8259bcd8fc", "source_git_blob": null, "sha256": "47fba6a9dbdf445a5c97f783c9be62093035f9d5e5cdc2cf3216ad8259bcd8fc" },
|
||||
@@ -36,6 +37,7 @@
|
||||
{ "path": "benches/painted_dreams.rs", "source_sha256": "073008db93840d380710e13ed3ae38e08cb823f10c12e5f838dac1ccf37eaecf", "source_git_blob": null, "sha256": "073008db93840d380710e13ed3ae38e08cb823f10c12e5f838dac1ccf37eaecf" },
|
||||
{ "path": "benches/synthetic.rs", "source_sha256": "7ce59bef2e1c4f28b00cb89feb15bc71ca4b098a8d27e7b02ea699aca9bcc810", "source_git_blob": null, "sha256": "7ce59bef2e1c4f28b00cb89feb15bc71ca4b098a8d27e7b02ea699aca9bcc810" },
|
||||
{ "path": "docs/sweep.typ", "source_sha256": "4766082c8672a7bb4356b5581043489c13b4e3fb8931ba3a5f0a473fab0172f3", "source_git_blob": null, "sha256": "571f227f4b43eaba8060c48344e26b639a4fea8787e5c63bd3f826836c5e4806" },
|
||||
{ "path": "docs/sweep.typ", "source_sha256": "4766082c8672a7bb4356b5581043489c13b4e3fb8931ba3a5f0a473fab0172f3", "source_git_blob": null, "sha256": "dac8d5c5d0d97d796824578a29ebbf5b23f79fba76a91f3dd8e6110db4e55821" },
|
||||
{ "path": "examples/boolean_op.rs", "source_sha256": "3b38a1ccda7e736cce4b191a3a45ab4824c4c365190e3eb637b2fb39b5996c9f", "source_git_blob": null, "sha256": "3b38a1ccda7e736cce4b191a3a45ab4824c4c365190e3eb637b2fb39b5996c9f" },
|
||||
{ "path": "docs/sweep.typ", "source_sha256": "4766082c8672a7bb4356b5581043489c13b4e3fb8931ba3a5f0a473fab0172f3", "source_git_blob": null, "sha256": "4766082c8672a7bb4356b5581043489c13b4e3fb8931ba3a5f0a473fab0172f3" },
|
||||
{ "path": "examples/boolean_op.rs", "source_sha256": "3b38a1ccda7e736cce4b191a3a45ab4824c4c365190e3eb637b2fb39b5996c9f", "source_git_blob": null, "sha256": "7b4f4fc94d3b1fd9b9ee06622b2e8c38bd6c85697d21505b09765139283df576" },
|
||||
|
||||
Vendored
+12
-5
@@ -640,18 +640,23 @@ Now, if the result of floating point addition or subtraction is subnormal then i
|
||||
for any floating-point $x$ and $y$, if $x - y$ and $x + y$ don't overflow then after rounding they
|
||||
have relative error at most $epsilon_0$.
|
||||
|
||||
// Craft patch (ratio lemma): the finite, nonzero denominator assumption and fl(y_1 - y_0) in the proof.
|
||||
#lemma[
|
||||
If $y_0 <= y <= y_1$ are floating-point numbers and $epsilon_0 <= 1/2$ then computing $(y - y_0) / (y_1 - y_0)$
|
||||
If $y_0 <= y <= y_1$ are floating-point numbers with $y_0 < y_1$, $fl(y_1 - y_0)$ is finite
|
||||
and $epsilon_0 <= 1/2$ then computing $(y - y_0) / (y_1 - y_0)$
|
||||
the naive way gives an absolute error of
|
||||
at most $3 epsilon_0 + 4 epsilon_0^2$.
|
||||
]<lem-ratio-error>
|
||||
|
||||
#proof[
|
||||
The assumption $y_0 <= y <= y_1$ ensures that $y - y_0$ and $y_1 - y_0$ do not overflow. Therefore
|
||||
The assumption that $fl(y_1 - y_0)$ is finite ensures that $y_1 - y_0$ does not overflow, and since
|
||||
$0 <= y - y_0 <= y_1 - y_0$, neither does $y - y_0$. (The ordering $y_0 <= y <= y_1$ alone is not
|
||||
enough: with $y_0 = -10^308$, $y = 0$ and $y_1 = 10^308$, $fl(y_1 - y_0)$ is infinite and the computed
|
||||
ratio is $0$ instead of $1/2$.) Therefore
|
||||
|
||||
$
|
||||
fl(y - y_0) &= (y - y_0) (1 plus.minus epsilon_0) \
|
||||
fl(y + y_0) &= (y + y_0) (1 plus.minus epsilon_0)
|
||||
fl(y_1 - y_0) &= (y_1 - y_0) (1 plus.minus epsilon_0)
|
||||
$
|
||||
and so
|
||||
$
|
||||
@@ -794,8 +799,9 @@ the maximum of these inverse-slopes.
|
||||
]
|
||||
|
||||
Putting all this together (and handling the "chamfers" yet):
|
||||
// Craft patch (ratio lemma): M is a floating-point number, and the proof shows the ratio lemma's assumptions hold.
|
||||
#lemma[
|
||||
Assume all line segments are inside the square $[-M/2, M/2]^2$,
|
||||
Assume $M$ is a floating-point number, all line segments are inside the square $[-M/2, M/2]^2$,
|
||||
and take $delta = 64 epsilon_0 M$. If $epsilon_0 <= 1/4$ then
|
||||
|
||||
- We can compute $x$ coordinates of line segments to additive accuracy $delta/8$.
|
||||
@@ -808,7 +814,8 @@ and take $delta = 64 epsilon_0 M$. If $epsilon_0 <= 1/4$ then
|
||||
|
||||
#proof[
|
||||
We compute $x$ coordinates by first computing $t = (y - y_0) / (y_1 - y_0)$ (with error at most $3 epsilon_0 + 4 epsilon_0^2$ by
|
||||
@lem-ratio-error). Then we apply @lem-convex-combination-error with $epsilon = 3 epsilon_0 + 4 epsilon_0^2$ to see that we
|
||||
@lem-ratio-error, which applies because a segment that is not horizontal has $y_0 < y_1$, and $fl(y_1 - y_0)$
|
||||
is finite because $0 < y_1 - y_0 <= M$ and $M$ is a floating-point number). Then we apply @lem-convex-combination-error with $epsilon = 3 epsilon_0 + 4 epsilon_0^2$ to see that we
|
||||
can compute the horizontal coordinate with error at most $(6 epsilon_0 + 4 epsilon_0^2)M$. If $epsilon_0 <= 1/4$ as we assumed,
|
||||
this is at most $7 epsilon_0 M <= delta/8$. This proves the first claim.
|
||||
|
||||
|
||||
Reference in new issue
Block a user