Skip to content

Commit 4e559ef

Browse files
authored
Merge pull request #28 from jlapeyre/fix-lambda
Define LAMBDA in only one place Add comments referencing paper. Closes #12
2 parents ecf01c5 + d275a67 commit 4e559ef

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

src/odgp.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@
44
use crate::common::ib_to_bf_prec;
55
use crate::math::{floorlog, pow_sqrt2, sqrt2};
66
use crate::region::Interval;
7+
use crate::ring::z_root_two::LAMBDA;
78
use crate::ring::{DRootTwo, ZRootTwo};
89
use dashu_float::round::mode::HalfEven;
910
use dashu_float::FBig;
1011
use dashu_int::IBig;
1112
use std::iter;
1213

13-
const LAMBDA: ZRootTwo = ZRootTwo {
14-
a: IBig::ONE,
15-
b: IBig::ONE,
16-
};
17-
1814
pub fn solve_odgp(i: Interval, j: Interval) -> impl Iterator<Item = ZRootTwo> {
1915
// Can't return two different iterator types. So we can't do this check.
2016
// I checked with dbg! to confirm that omitting this check is ok:

src/ring/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
mod d_omega;
55
mod d_root_two;
66
mod z_omega;
7-
mod z_root_two;
7+
pub mod z_root_two;
88

99
pub use d_omega::DOmega;
1010
pub use d_root_two::DRootTwo;

src/ring/z_root_two.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ pub struct ZRootTwo {
1818
pub(crate) b: IBig,
1919
}
2020

21+
// See Definition 3.5 on pg 3 of R+S for the definition of lambda (and delta)
22+
// Careful! There is a different, unrelated defintion of lambda in
23+
// the discussion in Definition 9.1 on page 19 of R+S. It is in fact
24+
// the fixed phase factor used in the up-to-phase algorithm.
25+
pub const LAMBDA: ZRootTwo = ZRootTwo {
26+
a: IBig::ONE,
27+
b: IBig::ONE,
28+
};
29+
2130
impl ZRootTwo {
2231
pub fn new(a: IBig, b: IBig) -> Self {
2332
Self { a, b }

src/to_upright.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@ use crate::common::ib_to_bf_prec;
88
use crate::grid_op::{EllipsePair, GridOp};
99
use crate::math::{floorsqrt, log};
1010
use crate::region::{Ellipse, Rectangle};
11-
use crate::ring::{ZOmega, ZRootTwo};
11+
use crate::ring::z_root_two::LAMBDA;
12+
use crate::ring::ZOmega;
1213
use crate::tdgp::Region;
1314
use dashu_int::IBig;
1415
use num_traits::Pow;
15-
const LAMBDA: ZRootTwo = ZRootTwo {
16-
a: IBig::ONE,
17-
b: IBig::ONE,
18-
};
1916

2017
fn reduction(
2118
ellipse_pair: EllipsePair,

0 commit comments

Comments
 (0)