diff --git a/benches/bench.rs b/benches/bench.rs index 838ab4d..afd7e1c 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -10,19 +10,13 @@ fn pow2_benchmarks(group: &mut BenchmarkGroup, x_f64: &[f64], x_f32: & b.iter(|| x_f64.iter().map(|&x| black_box(x).fast_pow2()).collect::>()) }); group.bench_function("f64_builtin_fn", |b| { - b.iter(|| x_f64.iter().map(|&x| black_box(x).powi(2)).collect::>()) - }); - group.bench_function("f64_builtin_mul", |b| { - b.iter(|| x_f64.iter().map(|&x| black_box(x) * x).collect::>()) + b.iter(|| x_f64.iter().map(|&x| 2.0f64.powf(black_box(x))).collect::>()) }); group.bench_function("f32_fast", |b| { b.iter(|| x_f32.iter().map(|&x| black_box(x).fast_pow2()).collect::>()) }); group.bench_function("f32_builtin_fn", |b| { - b.iter(|| x_f32.iter().map(|&x| black_box(x).powi(2)).collect::>()) - }); - group.bench_function("f32_builtin_mul", |b| { - b.iter(|| x_f32.iter().map(|&x| black_box(x) * x).collect::>()) + b.iter(|| x_f32.iter().map(|&x| 2.0f32.powf(black_box(x))).collect::>()) }); } diff --git a/build.rs b/build.rs index f76240b..5c9a350 100644 --- a/build.rs +++ b/build.rs @@ -1,42 +1,137 @@ // build.rs mod precalculate_lookup_tables { + use std::f32::consts as f32_consts; + use std::f64::consts as f64_consts; use std::fs::{create_dir_all, File}; use std::io::Write; - include!("src/lookup/lookup_table.rs"); - use bincode::serialize; + include!("src/lookup/config.rs"); + // use bincode::serialize; - const PRECISION: usize = 1000; + // fn precalculate_sin_tables() -> Result<(), Box> { + // let data = serialize(&EndoSinLookupTable::::new(PRECISION))?; + // let mut file = File::create("src/lookup/data/sin_f32.bin")?; + // file.write_all(&data)?; - fn precalculate_sin_tables() -> Result<(), Box> { - let data = serialize(&EndoSinLookupTable::::new(PRECISION))?; - let mut file = File::create("src/lookup/data/sin_f32.bin")?; - file.write_all(&data)?; + // let data = serialize(&EndoSinLookupTable::::new(PRECISION))?; + // let mut file = File::create("src/lookup/data/sin_f64.bin")?; + // file.write_all(&data)?; - let data = serialize(&EndoSinLookupTable::::new(PRECISION))?; - let mut file = File::create("src/lookup/data/sin_f64.bin")?; - file.write_all(&data)?; + // Ok(()) + // } - Ok(()) + // fn precalculate_cos_tables() -> Result<(), Box> { + // let data = serialize(&EndoCosLookupTable::::new(PRECISION))?; + // let mut file = File::create("src/lookup/data/cos_f32.bin")?; + // file.write_all(&data)?; + + // let data = serialize(&EndoCosLookupTable::::new(PRECISION))?; + // let mut file = File::create("src/lookup/data/cos_f64.bin")?; + // file.write_all(&data)?; + + // Ok(()) + // } + + // fn precalculate_sin_tables() -> Result<(), Box> { + // let step: f32 = f32_consts::FRAC_PI_2 / TABLE_SIZE as f32; + // let half_step: f32 = step / 2.0; + + // let keys: [f32; TABLE_SIZE] = (0..TABLE_SIZE).map(|i| { + // (step * (i as f32)) - half_step + // }).collect::>().try_into().unwrap_or([0.0f32; TABLE_SIZE]); + // let values: [f32; TABLE_SIZE] = (0..TABLE_SIZE).map(|i| { + // (step * (i as f32)).sin() + // }).collect::>().try_into().unwrap_or([0.0f32; TABLE_SIZE]); + // let data = format!("pub const KEYS: [f32; {}] = {:?};\npub const VALUES: [f32; {}] = {:?};\n", TABLE_SIZE, keys, TABLE_SIZE, values); + + // let mut file = File::create("src/lookup/data/sin_f32.rs")?; + // file.write_all(data.as_bytes())?; + + // let step: f64 = f64_consts::FRAC_PI_2 / TABLE_SIZE as f64; + // let half_step: f64 = step / 2.0; + + // let keys: [f64; TABLE_SIZE] = (0..TABLE_SIZE).map(|i| { + // (step * (i as f64)) - half_step + // }).collect::>().try_into().unwrap_or([0.0f64; TABLE_SIZE]); + // let values: [f64; TABLE_SIZE] = (0..TABLE_SIZE).map(|i| { + // (step * (i as f64)).sin() + // }).collect::>().try_into().unwrap_or([0.0f64; TABLE_SIZE]); + // let data = format!("pub const KEYS: [f64; {}] = {:?};\npub const VALUES: [f64; {}] = {:?};\n", TABLE_SIZE, keys, TABLE_SIZE, values); + + // let mut file = File::create("src/lookup/data/sin_f64.rs")?; + // file.write_all(data.as_bytes())?; + + // Ok(()) + // } + + macro_rules! precalculate_sin_tables { + () => {{ + let step: f32 = f32_consts::FRAC_PI_2 / TABLE_SIZE as f32; + let half_step: f32 = step / 2.0; + + let keys: [f32; TABLE_SIZE] = (0..TABLE_SIZE).map(|i| { + (step * (i as f32)) - half_step + }).collect::>().try_into().unwrap_or([0.0f32; TABLE_SIZE]); + let values: [f32; TABLE_SIZE] = (0..TABLE_SIZE).map(|i| { + (step * (i as f32)).sin() + }).collect::>().try_into().unwrap_or([0.0f32; TABLE_SIZE]); + let data = format!("pub const SIN_F32_KEYS: [f32; {}] = {:?};\npub const SIN_F32_VALUES: [f32; {}] = {:?};\n", TABLE_SIZE, keys, TABLE_SIZE, values); + + let mut file = File::create("src/lookup/data/sin_f32.rs").expect("Failed to create sin_f32.rs"); + file.write_all(data.as_bytes()).expect("Failed to write sin_f32.rs"); + + let step: f64 = f64_consts::FRAC_PI_2 / TABLE_SIZE as f64; + let half_step: f64 = step / 2.0; + + let keys: [f64; TABLE_SIZE] = (0..TABLE_SIZE).map(|i| { + (step * (i as f64)) - half_step + }).collect::>().try_into().unwrap_or([0.0f64; TABLE_SIZE]); + let values: [f64; TABLE_SIZE] = (0..TABLE_SIZE).map(|i| { + (step * (i as f64)).sin() + }).collect::>().try_into().unwrap_or([0.0f64; TABLE_SIZE]); + let data = format!("pub const SIN_F64_KEYS: [f64; {}] = {:?};\npub const SIN_F64_VALUES: [f64; {}] = {:?};\n", TABLE_SIZE, keys, TABLE_SIZE, values); + + let mut file = File::create("src/lookup/data/sin_f64.rs").expect("Failed to create sin_f64.rs"); + file.write_all(data.as_bytes()).expect("Failed to write sin_f64.rs"); + }}; } + // fn precalculate_sin_tables() -> Result<(), Box> { + // let step: f32 = f32_consts::FRAC_PI_2 / TABLE_SIZE as f32; + // let half_step: f32 = step / 2.0; - fn precalculate_cos_tables() -> Result<(), Box> { - let data = serialize(&EndoCosLookupTable::::new(PRECISION))?; - let mut file = File::create("src/lookup/data/cos_f32.bin")?; - file.write_all(&data)?; + // let keys: [f32; TABLE_SIZE] = (0..TABLE_SIZE).map(|i| { + // (step * (i as f32)) - half_step + // }).collect::>().try_into().unwrap_or([0.0f32; TABLE_SIZE]); + // let values: [f32; TABLE_SIZE] = (0..TABLE_SIZE).map(|i| { + // (step * (i as f32)).sin() + // }).collect::>().try_into().unwrap_or([0.0f32; TABLE_SIZE]); + // let data = format!("pub const KEYS: [f32; {}] = {:?};\npub const VALUES: [f32; {}] = {:?};\n", TABLE_SIZE, keys, TABLE_SIZE, values); - let data = serialize(&EndoCosLookupTable::::new(PRECISION))?; - let mut file = File::create("src/lookup/data/cos_f64.bin")?; - file.write_all(&data)?; + // let mut file = File::create("src/lookup/data/sin_f32.rs")?; + // file.write_all(data.as_bytes())?; - Ok(()) - } + // let step: f64 = f64_consts::FRAC_PI_2 / TABLE_SIZE as f64; + // let half_step: f64 = step / 2.0; + + // let keys: [f64; TABLE_SIZE] = (0..TABLE_SIZE).map(|i| { + // (step * (i as f64)) - half_step + // }).collect::>().try_into().unwrap_or([0.0f64; TABLE_SIZE]); + // let values: [f64; TABLE_SIZE] = (0..TABLE_SIZE).map(|i| { + // (step * (i as f64)).sin() + // }).collect::>().try_into().unwrap_or([0.0f64; TABLE_SIZE]); + // let data = format!("pub const KEYS: [f64; {}] = {:?};\npub const VALUES: [f64; {}] = {:?};\n", TABLE_SIZE, keys, TABLE_SIZE, values); + + // let mut file = File::create("src/lookup/data/sin_f64.rs")?; + // file.write_all(data.as_bytes())?; + + // Ok(()) + // } pub fn generate() -> Result<(), Box> { create_dir_all("src/lookup/data")?; - precalculate_sin_tables()?; - precalculate_cos_tables()?; + precalculate_sin_tables!(); + // precalculate_cos_tables()?; Ok(()) } diff --git a/src/fastmath.rs b/src/fastmath.rs index 64b79ac..2c7e14d 100644 --- a/src/fastmath.rs +++ b/src/fastmath.rs @@ -4,12 +4,19 @@ use std::f32::consts as f32_consts; use std::f64::consts as f64_consts; -use crate::lookup::*; +// use crate::lookup::*; +use crate::lookup::lookup_table::EndoCosLookupTable; -pub trait FastMath: FastCos + FastPow2 + FastExp + FastSigmoid {} +const COS_LOOKUP_F32: EndoCosLookupTable = EndoCosLookupTable::::new(); +const COS_LOOKUP_F64: EndoCosLookupTable = EndoCosLookupTable::::new(); + +pub trait FastMath: FastCos + FastExp + FastSigmoid {} impl FastMath for f32 {} impl FastMath for f64 {} +const V_SCALE_F32: f32 = 8388608.0; // the largest possible mantissa of an f32 +const V_SCALE_F64: f64 = 4503599627370496.0; // the largest possible mantissa of an f64 + pub trait LookupCos { fn lookup_cos(self: Self) -> Self; @@ -35,93 +42,66 @@ pub trait FastCos { impl FastCos for f32 { #[inline] fn fast_cos(self: Self) -> f32 { - const BITAND: u32 = u32::MAX / 2; const ONE: f32 = 1.0; - let mod_x = (((self + f32_consts::PI).abs()) % f32_consts::TAU) - f32_consts::PI; - let v = mod_x.to_bits() & BITAND; - let qpprox = ONE - f32_consts::FRAC_2_PI * f32::from_bits(v); + let v = ((((self + f32_consts::PI).abs()) % f32_consts::TAU) - f32_consts::PI).abs(); + let qpprox = ONE - f32_consts::FRAC_2_PI * v; qpprox + f32_consts::FRAC_PI_6 * qpprox * (ONE - qpprox * qpprox) } } impl FastCos for f64 { #[inline] fn fast_cos(self: Self) -> f64 { - const BITAND: u64 = u64::MAX / 2; const ONE: f64 = 1.0; - let mod_x = (((self + f64_consts::PI).abs()) % f64_consts::TAU) - f64_consts::PI; - let v = mod_x.to_bits() & BITAND; - let qpprox = ONE - f64_consts::FRAC_2_PI * f64::from_bits(v); + let v = ((((self + f64_consts::PI).abs()) % f64_consts::TAU) - f64_consts::PI).abs(); + let qpprox = ONE - f64_consts::FRAC_2_PI * v; qpprox + f64_consts::FRAC_PI_6 * qpprox * (ONE - qpprox * qpprox) } } -pub trait FastPow2 { - fn fast_pow2(self: Self) -> Self; -} -impl FastPow2 for f32 { - #[inline] - fn fast_pow2(self: Self) -> f32 { - // Khinchins constant over 3. IDK why it gives the best fit, but it does - const KHINCHIN_3: f32 = 2.68545200106530644530971483548179569382038229399446295305115234555721885953715200280114117493184769799515 / 3.0; - const CLIPP_THRESH: f32 = 0.12847338; - const V_SCALE: f32 = 8388608.0; // (1_i32 << 23) as f32 - const CLIPP_SHIFT: f32 = 126.67740855; - let abs_p = self.abs(); - let clipp = abs_p.max(CLIPP_THRESH); // if abs_p < CLIPP_THRESH { CLIPP_THRESH } else { abs_p }; - let v = (V_SCALE * (clipp + CLIPP_SHIFT)) as u32; - f32::from_bits(v) - KHINCHIN_3 - } -} -impl FastPow2 for f64 { - #[inline] - fn fast_pow2(self: Self) -> f64 { - const KHINCHIN_3: f64 = 2.68545200106530644530971483548179569382038229399446295305115234555721885953715200280114117493184769799515 / 3.0; - const CLIPP_THRESH: f64 = -45774.9247660416; - const V_SCALE: f64 = 4503599627370496.0; // (1i64 << 52) as f64 - const CLIPP_SHIFT: f64 = 1022.6769200000002; - const ZERO: f64 = 0.; - let abs_p = self.abs(); - let clipp = abs_p.max(CLIPP_THRESH); // if abs_p < CLIPP_THRESH { CLIPP_THRESH } else { abs_p }; - let v = (V_SCALE * (clipp + CLIPP_SHIFT)) as u64; - let y = f64::from_bits(v) - KHINCHIN_3; - if y.is_sign_positive() { - y - } else { - ZERO - } - } -} - pub trait FastExp { fn fast_exp(self: Self) -> Self; } impl FastExp for f32 { #[inline] fn fast_exp(self: Self) -> f32 { - const CLIPP_THRESH: f32 = -126.0; // 0.12847338; - const V_SCALE: f32 = 8388608.0; // (1_i32 << 23) as f32 - const CLIPP_SHIFT: f32 = 126.94269504; // 126.67740855; + const CLIPP_THRESH: f32 = -126.0; // exponent of smallest possible f32 to prevent underflow + const CLIPP_SHIFT: f32 = 126.94269504; // shift to align curve, found by regression let scaled_p = f32_consts::LOG2_E * self; - let clipp = scaled_p.max(CLIPP_THRESH); // if scaled_p < CLIPP_THRESH { CLIPP_THRESH } else { scaled_p }; - let v = (V_SCALE * (clipp + CLIPP_SHIFT)) as u32; + let clipp = scaled_p.max(CLIPP_THRESH); + let v = (V_SCALE_F32 * (clipp + CLIPP_SHIFT)) as u32; f32::from_bits(v) } } impl FastExp for f64 { #[inline] fn fast_exp(self: Self) -> f64 { - const CLIPP_THRESH: f64 = -180335.51911105003; - const V_SCALE: f64 = 4524653012949098.0; - const CLIPP_SHIFT: f64 = 1018.1563534409383; + const CLIPP_THRESH: f64 = -1022.0; // exponent of smallest possible f64 to prevent underflow + const CLIPP_SHIFT: f64 = 1022.9349439517318; // shift to align curve, found by regression let scaled_p = f64_consts::LOG2_E * self; - let clipp = scaled_p.max(CLIPP_THRESH); // let clipp = if scaled_p < CLIPP_THRESH { CLIPP_THRESH } else { scaled_p }; - let v = (V_SCALE * (clipp + CLIPP_SHIFT)) as u64; + let clipp = scaled_p.max(CLIPP_THRESH); + let v = (V_SCALE_F64 * (clipp + CLIPP_SHIFT)) as u64; f64::from_bits(v) } } +pub trait FastPow2 { + fn fast_pow2(self: Self) -> Self; +} +impl FastPow2 for f32 { + #[inline] + fn fast_pow2(self: Self) -> f32 { + (f32_consts::LN_2 * self).fast_exp() + } +} +impl FastPow2 for f64 { + #[inline] + fn fast_pow2(self: Self) -> f64 { + (f64_consts::LN_2 * self).fast_exp() + } +} + pub trait FastSigmoid { fn fast_sigmoid(self: Self) -> Self; } @@ -140,63 +120,7 @@ impl FastSigmoid for f64 { } } -// A trait for testing and improving implementations of fast functions -pub trait Test { - fn test(self: Self) -> Self; -} -impl Test for f32 { - #[inline] - fn test(self: Self) -> f32 { - // Khinchins constant over 3. IDK why it gives the best fit, but it does - // const KHINCHIN_3: f32 = 2.68545200106530644530971483548179569382038229399446295305115234555721885953715200280114117493184769799515 / 3.0; - const CLIPP_THRESH: f32 = -126.0; // 0.12847338; - const V_SCALE: f32 = 8388608.0; // (1_i32 << 23) as f32 - const CLIPP_SHIFT: f32 = 126.94269504; // 126.67740855; - - let scaled_p = f32_consts::LOG2_E * self; - let clipp = if scaled_p < CLIPP_THRESH { - CLIPP_THRESH - } else { - scaled_p - }; - let v = (V_SCALE * (clipp + CLIPP_SHIFT)) as u32; - f32::from_bits(v) // - KHINCHIN_3 - } -} -impl Test for f64 { - #[inline] - fn test(self: Self) -> f64 { - const CLIPP_THRESH: f64 = -180335.51911105003; - const V_SCALE: f64 = 4524653012949098.0; - const CLIPP_SHIFT: f64 = 1018.1563534409383; - - let scaled_p = f64_consts::LOG2_E * self; - let clipp = if scaled_p < CLIPP_THRESH { - CLIPP_THRESH - } else { - scaled_p - }; - let v = (V_SCALE * (clipp + CLIPP_SHIFT)) as u64; - f64::from_bits(v) - } -} - -#[allow(non_snake_case, dead_code)] -pub fn optimizing(p: f64, CLIPP_THRESH: f64, V_SCALE: f64, CLIPP_SHIFT: f64) -> f64 { - // const CLIPP_THRESH: f64 = -45774.9247660416; - // const V_SCALE: f64 = 4503599627370496.0; - // const CLIPP_SHIFT: f64 = 1022.6769200000002; - - let scaled_p = f64_consts::LOG2_E * p; - let clipp = if scaled_p < CLIPP_THRESH { - CLIPP_THRESH - } else { - scaled_p - }; - let v = (V_SCALE * (clipp + CLIPP_SHIFT)) as u64; - f64::from_bits(v) -} - +// functions for testing the accuracy of fast functions against builtin functions #[inline] pub fn sigmoid_builtin_f32(p: f32) -> f32 { (1. + (-p).exp()).recip() diff --git a/src/lookup/config.rs b/src/lookup/config.rs new file mode 100644 index 0000000..ceb008c --- /dev/null +++ b/src/lookup/config.rs @@ -0,0 +1,3 @@ +// lookup/config.rs + +const TABLE_SIZE: usize = 1000; \ No newline at end of file diff --git a/src/lookup/const_tables.rs b/src/lookup/const_tables.rs index 31a064e..7369580 100644 --- a/src/lookup/const_tables.rs +++ b/src/lookup/const_tables.rs @@ -1,30 +1,4 @@ // lookup/const_tables.rs -use once_cell::sync::Lazy; -use std::fs::read; -use bincode::deserialize; -use super::lookup_table::*; - -pub const SIN_LOOKUP_F32: Lazy> = Lazy::new(|| { - deserialize( - &read("src/lookup/data/sin_f32.bin").expect("Failed to read sin_f64.bin") - ).expect("Failed to load SIN_LOOKUP_F32") -}); - -pub const SIN_LOOKUP_F64: Lazy> = Lazy::new(|| { - deserialize( - &read("src/lookup/data/sin_f64.bin").expect("Failed to read sin_f32.bin") - ).expect("Failed to load SIN_LOOKUP_F64") -}); - -pub const COS_LOOKUP_F32: Lazy> = Lazy::new(|| { - deserialize( - &read("src/lookup/data/cos_f32.bin").expect("Failed to read cos_f64.bin") - ).expect("Failed to load COS_LOOKUP_F32") -}); - -pub const COS_LOOKUP_F64: Lazy> = Lazy::new(|| { - deserialize( - &read("src/lookup/data/cos_f64.bin").expect("Failed to read cos_f32.bin") - ).expect("Failed to load COS_LOOKUP_F64") -}); +include!("data/sin_f32.rs"); +include!("data/sin_f64.rs"); \ No newline at end of file diff --git a/src/lookup/data/cos_f32.bin b/src/lookup/data/cos_f32.bin deleted file mode 100644 index 78252d9..0000000 Binary files a/src/lookup/data/cos_f32.bin and /dev/null differ diff --git a/src/lookup/data/cos_f64.bin b/src/lookup/data/cos_f64.bin deleted file mode 100644 index 0a7b3ac..0000000 Binary files a/src/lookup/data/cos_f64.bin and /dev/null differ diff --git a/src/lookup/data/sin_f32.bin b/src/lookup/data/sin_f32.bin deleted file mode 100644 index 78252d9..0000000 Binary files a/src/lookup/data/sin_f32.bin and /dev/null differ diff --git a/src/lookup/data/sin_f32.rs b/src/lookup/data/sin_f32.rs new file mode 100644 index 0000000..237a898 --- /dev/null +++ b/src/lookup/data/sin_f32.rs @@ -0,0 +1,2 @@ +pub const SIN_F32_KEYS: [f32; 1000] = [-0.0007853982, 0.0007853982, 0.0023561944, 0.0039269906, 0.005497787, 0.0070685837, 0.008639379, 0.010210176, 0.011780973, 0.013351769, 0.014922566, 0.016493363, 0.018064158, 0.019634955, 0.021205751, 0.022776548, 0.024347344, 0.025918141, 0.027488938, 0.029059734, 0.03063053, 0.032201324, 0.033772122, 0.035342917, 0.03691371, 0.03848451, 0.040055305, 0.041626103, 0.043196898, 0.044767696, 0.04633849, 0.04790929, 0.049480084, 0.05105088, 0.052621678, 0.054192472, 0.05576327, 0.057334065, 0.058904864, 0.06047566, 0.062046457, 0.06361725, 0.06518805, 0.06675885, 0.06832965, 0.06990044, 0.07147124, 0.073042035, 0.074612826, 0.076183625, 0.07775442, 0.07932522, 0.08089601, 0.08246681, 0.08403761, 0.08560841, 0.0871792, 0.08875, 0.090320796, 0.09189159, 0.093462385, 0.09503318, 0.09660398, 0.09817477, 0.09974557, 0.10131637, 0.10288716, 0.10445796, 0.10602876, 0.10759956, 0.10917035, 0.110741146, 0.112311944, 0.113882735, 0.115453534, 0.11702433, 0.11859513, 0.12016592, 0.12173672, 0.12330752, 0.12487832, 0.12644911, 0.1280199, 0.1295907, 0.1311615, 0.1327323, 0.1343031, 0.13587388, 0.13744469, 0.13901548, 0.14058627, 0.14215708, 0.14372787, 0.14529866, 0.14686947, 0.14844026, 0.15001105, 0.15158185, 0.15315264, 0.15472345, 0.15629424, 0.15786503, 0.15943584, 0.16100663, 0.16257742, 0.16414823, 0.16571902, 0.16728981, 0.16886061, 0.1704314, 0.17200221, 0.173573, 0.1751438, 0.1767146, 0.17828539, 0.17985618, 0.18142699, 0.18299778, 0.18456857, 0.18613937, 0.18771017, 0.18928096, 0.19085176, 0.19242255, 0.19399336, 0.19556415, 0.19713494, 0.19870575, 0.20027654, 0.20184733, 0.20341814, 0.20498893, 0.20655972, 0.20813052, 0.20970131, 0.21127212, 0.21284291, 0.2144137, 0.21598451, 0.2175553, 0.21912609, 0.2206969, 0.22226769, 0.22383848, 0.22540928, 0.22698008, 0.22855087, 0.23012167, 0.23169246, 0.23326327, 0.23483406, 0.23640485, 0.23797566, 0.23954645, 0.24111724, 0.24268804, 0.24425884, 0.24582963, 0.24740043, 0.24897122, 0.250542, 0.2521128, 0.2536836, 0.2552544, 0.25682518, 0.258396, 0.2599668, 0.26153758, 0.26310837, 0.26467916, 0.26624998, 0.26782078, 0.26939157, 0.27096236, 0.27253315, 0.27410394, 0.27567476, 0.27724555, 0.27881634, 0.28038713, 0.28195792, 0.28352875, 0.28509954, 0.28667033, 0.28824112, 0.2898119, 0.2913827, 0.29295352, 0.2945243, 0.2960951, 0.2976659, 0.29923669, 0.30080748, 0.3023783, 0.3039491, 0.30551988, 0.30709067, 0.30866146, 0.31023228, 0.31180307, 0.31337386, 0.31494465, 0.31651545, 0.31808624, 0.31965706, 0.32122785, 0.32279864, 0.32436943, 0.32594022, 0.32751104, 0.32908183, 0.33065262, 0.33222342, 0.3337942, 0.335365, 0.33693582, 0.3385066, 0.3400774, 0.3416482, 0.34321898, 0.3447898, 0.3463606, 0.34793139, 0.34950218, 0.35107297, 0.35264376, 0.35421458, 0.35578537, 0.35735616, 0.35892695, 0.36049774, 0.36206856, 0.36363935, 0.36521015, 0.36678094, 0.36835173, 0.36992252, 0.37149334, 0.37306413, 0.37463492, 0.3762057, 0.3777765, 0.3793473, 0.38091812, 0.3824889, 0.3840597, 0.3856305, 0.38720128, 0.3887721, 0.3903429, 0.39191368, 0.39348447, 0.39505526, 0.39662606, 0.39819688, 0.39976767, 0.40133846, 0.40290925, 0.40448004, 0.40605086, 0.40762165, 0.40919244, 0.41076323, 0.41233402, 0.41390482, 0.41547564, 0.41704643, 0.41861722, 0.420188, 0.4217588, 0.42332962, 0.4249004, 0.4264712, 0.428042, 0.4296128, 0.43118358, 0.4327544, 0.4343252, 0.43589598, 0.43746677, 0.43903756, 0.44060835, 0.44217917, 0.44374996, 0.44532076, 0.44689155, 0.44846234, 0.45003316, 0.45160395, 0.45317474, 0.45474553, 0.45631632, 0.4578871, 0.45945793, 0.46102872, 0.46259952, 0.4641703, 0.4657411, 0.46731192, 0.4688827, 0.4704535, 0.4720243, 0.47359508, 0.47516587, 0.4767367, 0.4783075, 0.47987828, 0.48144907, 0.48301986, 0.48459068, 0.48616147, 0.48773226, 0.48930305, 0.49087384, 0.49244463, 0.49401546, 0.49558625, 0.49715704, 0.49872783, 0.5002986, 0.50186944, 0.5034402, 0.505011, 0.50658184, 0.5081526, 0.5097234, 0.5112942, 0.512865, 0.51443577, 0.5160066, 0.5175774, 0.5191482, 0.520719, 0.52228975, 0.5238606, 0.5254314, 0.52700216, 0.528573, 0.53014374, 0.53171456, 0.5332854, 0.53485614, 0.53642696, 0.5379977, 0.53956854, 0.5411393, 0.5427101, 0.54428095, 0.5458517, 0.5474225, 0.5489933, 0.5505641, 0.55213493, 0.5537057, 0.5552765, 0.5568473, 0.5584181, 0.5599889, 0.5615597, 0.5631305, 0.56470126, 0.5662721, 0.5678429, 0.56941366, 0.5709845, 0.57255524, 0.57412606, 0.5756968, 0.57726765, 0.57883847, 0.5804092, 0.58198005, 0.5835508, 0.58512163, 0.58669245, 0.5882632, 0.58983403, 0.5914048, 0.5929756, 0.59454644, 0.5961172, 0.597688, 0.5992588, 0.6008296, 0.60240036, 0.6039712, 0.605542, 0.60711277, 0.6086836, 0.61025435, 0.61182517, 0.613396, 0.61496675, 0.6165376, 0.61810833, 0.61967915, 0.62125, 0.62282073, 0.62439156, 0.6259623, 0.62753314, 0.62910396, 0.6306747, 0.63224554, 0.6338163, 0.6353871, 0.6369579, 0.6385287, 0.6400995, 0.6416703, 0.6432411, 0.64481187, 0.6463827, 0.6479535, 0.6495243, 0.6510951, 0.65266585, 0.6542367, 0.6558075, 0.65737826, 0.6589491, 0.66051984, 0.66209066, 0.6636615, 0.66523224, 0.66680306, 0.6683738, 0.66994464, 0.6715154, 0.6730862, 0.67465705, 0.6762278, 0.6777986, 0.6793694, 0.6809402, 0.68251103, 0.6840818, 0.6856526, 0.6872234, 0.6887942, 0.690365, 0.6919358, 0.6935066, 0.69507736, 0.6966482, 0.69821894, 0.69978976, 0.7013606, 0.70293134, 0.70450217, 0.7060729, 0.70764375, 0.70921457, 0.7107853, 0.71235615, 0.7139269, 0.71549773, 0.71706855, 0.7186393, 0.72021013, 0.7217809, 0.7233517, 0.72492254, 0.7264933, 0.7280641, 0.7296349, 0.7312057, 0.73277646, 0.7343473, 0.7359181, 0.73748887, 0.7390597, 0.74063045, 0.74220127, 0.7437721, 0.74534285, 0.7469137, 0.74848443, 0.75005525, 0.7516261, 0.75319684, 0.75476766, 0.7563384, 0.75790924, 0.75948, 0.7610508, 0.76262164, 0.7641924, 0.7657632, 0.767334, 0.7689048, 0.7704756, 0.7720464, 0.7736172, 0.77518797, 0.7767588, 0.7783296, 0.7799004, 0.7814712, 0.78304195, 0.7846128, 0.7861836, 0.78775436, 0.7893252, 0.79089594, 0.79246676, 0.7940375, 0.79560834, 0.79717916, 0.7987499, 0.80032074, 0.8018915, 0.8034623, 0.80503315, 0.8066039, 0.8081747, 0.8097455, 0.8113163, 0.81288713, 0.8144579, 0.8160287, 0.8175995, 0.8191703, 0.82074106, 0.8223119, 0.8238827, 0.82545346, 0.8270243, 0.82859504, 0.83016586, 0.8317367, 0.83330745, 0.83487827, 0.836449, 0.83801985, 0.83959067, 0.84116143, 0.84273225, 0.844303, 0.84587383, 0.84744465, 0.8490154, 0.85058624, 0.852157, 0.8537278, 0.8552986, 0.8568694, 0.8584402, 0.860011, 0.8615818, 0.86315256, 0.8647234, 0.8662942, 0.86786497, 0.8694358, 0.87100655, 0.87257737, 0.8741482, 0.87571895, 0.8772898, 0.87886053, 0.88043135, 0.8820021, 0.88357294, 0.88514376, 0.8867145, 0.88828534, 0.8898561, 0.8914269, 0.89299774, 0.8945685, 0.8961393, 0.8977101, 0.8992809, 0.9008517, 0.9024225, 0.9039933, 0.90556407, 0.9071349, 0.9087057, 0.9102765, 0.9118473, 0.91341805, 0.9149889, 0.91655964, 0.91813046, 0.9197013, 0.92127204, 0.92284286, 0.9244136, 0.92598444, 0.92755526, 0.929126, 0.93069685, 0.9322676, 0.9338384, 0.93540925, 0.93698, 0.93855083, 0.9401216, 0.9416924, 0.9432632, 0.944834, 0.9464048, 0.9479756, 0.9495464, 0.95111716, 0.952688, 0.9542588, 0.95582956, 0.9574004, 0.95897114, 0.96054196, 0.9621128, 0.96368355, 0.96525437, 0.9668251, 0.96839595, 0.96996677, 0.97153753, 0.97310835, 0.9746791, 0.97624993, 0.9778207, 0.9793915, 0.98096234, 0.9825331, 0.9841039, 0.9856747, 0.9872455, 0.9888163, 0.9903871, 0.9919579, 0.99352866, 0.9950995, 0.9966703, 0.99824107, 0.9998118, 1.0013827, 1.0029535, 1.0045244, 1.0060952, 1.0076659, 1.0092367, 1.0108075, 1.0123783, 1.0139492, 1.0155199, 1.0170907, 1.0186615, 1.0202323, 1.021803, 1.0233738, 1.0249447, 1.0265155, 1.0280863, 1.029657, 1.0312278, 1.0327986, 1.0343695, 1.0359403, 1.037511, 1.0390818, 1.0406526, 1.0422235, 1.0437943, 1.045365, 1.0469358, 1.0485066, 1.0500774, 1.0516483, 1.053219, 1.0547898, 1.0563606, 1.0579314, 1.0595022, 1.061073, 1.0626438, 1.0642146, 1.0657854, 1.0673562, 1.0689269, 1.0704978, 1.0720686, 1.0736394, 1.0752102, 1.0767809, 1.0783517, 1.0799226, 1.0814934, 1.0830641, 1.0846349, 1.0862057, 1.0877765, 1.0893474, 1.0909181, 1.0924889, 1.0940597, 1.0956305, 1.0972013, 1.098772, 1.1003429, 1.1019137, 1.1034845, 1.1050553, 1.106626, 1.1081969, 1.1097677, 1.1113385, 1.1129093, 1.11448, 1.1160508, 1.1176217, 1.1191925, 1.1207633, 1.122334, 1.1239048, 1.1254756, 1.1270465, 1.1286173, 1.130188, 1.1317588, 1.1333296, 1.1349005, 1.1364713, 1.138042, 1.1396128, 1.1411836, 1.1427544, 1.1443251, 1.145896, 1.1474668, 1.1490376, 1.1506084, 1.1521791, 1.15375, 1.1553208, 1.1568916, 1.1584624, 1.1600331, 1.1616039, 1.1631747, 1.1647456, 1.1663164, 1.1678871, 1.1694579, 1.1710287, 1.1725996, 1.1741704, 1.1757411, 1.1773119, 1.1788827, 1.1804535, 1.1820244, 1.1835951, 1.1851659, 1.1867367, 1.1883075, 1.1898783, 1.191449, 1.1930199, 1.1945907, 1.1961615, 1.1977323, 1.199303, 1.2008739, 1.2024447, 1.2040155, 1.2055862, 1.207157, 1.2087278, 1.2102987, 1.2118695, 1.2134402, 1.215011, 1.2165818, 1.2181526, 1.2197235, 1.2212942, 1.222865, 1.2244358, 1.2260066, 1.2275774, 1.2291481, 1.230719, 1.2322898, 1.2338606, 1.2354314, 1.2370021, 1.238573, 1.2401438, 1.2417146, 1.2432854, 1.2448561, 1.2464269, 1.2479978, 1.2495686, 1.2511394, 1.2527101, 1.2542809, 1.2558517, 1.2574226, 1.2589934, 1.2605641, 1.2621349, 1.2637057, 1.2652766, 1.2668474, 1.2684181, 1.2699889, 1.2715597, 1.2731305, 1.2747012, 1.276272, 1.2778429, 1.2794137, 1.2809845, 1.2825552, 1.284126, 1.2856969, 1.2872677, 1.2888385, 1.2904092, 1.29198, 1.2935508, 1.2951217, 1.2966925, 1.2982632, 1.299834, 1.3014048, 1.3029757, 1.3045465, 1.3061172, 1.307688, 1.3092588, 1.3108296, 1.3124005, 1.3139712, 1.315542, 1.3171128, 1.3186836, 1.3202544, 1.3218251, 1.323396, 1.3249668, 1.3265376, 1.3281084, 1.3296791, 1.33125, 1.3328208, 1.3343916, 1.3359623, 1.3375331, 1.3391039, 1.3406748, 1.3422456, 1.3438163, 1.3453871, 1.3469579, 1.3485287, 1.3500996, 1.3516703, 1.3532411, 1.3548119, 1.3563827, 1.3579535, 1.3595243, 1.3610951, 1.3626659, 1.3642367, 1.3658075, 1.3673782, 1.368949, 1.3705199, 1.3720907, 1.3736615, 1.3752322, 1.376803, 1.3783739, 1.3799447, 1.3815155, 1.3830862, 1.384657, 1.3862278, 1.3877987, 1.3893695, 1.3909402, 1.392511, 1.3940818, 1.3956527, 1.3972234, 1.3987942, 1.400365, 1.4019358, 1.4035066, 1.4050773, 1.4066482, 1.408219, 1.4097898, 1.4113606, 1.4129313, 1.4145021, 1.416073, 1.4176438, 1.4192146, 1.4207853, 1.4223561, 1.423927, 1.4254978, 1.4270686, 1.4286393, 1.4302101, 1.4317809, 1.4333518, 1.4349226, 1.4364933, 1.4380641, 1.4396349, 1.4412057, 1.4427766, 1.4443473, 1.4459181, 1.4474889, 1.4490597, 1.4506305, 1.4522012, 1.4537721, 1.4553429, 1.4569137, 1.4584844, 1.4600552, 1.461626, 1.4631969, 1.4647677, 1.4663384, 1.4679092, 1.46948, 1.4710509, 1.4726217, 1.4741924, 1.4757632, 1.477334, 1.4789048, 1.4804757, 1.4820464, 1.4836172, 1.485188, 1.4867588, 1.4883296, 1.4899004, 1.4914712, 1.493042, 1.4946128, 1.4961836, 1.4977543, 1.4993252, 1.500896, 1.5024668, 1.5040376, 1.5056083, 1.5071791, 1.50875, 1.5103208, 1.5118916, 1.5134623, 1.5150331, 1.516604, 1.5181748, 1.5197455, 1.5213163, 1.5228871, 1.5244579, 1.5260288, 1.5275995, 1.5291703, 1.5307411, 1.5323119, 1.5338827, 1.5354534, 1.5370243, 1.5385951, 1.5401659, 1.5417367, 1.5433074, 1.5448782, 1.5464491, 1.5480199, 1.5495907, 1.5511614, 1.5527322, 1.554303, 1.5558739, 1.5574447, 1.5590154, 1.5605862, 1.562157, 1.5637279, 1.5652987, 1.5668694, 1.5684402]; +pub const SIN_F32_VALUES: [f32; 1000] = [0.0, 0.0015707957, 0.0031415876, 0.0047123716, 0.006283144, 0.007853901, 0.009424638, 0.010995353, 0.01256604, 0.014136696, 0.015707318, 0.0172779, 0.01884844, 0.020418933, 0.021989375, 0.023559766, 0.025130097, 0.026700364, 0.028270569, 0.0298407, 0.03141076, 0.03298074, 0.034550644, 0.036120456, 0.03769018, 0.039259817, 0.040829353, 0.042398788, 0.04396812, 0.04553734, 0.047106452, 0.048675448, 0.05024432, 0.051813066, 0.053381693, 0.05495018, 0.056518536, 0.05808675, 0.059654824, 0.061222747, 0.06279052, 0.06435814, 0.0659256, 0.067492895, 0.06906003, 0.07062698, 0.07219377, 0.07376038, 0.0753268, 0.07689305, 0.0784591, 0.08002496, 0.08159061, 0.08315607, 0.08472133, 0.08628637, 0.0878512, 0.08941581, 0.09098021, 0.09254437, 0.09410831, 0.09567203, 0.0972355, 0.09879873, 0.10036172, 0.10192446, 0.10348695, 0.10504918, 0.106611155, 0.10817287, 0.10973431, 0.111295484, 0.11285639, 0.114417, 0.11597735, 0.1175374, 0.119097166, 0.12065663, 0.1222158, 0.12377468, 0.12533323, 0.1268915, 0.12844943, 0.13000706, 0.13156436, 0.13312134, 0.13467799, 0.13623431, 0.13779029, 0.13934594, 0.14090122, 0.14245619, 0.14401078, 0.14556502, 0.14711891, 0.14867243, 0.15022558, 0.15177839, 0.15333079, 0.15488282, 0.15643448, 0.15798573, 0.15953662, 0.16108708, 0.16263716, 0.16418685, 0.16573612, 0.16728498, 0.16883345, 0.17038149, 0.1719291, 0.1734763, 0.17502306, 0.1765694, 0.1781153, 0.17966075, 0.18120578, 0.18275033, 0.18429445, 0.18583812, 0.18738131, 0.18892406, 0.19046634, 0.19200814, 0.19354948, 0.19509032, 0.1966307, 0.19817059, 0.19970998, 0.20124888, 0.20278731, 0.20432521, 0.20586261, 0.20739952, 0.20893589, 0.21047178, 0.21200712, 0.21354194, 0.21507625, 0.21661001, 0.21814324, 0.21967594, 0.2212081, 0.2227397, 0.22427078, 0.22580127, 0.22733122, 0.22886062, 0.23038943, 0.2319177, 0.23344538, 0.23497248, 0.23649901, 0.23802495, 0.23955029, 0.24107507, 0.24259923, 0.2441228, 0.24564578, 0.24716814, 0.2486899, 0.25021103, 0.25173154, 0.25325143, 0.25477073, 0.2562894, 0.2578074, 0.25932476, 0.26084152, 0.2623576, 0.26387307, 0.26538786, 0.266902, 0.26841548, 0.2699283, 0.27144045, 0.27295196, 0.27446276, 0.2759729, 0.27748233, 0.2789911, 0.28049922, 0.2820066, 0.28351328, 0.28501928, 0.28652456, 0.28802913, 0.28953302, 0.2910362, 0.2925386, 0.29404032, 0.29554132, 0.29704157, 0.29854113, 0.30003992, 0.30153796, 0.30303526, 0.30453184, 0.30602765, 0.3075227, 0.309017, 0.31051055, 0.31200328, 0.31349528, 0.31498653, 0.31647697, 0.31796664, 0.3194555, 0.3209436, 0.32243094, 0.32391742, 0.32540312, 0.32688802, 0.32837212, 0.3298554, 0.3313379, 0.33281955, 0.3343004, 0.33578038, 0.33725956, 0.33873793, 0.34021544, 0.34169212, 0.34316793, 0.34464294, 0.34611705, 0.34759036, 0.34906277, 0.35053432, 0.35200503, 0.35347486, 0.3549438, 0.3564119, 0.3578791, 0.3593454, 0.36081082, 0.36227536, 0.36373904, 0.36520177, 0.3666636, 0.36812454, 0.3695846, 0.3710437, 0.37250194, 0.3739592, 0.3754156, 0.37687102, 0.37832552, 0.37977913, 0.38123176, 0.38268346, 0.3841342, 0.385584, 0.38703284, 0.38848075, 0.38992772, 0.39137366, 0.3928187, 0.39426273, 0.39570582, 0.3971479, 0.39858902, 0.40002915, 0.40146828, 0.40290642, 0.4043436, 0.40577978, 0.40721494, 0.4086491, 0.41008222, 0.41151437, 0.4129455, 0.4143756, 0.41580465, 0.41723272, 0.41865975, 0.42008576, 0.4215107, 0.4229346, 0.42435747, 0.42577928, 0.42720005, 0.4286198, 0.43003845, 0.43145606, 0.4328726, 0.43428805, 0.43570247, 0.4371158, 0.43852803, 0.43993917, 0.44134924, 0.44275823, 0.44416615, 0.44557294, 0.44697863, 0.4483832, 0.4497867, 0.4511891, 0.45259038, 0.45399052, 0.45538953, 0.45678744, 0.4581842, 0.45957989, 0.4609744, 0.46236777, 0.46376, 0.46515107, 0.46654105, 0.46792984, 0.46931747, 0.47070393, 0.47208926, 0.4734734, 0.4748564, 0.47623822, 0.47761884, 0.4789983, 0.48037657, 0.4817537, 0.48312956, 0.4845043, 0.48587784, 0.48725012, 0.48862126, 0.48999116, 0.49135986, 0.49272734, 0.49409363, 0.4954587, 0.4968225, 0.49818513, 0.49954647, 0.50090665, 0.5022656, 0.5036232, 0.50497967, 0.5063348, 0.50768876, 0.5090414, 0.51039284, 0.511743, 0.51309186, 0.5144395, 0.5157859, 0.517131, 0.5184748, 0.51981735, 0.52115864, 0.52249855, 0.52383727, 0.5251747, 0.5265107, 0.5278455, 0.529179, 0.5305112, 0.5318421, 0.5331716, 0.5344999, 0.5358268, 0.5371524, 0.5384767, 0.53979963, 0.5411213, 0.54244155, 0.5437605, 0.5450781, 0.54639435, 0.5477093, 0.5490228, 0.55033505, 0.5516459, 0.5529554, 0.55426353, 0.55557024, 0.55687565, 0.5581796, 0.5594823, 0.56078357, 0.56208336, 0.5633819, 0.56467897, 0.56597465, 0.5672689, 0.56856185, 0.56985337, 0.57114345, 0.57243216, 0.5737194, 0.57500523, 0.5762897, 0.5775727, 0.5788543, 0.58013445, 0.5814132, 0.58269054, 0.5839663, 0.5852408, 0.5865137, 0.58778524, 0.58905536, 0.5903239, 0.5915911, 0.5928568, 0.5941211, 0.5953838, 0.5966452, 0.59790504, 0.59916335, 0.60042024, 0.6016756, 0.60292953, 0.604182, 0.6054329, 0.60668236, 0.6079303, 0.60917675, 0.6104217, 0.6116651, 0.61290705, 0.6141475, 0.61538637, 0.61662376, 0.6178596, 0.61909395, 0.62032676, 0.62155807, 0.6227878, 0.624016, 0.6252427, 0.62646776, 0.6276914, 0.6289134, 0.63013387, 0.63135284, 0.63257015, 0.63378596, 0.6350002, 0.6362129, 0.63742405, 0.63863355, 0.6398415, 0.64104784, 0.6422527, 0.64345586, 0.6446575, 0.6458576, 0.647056, 0.64825284, 0.64944804, 0.6506417, 0.6518338, 0.65302414, 0.654213, 0.65540016, 0.65658575, 0.65776974, 0.65895206, 0.6601328, 0.66131186, 0.66248935, 0.6636652, 0.6648393, 0.66601187, 0.66718274, 0.66835207, 0.6695196, 0.6706856, 0.6718499, 0.6730125, 0.67417353, 0.6753328, 0.6764905, 0.67764646, 0.67880076, 0.6799534, 0.68110436, 0.6822536, 0.6834012, 0.6845471, 0.68569136, 0.68683386, 0.6879747, 0.6891138, 0.69025123, 0.691387, 0.692521, 0.69365335, 0.6947839, 0.6959128, 0.69704, 0.6981654, 0.69928914, 0.70041114, 0.7015314, 0.70265, 0.70376676, 0.70488185, 0.7059952, 0.70710677, 0.70821667, 0.7093247, 0.7104311, 0.7115357, 0.71263856, 0.7137396, 0.7148389, 0.7159365, 0.71703225, 0.7181263, 0.71921855, 0.720309, 0.72139776, 0.72248465, 0.7235698, 0.7246531, 0.7257347, 0.7268145, 0.72789246, 0.7289687, 0.730043, 0.73111564, 0.7321864, 0.7332553, 0.73432255, 0.73538786, 0.7364514, 0.7375131, 0.738573, 0.7396311, 0.7406874, 0.7417418, 0.74279433, 0.74384516, 0.7448941, 0.74594116, 0.7469864, 0.74802977, 0.74907136, 0.7501111, 0.75114894, 0.752185, 0.75321907, 0.7542514, 0.7552818, 0.7563104, 0.7573371, 0.75836194, 0.7593849, 0.76040596, 0.7614252, 0.7624425, 0.76345795, 0.76447153, 0.7654832, 0.766493, 0.76750094, 0.76850694, 0.76951104, 0.77051324, 0.7715136, 0.77251196, 0.7735085, 0.7745031, 0.77549577, 0.7764865, 0.77747536, 0.7784623, 0.7794473, 0.78043044, 0.7814116, 0.78239083, 0.7833681, 0.78434354, 0.78531694, 0.78628844, 0.78725797, 0.78822565, 0.7891913, 0.790155, 0.79111683, 0.7920766, 0.7930345, 0.7939904, 0.79494435, 0.79589635, 0.7968464, 0.79779446, 0.7987405, 0.79968464, 0.8006268, 0.801567, 0.8025052, 0.8034414, 0.80437565, 0.8053079, 0.8062382, 0.80716646, 0.8080927, 0.809017, 0.80993927, 0.81085956, 0.8117779, 0.8126942, 0.81360847, 0.8145207, 0.815431, 0.81633925, 0.8172455, 0.81814975, 0.8190519, 0.81995213, 0.8208503, 0.8217464, 0.82264054, 0.8235326, 0.82442266, 0.8253107, 0.8261967, 0.8270806, 0.82796246, 0.82884234, 0.82972014, 0.8305959, 0.83146966, 0.83234125, 0.8332109, 0.83407843, 0.83494395, 0.8358074, 0.8366687, 0.83752805, 0.8383853, 0.8392405, 0.84009355, 0.8409446, 0.84179354, 0.8426404, 0.84348524, 0.8443279, 0.8451686, 0.8460071, 0.84684354, 0.84767795, 0.84851027, 0.84934044, 0.85016847, 0.85099447, 0.8518184, 0.8526402, 0.85345984, 0.85427743, 0.8550929, 0.8559063, 0.8567175, 0.85752666, 0.85833365, 0.8591386, 0.85994136, 0.86074203, 0.86154056, 0.862337, 0.8631313, 0.86392343, 0.8647135, 0.86550134, 0.8662871, 0.86707073, 0.8678522, 0.86863154, 0.86940867, 0.87018377, 0.87095666, 0.8717274, 0.87249607, 0.87326247, 0.8740268, 0.8747889, 0.8755489, 0.8763067, 0.8770623, 0.87781584, 0.87856716, 0.87931633, 0.88006335, 0.8808081, 0.8815508, 0.88229126, 0.8830295, 0.88376564, 0.88449955, 0.8852313, 0.8859609, 0.8866883, 0.88741344, 0.88813645, 0.88885725, 0.8895759, 0.89029235, 0.8910065, 0.89171857, 0.8924284, 0.893136, 0.89384145, 0.8945446, 0.8952457, 0.8959445, 0.8966411, 0.89733547, 0.89802754, 0.8987175, 0.89940524, 0.90009075, 0.90077406, 0.9014551, 0.90213394, 0.9028106, 0.903485, 0.90415716, 0.90482706, 0.90549475, 0.90616024, 0.90682346, 0.9074845, 0.90814316, 0.9087997, 0.909454, 0.910106, 0.91075575, 0.9114033, 0.9120486, 0.9126916, 0.9133324, 0.9139709, 0.91460717, 0.9152412, 0.91587293, 0.9165025, 0.91712964, 0.91775465, 0.91837734, 0.91899776, 0.919616, 0.9202318, 0.9208455, 0.9214569, 0.922066, 0.92267275, 0.92327726, 0.9238795, 0.92447954, 0.9250772, 0.92567265, 0.9262657, 0.9268566, 0.9274452, 0.92803144, 0.92861545, 0.9291971, 0.9297765, 0.9303536, 0.9309284, 0.9315009, 0.9320711, 0.932639, 0.93320465, 0.933768, 0.9343289, 0.93488765, 0.93544406, 0.93599814, 0.9365499, 0.93709934, 0.9376465, 0.93819135, 0.9387339, 0.9392741, 0.93981194, 0.9403475, 0.9408808, 0.94141173, 0.9419403, 0.94246656, 0.94299054, 0.9435122, 0.9440315, 0.9445485, 0.94506305, 0.94557536, 0.9460854, 0.94659305, 0.9470983, 0.94760126, 0.9481019, 0.94860023, 0.94909614, 0.9495898, 0.950081, 0.9505699, 0.95105654, 0.95154077, 0.9520227, 0.95250213, 0.9529793, 0.9534542, 0.9539267, 0.9543968, 0.95486456, 0.95532995, 0.955793, 0.9562537, 0.95671207, 0.95716804, 0.95762163, 0.9580729, 0.9585218, 0.9589683, 0.95941246, 0.95985425, 0.9602937, 0.96073073, 0.9611654, 0.96159774, 0.96202767, 0.9624553, 0.96288043, 0.9633032, 0.96372366, 0.9641417, 0.9645574, 0.96497077, 0.9653816, 0.96579015, 0.96619636, 0.9666001, 0.9670015, 0.9674005, 0.9677971, 0.9681913, 0.96858317, 0.9689726, 0.96935964, 0.9697443, 0.9701266, 0.9705065, 0.97088397, 0.97125906, 0.97163177, 0.972002, 0.9723699, 0.9727354, 0.9730985, 0.9734592, 0.9738175, 0.9741734, 0.9745269, 0.97487795, 0.97522664, 0.9755729, 0.9759168, 0.9762582, 0.97659725, 0.9769339, 0.97726816, 0.9776, 0.97792935, 0.97825634, 0.9785809, 0.97890306, 0.97922283, 0.9795401, 0.97985506, 0.98016757, 0.98047763, 0.9807853, 0.9810905, 0.98139334, 0.98169374, 0.9819917, 0.9822873, 0.98258036, 0.98287106, 0.98315936, 0.9834452, 0.98372865, 0.9840096, 0.9842882, 0.98456436, 0.98483807, 0.9851093, 0.9853782, 0.9856446, 0.98590857, 0.9861702, 0.9864293, 0.98668593, 0.9869402, 0.98719203, 0.9874414, 0.98768836, 0.98793286, 0.9881749, 0.9884146, 0.98865175, 0.9888865, 0.9891188, 0.9893487, 0.9895761, 0.9898011, 0.9900237, 0.9902438, 0.9904614, 0.99067664, 0.99088943, 0.9910998, 0.9913076, 0.9915131, 0.9917161, 0.9919166, 0.9921147, 0.99231035, 0.9925036, 0.9926943, 0.9928826, 0.99306846, 0.99325186, 0.9934328, 0.99361134, 0.99378735, 0.993961, 0.9941321, 0.9943008, 0.994467, 0.9946308, 0.99479216, 0.994951, 0.9951075, 0.99526143, 0.9954129, 0.99556196, 0.9957086, 0.9958527, 0.9959944, 0.9961336, 0.99627036, 0.9964047, 0.99653655, 0.99666595, 0.99679285, 0.9969173, 0.9970394, 0.9971589, 0.997276, 0.9973906, 0.9975028, 0.99761254, 0.99771976, 0.99782455, 0.9979269, 0.9980267, 0.9981241, 0.9982191, 0.9983115, 0.9984015, 0.9984891, 0.9985742, 0.9986568, 0.998737, 0.99881464, 0.99888986, 0.99896264, 0.9990329, 0.99910074, 0.99916613, 0.999229, 0.99928945, 0.99934745, 0.99940294, 0.999456, 0.99950653, 0.9995547, 0.9996003, 0.9996435, 0.9996842, 0.9997224, 0.9997582, 0.9997915, 0.9998224, 0.99985075, 0.9998766, 0.99990004, 0.999921, 0.99993956, 0.9999556, 0.9999692, 0.9999803, 0.9999889, 0.99999505, 0.99999875]; diff --git a/src/lookup/data/sin_f64.bin b/src/lookup/data/sin_f64.bin deleted file mode 100644 index 0a7b3ac..0000000 Binary files a/src/lookup/data/sin_f64.bin and /dev/null differ diff --git a/src/lookup/data/sin_f64.rs b/src/lookup/data/sin_f64.rs new file mode 100644 index 0000000..186706b --- /dev/null +++ b/src/lookup/data/sin_f64.rs @@ -0,0 +1,2 @@ +pub const SIN_F64_KEYS: [f64; 1000] = [-0.0007853981633974483, 0.0007853981633974483, 0.002356194490192345, 0.003926990816987242, 0.005497787143782139, 0.0070685834705770355, 0.008639379797371931, 0.01021017612416683, 0.011780972450961725, 0.013351768777756621, 0.014922565104551519, 0.016493361431346415, 0.01806415775814131, 0.019634954084936207, 0.021205750411731106, 0.022776546738526002, 0.0243473430653209, 0.025918139392115794, 0.02748893571891069, 0.02905973204570559, 0.030630528372500486, 0.03220132469929538, 0.03377212102609028, 0.035342917352885174, 0.03691371367968007, 0.038484510006474966, 0.04005530633326986, 0.041626102660064765, 0.04319689898685966, 0.04476769531365456, 0.04633849164044945, 0.04790928796724435, 0.049480084294039245, 0.05105088062083414, 0.05262167694762904, 0.05419247327442393, 0.05576326960121883, 0.057334065928013725, 0.05890486225480863, 0.060475658581603524, 0.06204645490839842, 0.06361725123519331, 0.0651880475619882, 0.0667588438887831, 0.068329640215578, 0.06990043654237289, 0.07147123286916779, 0.07304202919596268, 0.07461282552275758, 0.07618362184955248, 0.07775441817634737, 0.07932521450314227, 0.08089601082993716, 0.08246680715673206, 0.08403760348352697, 0.08560839981032187, 0.08717919613711676, 0.08874999246391166, 0.09032078879070655, 0.09189158511750145, 0.09346238144429635, 0.09503317777109124, 0.09660397409788614, 0.09817477042468103, 0.09974556675147593, 0.10131636307827083, 0.10288715940506572, 0.10445795573186062, 0.10602875205865551, 0.10759954838545041, 0.1091703447122453, 0.1107411410390402, 0.1123119373658351, 0.11388273369263, 0.11545353001942489, 0.1170243263462198, 0.1185951226730147, 0.12016591899980959, 0.12173671532660449, 0.12330751165339938, 0.12487830798019428, 0.12644910430698916, 0.12801990063378407, 0.12959069696057895, 0.13116149328737386, 0.13273228961416875, 0.13430308594096366, 0.13587388226775857, 0.13744467859455345, 0.13901547492134836, 0.14058627124814324, 0.14215706757493815, 0.14372786390173303, 0.14529866022852794, 0.14686945655532282, 0.14844025288211773, 0.15001104920891262, 0.15158184553570753, 0.1531526418625024, 0.15472343818929732, 0.1562942345160922, 0.1578650308428871, 0.159435827169682, 0.1610066234964769, 0.16257741982327178, 0.1641482161500667, 0.16571901247686158, 0.1672898088036565, 0.1688606051304514, 0.17043140145724628, 0.1720021977840412, 0.17357299411083607, 0.17514379043763098, 0.17671458676442586, 0.17828538309122077, 0.17985617941801565, 0.18142697574481056, 0.18299777207160545, 0.18456856839840036, 0.18613936472519524, 0.18771016105199015, 0.18928095737878503, 0.19085175370557994, 0.19242255003237482, 0.19399334635916973, 0.19556414268596461, 0.19713493901275952, 0.1987057353395544, 0.20027653166634932, 0.20184732799314423, 0.2034181243199391, 0.20498892064673402, 0.2065597169735289, 0.2081305133003238, 0.2097013096271187, 0.2112721059539136, 0.21284290228070848, 0.2144136986075034, 0.21598449493429828, 0.2175552912610932, 0.21912608758788807, 0.22069688391468298, 0.22226768024147786, 0.22383847656827277, 0.22540927289506765, 0.22698006922186256, 0.22855086554865744, 0.23012166187545235, 0.23169245820224724, 0.23326325452904215, 0.23483405085583706, 0.23640484718263194, 0.23797564350942685, 0.23954643983622173, 0.24111723616301664, 0.24268803248981152, 0.24425882881660643, 0.24582962514340131, 0.24740042147019622, 0.2489712177969911, 0.250542014123786, 0.2521128104505809, 0.2536836067773758, 0.2552544031041707, 0.2568251994309656, 0.2583959957577605, 0.25996679208455536, 0.2615375884113503, 0.2631083847381452, 0.2646791810649401, 0.26624997739173495, 0.26782077371852986, 0.26939157004532477, 0.2709623663721197, 0.2725331626989146, 0.27410395902570944, 0.27567475535250435, 0.27724555167929926, 0.2788163480060942, 0.280387144332889, 0.28195794065968394, 0.28352873698647885, 0.28509953331327376, 0.2866703296400686, 0.2882411259668635, 0.28981192229365843, 0.29138271862045334, 0.2929535149472482, 0.2945243112740431, 0.296095107600838, 0.2976659039276329, 0.2992367002544278, 0.3008074965812227, 0.3023782929080176, 0.3039490892348125, 0.3055198855616074, 0.3070906818884023, 0.3086614782151972, 0.3102322745419921, 0.311803070868787, 0.31337386719558186, 0.31494466352237677, 0.3165154598491717, 0.3180862561759666, 0.31965705250276144, 0.32122784882955635, 0.32279864515635126, 0.32436944148314617, 0.325940237809941, 0.32751103413673593, 0.32908183046353084, 0.33065262679032575, 0.3322234231171206, 0.3337942194439155, 0.33536501577071043, 0.33693581209750534, 0.33850660842430025, 0.3400774047510951, 0.34164820107789, 0.3432189974046849, 0.34478979373147983, 0.3463605900582747, 0.3479313863850696, 0.3495021827118645, 0.3510729790386594, 0.35264377536545427, 0.3542145716922492, 0.3557853680190441, 0.357356164345839, 0.35892696067263385, 0.36049775699942876, 0.3620685533262237, 0.3636393496530186, 0.36521014597981344, 0.36678094230660835, 0.36835173863340326, 0.36992253496019817, 0.3714933312869931, 0.37306412761378793, 0.37463492394058284, 0.37620572026737775, 0.37777651659417266, 0.3793473129209675, 0.3809181092477624, 0.38248890557455734, 0.38405970190135225, 0.3856304982281471, 0.387201294554942, 0.3887720908817369, 0.39034288720853183, 0.3919136835353267, 0.3934844798621216, 0.3950552761889165, 0.3966260725157114, 0.39819686884250627, 0.3997676651693012, 0.4013384614960961, 0.402909257822891, 0.4044800541496859, 0.40605085047648076, 0.4076216468032757, 0.4091924431300706, 0.4107632394568655, 0.41233403578366035, 0.41390483211045526, 0.41547562843725017, 0.4170464247640451, 0.41861722109083993, 0.42018801741763484, 0.42175881374442975, 0.42332961007122466, 0.4249004063980195, 0.4264712027248144, 0.42804199905160933, 0.42961279537840424, 0.4311835917051991, 0.432754388031994, 0.4343251843587889, 0.43589598068558383, 0.43746677701237874, 0.4390375733391736, 0.4406083696659685, 0.4421791659927634, 0.4437499623195583, 0.4453207586463532, 0.4468915549731481, 0.448462351299943, 0.4500331476267379, 0.45160394395353276, 0.45317474028032767, 0.4547455366071226, 0.4563163329339175, 0.45788712926071234, 0.45945792558750725, 0.46102872191430216, 0.4625995182410971, 0.46417031456789193, 0.46574111089468684, 0.46731190722148175, 0.46888270354827666, 0.47045349987507157, 0.4720242962018664, 0.47359509252866133, 0.47516588885545624, 0.47673668518225115, 0.478307481509046, 0.4798782778358409, 0.4814490741626358, 0.48301987048943074, 0.4845906668162256, 0.4861614631430205, 0.4877322594698154, 0.4893030557966103, 0.4908738521234052, 0.4924446484502001, 0.494015444776995, 0.4955862411037899, 0.49715703743058476, 0.49872783375737967, 0.5002986300841746, 0.5018694264109695, 0.5034402227377645, 0.5050110190645594, 0.5065818153913543, 0.5081526117181491, 0.509723408044944, 0.5112942043717389, 0.5128650006985338, 0.5144357970253287, 0.5160065933521236, 0.5175773896789185, 0.5191481860057134, 0.5207189823325082, 0.5222897786593031, 0.5238605749860981, 0.525431371312893, 0.5270021676396879, 0.5285729639664828, 0.5301437602932777, 0.5317145566200726, 0.5332853529468674, 0.5348561492736623, 0.5364269456004572, 0.5379977419272521, 0.539568538254047, 0.541139334580842, 0.5427101309076369, 0.5442809272344318, 0.5458517235612267, 0.5474225198880215, 0.5489933162148164, 0.5505641125416113, 0.5521349088684062, 0.5537057051952011, 0.555276501521996, 0.556847297848791, 0.5584180941755859, 0.5599888905023807, 0.5615596868291756, 0.5631304831559705, 0.5647012794827654, 0.5662720758095603, 0.5678428721363552, 0.5694136684631501, 0.570984464789945, 0.5725552611167399, 0.5741260574435347, 0.5756968537703296, 0.5772676500971246, 0.5788384464239195, 0.5804092427507144, 0.5819800390775093, 0.5835508354043042, 0.5851216317310991, 0.5866924280578939, 0.5882632243846888, 0.5898340207114837, 0.5914048170382786, 0.5929756133650735, 0.5945464096918684, 0.5961172060186634, 0.5976880023454583, 0.5992587986722531, 0.600829594999048, 0.6024003913258429, 0.6039711876526378, 0.6055419839794327, 0.6071127803062276, 0.6086835766330225, 0.6102543729598174, 0.6118251692866123, 0.6133959656134071, 0.6149667619402021, 0.616537558266997, 0.6181083545937919, 0.6196791509205868, 0.6212499472473817, 0.6228207435741766, 0.6243915399009715, 0.6259623362277663, 0.6275331325545612, 0.6291039288813561, 0.630674725208151, 0.632245521534946, 0.6338163178617409, 0.6353871141885358, 0.6369579105153307, 0.6385287068421256, 0.6400995031689204, 0.6416702994957153, 0.6432410958225102, 0.6448118921493051, 0.6463826884761, 0.6479534848028949, 0.6495242811296899, 0.6510950774564848, 0.6526658737832796, 0.6542366701100745, 0.6558074664368694, 0.6573782627636643, 0.6589490590904592, 0.6605198554172541, 0.662090651744049, 0.6636614480708439, 0.6652322443976387, 0.6668030407244336, 0.6683738370512285, 0.6699446333780235, 0.6715154297048184, 0.6730862260316133, 0.6746570223584082, 0.6762278186852031, 0.677798615011998, 0.6793694113387928, 0.6809402076655877, 0.6825110039923826, 0.6840818003191775, 0.6856525966459724, 0.6872233929727674, 0.6887941892995623, 0.6903649856263572, 0.691935781953152, 0.6935065782799469, 0.6950773746067418, 0.6966481709335367, 0.6982189672603316, 0.6997897635871265, 0.7013605599139214, 0.7029313562407163, 0.7045021525675113, 0.706072948894306, 0.707643745221101, 0.7092145415478959, 0.7107853378746908, 0.7123561342014857, 0.7139269305282806, 0.7154977268550755, 0.7170685231818704, 0.7186393195086652, 0.7202101158354601, 0.721780912162255, 0.72335170848905, 0.7249225048158449, 0.7264933011426398, 0.7280640974694347, 0.7296348937962296, 0.7312056901230244, 0.7327764864498193, 0.7343472827766142, 0.7359180791034091, 0.737488875430204, 0.7390596717569989, 0.7406304680837938, 0.7422012644105888, 0.7437720607373837, 0.7453428570641785, 0.7469136533909734, 0.7484844497177683, 0.7500552460445632, 0.7516260423713581, 0.753196838698153, 0.7547676350249479, 0.7563384313517428, 0.7579092276785376, 0.7594800240053325, 0.7610508203321275, 0.7626216166589224, 0.7641924129857173, 0.7657632093125122, 0.7673340056393071, 0.768904801966102, 0.7704755982928969, 0.7720463946196917, 0.7736171909464866, 0.7751879872732815, 0.7767587836000764, 0.7783295799268714, 0.7799003762536663, 0.7814711725804612, 0.7830419689072561, 0.7846127652340509, 0.7861835615608458, 0.7877543578876407, 0.7893251542144356, 0.7908959505412305, 0.7924667468680254, 0.7940375431948203, 0.7956083395216152, 0.79717913584841, 0.798749932175205, 0.8003207285019999, 0.8018915248287948, 0.8034623211555897, 0.8050331174823846, 0.8066039138091795, 0.8081747101359744, 0.8097455064627693, 0.8113163027895641, 0.812887099116359, 0.814457895443154, 0.8160286917699489, 0.8175994880967438, 0.8191702844235387, 0.8207410807503336, 0.8223118770771285, 0.8238826734039233, 0.8254534697307182, 0.8270242660575131, 0.828595062384308, 0.8301658587111029, 0.8317366550378978, 0.8333074513646928, 0.8348782476914877, 0.8364490440182825, 0.8380198403450774, 0.8395906366718723, 0.8411614329986672, 0.8427322293254621, 0.844303025652257, 0.8458738219790519, 0.8474446183058468, 0.8490154146326417, 0.8505862109594365, 0.8521570072862314, 0.8537278036130264, 0.8552985999398213, 0.8568693962666162, 0.8584401925934111, 0.860010988920206, 0.8615817852470009, 0.8631525815737957, 0.8647233779005906, 0.8662941742273855, 0.8678649705541804, 0.8694357668809753, 0.8710065632077703, 0.8725773595345652, 0.8741481558613601, 0.875718952188155, 0.8772897485149498, 0.8788605448417447, 0.8804313411685396, 0.8820021374953345, 0.8835729338221294, 0.8851437301489243, 0.8867145264757192, 0.8882853228025142, 0.889856119129309, 0.8914269154561039, 0.8929977117828988, 0.8945685081096937, 0.8961393044364886, 0.8977101007632835, 0.8992808970900784, 0.9008516934168733, 0.9024224897436681, 0.903993286070463, 0.9055640823972579, 0.9071348787240529, 0.9087056750508478, 0.9102764713776427, 0.9118472677044376, 0.9134180640312325, 0.9149888603580274, 0.9165596566848222, 0.9181304530116171, 0.919701249338412, 0.9212720456652069, 0.9228428419920018, 0.9244136383187967, 0.9259844346455917, 0.9275552309723866, 0.9291260272991814, 0.9306968236259763, 0.9322676199527712, 0.9338384162795661, 0.935409212606361, 0.9369800089331559, 0.9385508052599508, 0.9401216015867457, 0.9416923979135406, 0.9432631942403354, 0.9448339905671304, 0.9464047868939253, 0.9479755832207202, 0.9495463795475151, 0.95111717587431, 0.9526879722011049, 0.9542587685278998, 0.9558295648546946, 0.9574003611814895, 0.9589711575082844, 0.9605419538350793, 0.9621127501618743, 0.9636835464886692, 0.9652543428154641, 0.966825139142259, 0.9683959354690538, 0.9699667317958487, 0.9715375281226436, 0.9731083244494385, 0.9746791207762334, 0.9762499171030283, 0.9778207134298232, 0.9793915097566182, 0.9809623060834131, 0.9825331024102079, 0.9841038987370028, 0.9856746950637977, 0.9872454913905926, 0.9888162877173875, 0.9903870840441824, 0.9919578803709773, 0.9935286766977722, 0.995099473024567, 0.9966702693513619, 0.9982410656781568, 0.9998118620049519, 1.0013826583317467, 1.0029534546585415, 1.0045242509853365, 1.0060950473121313, 1.0076658436389263, 1.009236639965721, 1.0108074362925161, 1.012378232619311, 1.013949028946106, 1.0155198252729007, 1.0170906215996955, 1.0186614179264906, 1.0202322142532854, 1.0218030105800804, 1.0233738069068752, 1.0249446032336702, 1.026515399560465, 1.0280861958872598, 1.0296569922140548, 1.0312277885408496, 1.0327985848676446, 1.0343693811944394, 1.0359401775212345, 1.0375109738480293, 1.0390817701748243, 1.040652566501619, 1.0422233628284139, 1.043794159155209, 1.0453649554820037, 1.0469357518087987, 1.0485065481355935, 1.0500773444623885, 1.0516481407891833, 1.0532189371159784, 1.0547897334427732, 1.056360529769568, 1.057931326096363, 1.0595021224231578, 1.0610729187499528, 1.0626437150767476, 1.0642145114035426, 1.0657853077303374, 1.0673561040571322, 1.0689269003839272, 1.070497696710722, 1.072068493037517, 1.0736392893643119, 1.0752100856911069, 1.0767808820179017, 1.0783516783446967, 1.0799224746714915, 1.0814932709982863, 1.0830640673250813, 1.0846348636518761, 1.0862056599786711, 1.087776456305466, 1.089347252632261, 1.0909180489590558, 1.0924888452858508, 1.0940596416126456, 1.0956304379394404, 1.0972012342662354, 1.0987720305930302, 1.1003428269198252, 1.10191362324662, 1.103484419573415, 1.1050552159002098, 1.1066260122270049, 1.1081968085537997, 1.1097676048805944, 1.1113384012073895, 1.1129091975341843, 1.1144799938609793, 1.116050790187774, 1.117621586514569, 1.119192382841364, 1.1207631791681587, 1.1223339754949537, 1.1239047718217485, 1.1254755681485435, 1.1270463644753383, 1.1286171608021334, 1.1301879571289282, 1.1317587534557232, 1.133329549782518, 1.1349003461093128, 1.1364711424361078, 1.1380419387629026, 1.1396127350896976, 1.1411835314164924, 1.1427543277432874, 1.1443251240700822, 1.1458959203968773, 1.147466716723672, 1.1490375130504669, 1.1506083093772619, 1.1521791057040567, 1.1537499020308517, 1.1553206983576465, 1.1568914946844415, 1.1584622910112363, 1.1600330873380311, 1.1616038836648261, 1.163174679991621, 1.164745476318416, 1.1663162726452108, 1.1678870689720058, 1.1694578652988006, 1.1710286616255956, 1.1725994579523904, 1.1741702542791852, 1.1757410506059802, 1.177311846932775, 1.17888264325957, 1.1804534395863648, 1.1820242359131599, 1.1835950322399547, 1.1851658285667497, 1.1867366248935445, 1.1883074212203393, 1.1898782175471343, 1.191449013873929, 1.1930198102007241, 1.194590606527519, 1.196161402854314, 1.1977321991811087, 1.1993029955079035, 1.2008737918346986, 1.2024445881614934, 1.2040153844882884, 1.2055861808150832, 1.2071569771418782, 1.208727773468673, 1.210298569795468, 1.2118693661222628, 1.2134401624490576, 1.2150109587758526, 1.2165817551026474, 1.2181525514294425, 1.2197233477562373, 1.2212941440830323, 1.222864940409827, 1.224435736736622, 1.226006533063417, 1.2275773293902117, 1.2291481257170067, 1.2307189220438015, 1.2322897183705965, 1.2338605146973913, 1.2354313110241864, 1.2370021073509812, 1.238572903677776, 1.240143700004571, 1.2417144963313658, 1.2432852926581608, 1.2448560889849556, 1.2464268853117506, 1.2479976816385454, 1.2495684779653404, 1.2511392742921352, 1.25271007061893, 1.254280866945725, 1.2558516632725198, 1.2574224595993149, 1.2589932559261097, 1.2605640522529047, 1.2621348485796995, 1.2637056449064945, 1.2652764412332893, 1.266847237560084, 1.2684180338868791, 1.269988830213674, 1.271559626540469, 1.2731304228672637, 1.2747012191940588, 1.2762720155208536, 1.2778428118476486, 1.2794136081744434, 1.2809844045012382, 1.2825552008280332, 1.284125997154828, 1.285696793481623, 1.2872675898084178, 1.2888383861352128, 1.2904091824620076, 1.2919799787888024, 1.2935507751155975, 1.2951215714423923, 1.2966923677691873, 1.298263164095982, 1.299833960422777, 1.301404756749572, 1.302975553076367, 1.3045463494031617, 1.3061171457299565, 1.3076879420567515, 1.3092587383835463, 1.3108295347103414, 1.3124003310371362, 1.3139711273639312, 1.315541923690726, 1.317112720017521, 1.3186835163443158, 1.3202543126711106, 1.3218251089979056, 1.3233959053247004, 1.3249667016514954, 1.3265374979782902, 1.3281082943050853, 1.32967909063188, 1.3312498869586749, 1.3328206832854699, 1.3343914796122647, 1.3359622759390597, 1.3375330722658545, 1.3391038685926495, 1.3406746649194443, 1.3422454612462393, 1.3438162575730341, 1.345387053899829, 1.346957850226624, 1.3485286465534188, 1.3500994428802138, 1.3516702392070086, 1.3532410355338036, 1.3548118318605984, 1.3563826281873934, 1.3579534245141882, 1.359524220840983, 1.361095017167778, 1.3626658134945728, 1.3642366098213679, 1.3658074061481627, 1.3673782024749577, 1.3689489988017525, 1.3705197951285473, 1.3720905914553423, 1.373661387782137, 1.375232184108932, 1.376802980435727, 1.378373776762522, 1.3799445730893167, 1.3815153694161117, 1.3830861657429065, 1.3846569620697013, 1.3862277583964964, 1.3877985547232912, 1.3893693510500862, 1.390940147376881, 1.392510943703676, 1.3940817400304708, 1.3956525363572658, 1.3972233326840606, 1.3987941290108554, 1.4003649253376504, 1.4019357216644452, 1.4035065179912403, 1.405077314318035, 1.40664811064483, 1.4082189069716249, 1.40978970329842, 1.4113604996252147, 1.4129312959520095, 1.4145020922788045, 1.4160728886055993, 1.4176436849323943, 1.4192144812591891, 1.4207852775859842, 1.422356073912779, 1.4239268702395738, 1.4254976665663688, 1.4270684628931636, 1.4286392592199586, 1.4302100555467534, 1.4317808518735484, 1.4333516482003432, 1.4349224445271382, 1.436493240853933, 1.4380640371807278, 1.4396348335075229, 1.4412056298343177, 1.4427764261611127, 1.4443472224879075, 1.4459180188147025, 1.4474888151414973, 1.4490596114682923, 1.4506304077950871, 1.452201204121882, 1.453772000448677, 1.4553427967754717, 1.4569135931022668, 1.4584843894290616, 1.4600551857558566, 1.4616259820826514, 1.4631967784094462, 1.4647675747362412, 1.466338371063036, 1.467909167389831, 1.4694799637166258, 1.4710507600434208, 1.4726215563702156, 1.4741923526970107, 1.4757631490238055, 1.4773339453506003, 1.4789047416773953, 1.48047553800419, 1.482046334330985, 1.48361713065778, 1.485187926984575, 1.4867587233113697, 1.4883295196381647, 1.4899003159649595, 1.4914711122917543, 1.4930419086185494, 1.4946127049453442, 1.4961835012721392, 1.497754297598934, 1.499325093925729, 1.5008958902525238, 1.5024666865793186, 1.5040374829061136, 1.5056082792329084, 1.5071790755597034, 1.5087498718864982, 1.5103206682132932, 1.511891464540088, 1.513462260866883, 1.5150330571936779, 1.5166038535204727, 1.5181746498472677, 1.5197454461740625, 1.5213162425008575, 1.5228870388276523, 1.5244578351544473, 1.5260286314812421, 1.5275994278080371, 1.529170224134832, 1.5307410204616267, 1.5323118167884218, 1.5338826131152166, 1.5354534094420116, 1.5370242057688064, 1.5385950020956014, 1.5401657984223962, 1.5417365947491912, 1.543307391075986, 1.5448781874027808, 1.5464489837295758, 1.5480197800563706, 1.5495905763831657, 1.5511613727099605, 1.5527321690367555, 1.5543029653635503, 1.555873761690345, 1.55744455801714, 1.559015354343935, 1.56058615067073, 1.5621569469975247, 1.5637277433243197, 1.5652985396511145, 1.5668693359779096, 1.5684401323047044]; +pub const SIN_F64_VALUES: [f64; 1000] = [0.0, 0.001570795680830879, 0.0031415874858795635, 0.004712371539373423, 0.006283143965558951, 0.007853900888711334, 0.009424638433144006, 0.010995352723218223, 0.012566039883352607, 0.014136696038032734, 0.015707317311820675, 0.01727789982936457, 0.018848439715408175, 0.020418933094800456, 0.02198937609250511, 0.023559764833610154, 0.02513009544333748, 0.026700364047052408, 0.028270566770273252, 0.02984069973868089, 0.03141075907812829, 0.03298074091465013, 0.03455064137447227, 0.0361204565840214, 0.03769018266993454, 0.03925981575906861, 0.040829351978509995, 0.042398787455584105, 0.04396811831786491, 0.0455373406931845, 0.047106450709642665, 0.048675444495616414, 0.050244318179769556, 0.051813067891062235, 0.053381689758760474, 0.054950179912445746, 0.05651853448202453, 0.05808674959773781, 0.059654821390170705, 0.06122274599026192, 0.06279051952931337, 0.06435813813899972, 0.06592559795137785, 0.06749289509889653, 0.0690600257144058, 0.07062698593116667, 0.0721937718828606, 0.07376037970359897, 0.07532680552793272, 0.07689304549086184, 0.07845909572784494, 0.08002495237480871, 0.08159061156815754, 0.08315606944478302, 0.08472132214207345, 0.08628636579792338, 0.08785119655074318, 0.08941581053946852, 0.09098020390356992, 0.09254437278306225, 0.09410831331851433, 0.0956720216510583, 0.09723549392239933, 0.09879872627482501, 0.1003617148512149, 0.10192445579505004, 0.10348694525042253, 0.10504917936204494, 0.10661115427525991, 0.10817286613604961, 0.10973431109104527, 0.11129548528753667, 0.11285638487348168, 0.11441700599751574, 0.11597734480896137, 0.11753739745783766, 0.11909716009486974, 0.1206566288714984, 0.12221579993988944, 0.12377466945294324, 0.12533323356430426, 0.12689148842837042, 0.12844943020030286, 0.13000705503603502, 0.1315643590922825, 0.13312133852655234, 0.1346779894971526, 0.13623430816320173, 0.13779029068463808, 0.13934593322222952, 0.14090123193758267, 0.14245618299315263, 0.14401078255225216, 0.14556502677906147, 0.14711891183863737, 0.148672433896923, 0.15022558912075706, 0.15177837367788347, 0.15333078373696063, 0.15488281546757113, 0.15643446504023087, 0.15798572862639884, 0.1595366023984863, 0.16108708252986642, 0.16263716519488358, 0.16418684656886295, 0.1657361228281197, 0.16728499014996873, 0.1688334447127339, 0.17038148269575742, 0.17192910027940955, 0.1734762936450977, 0.17502305897527606, 0.1765693924534549, 0.17811529026421014, 0.17966074859319253, 0.18120576362713736, 0.18275033155387355, 0.18429444856233332, 0.1858381108425614, 0.18738131458572463, 0.18892405598412113, 0.1904663312311899, 0.19200813652152002, 0.19354946805086026, 0.19509032201612825, 0.19663069461542007, 0.19817058204801935, 0.19970998051440703, 0.20124888621627035, 0.2027872953565125, 0.20432520413926183, 0.20586260876988133, 0.2073995054549779, 0.2089358904024117, 0.21047175982130567, 0.21200710992205463, 0.2135419369163349, 0.21507623701711337, 0.21661000643865713, 0.21814324139654254, 0.2196759381076648, 0.2212080927902471, 0.22273970166385015, 0.22427076094938117, 0.2258012668691037, 0.22733121564664643, 0.22886060350701293, 0.23038942667659057, 0.2319176813831603, 0.23344536385590542, 0.23497247032542135, 0.2364989970237247, 0.23802494018426254, 0.23955029604192185, 0.24107506083303865, 0.24259923079540743, 0.2441228021682903, 0.24564577119242634, 0.2471681341100409, 0.2486898871648548, 0.25021102660209366, 0.25173154866849706, 0.2532514496123281, 0.25477072568338216, 0.25628937313299666, 0.25780738821405985, 0.25932476718102054, 0.26084150628989694, 0.26235760179828604, 0.26387304996537286, 0.2653878470519398, 0.26690198932037557, 0.2684154730346846, 0.2699282944604964, 0.27144044986507426, 0.2729519355173252, 0.2744627476878087, 0.27597288264874575, 0.2774823366740285, 0.2789911060392293, 0.28049918702160953, 0.28200657590012945, 0.28351326895545675, 0.2850192624699761, 0.2865245527277983, 0.2880291360147692, 0.2895330086184791, 0.2910361668282718, 0.292538606935254, 0.294040325232304, 0.29554131801408107, 0.2970415815770349, 0.2985411122194142, 0.30003990624127624, 0.3015379599444957, 0.30303526963277394, 0.3045318316116483, 0.30602764218850076, 0.3075226976725674, 0.3090169943749474, 0.31051052860861234, 0.31200329668841487, 0.3134952949310981, 0.3149865196553048, 0.31647696718158613, 0.31796663383241097, 0.31945551593217497, 0.3209436098072095, 0.3224309117857909, 0.3239174181981494, 0.3254031253764782, 0.32688802965494246, 0.32837212736968857, 0.3298554148588529, 0.331337888462571, 0.3328195445229867, 0.33430037938426077, 0.33578038939258065, 0.33725957089616865, 0.3387379202452914, 0.3402154337922689, 0.3416921078914833, 0.3431679388993882, 0.34464292317451706, 0.34611705707749296, 0.34759033697103703, 0.3490627592199776, 0.350534320191259, 0.352005016253951, 0.35347484377925714, 0.35494379914052415, 0.35641187871325075, 0.3578790788750964, 0.35934539600589066, 0.3608108264876418, 0.3622753667045457, 0.363739013042995, 0.3652017618915878, 0.3666636096411368, 0.368124552684678, 0.36958458741747957, 0.371043710237051, 0.3725019175431518, 0.37395920573780045, 0.3754155712252831, 0.37687101041216264, 0.3783255197072877, 0.3797790955218011, 0.3812317342691491, 0.3826834323650898, 0.38413418622770257, 0.38558399227739654, 0.38703284693691936, 0.38848074663136606, 0.38992768778818826, 0.3913736668372024, 0.39281868021059896, 0.394262724342951, 0.3957057956712232, 0.3971478906347806, 0.3985890056753972, 0.4000291372372648, 0.40146828176700194, 0.40290643571366264, 0.404343595528745, 0.4057797576662, 0.4072149185824403, 0.40864907473634904, 0.4100822225892885, 0.4115143586051088, 0.4129454792501566, 0.41437558099328414, 0.4158046603058574, 0.4172327136617653, 0.4186597375374281, 0.42008572841180625, 0.4215106827664091, 0.4229345970853033, 0.4243574678551219, 0.42577929156507266, 0.427200064706947, 0.4286197837751284, 0.4300384452666011, 0.43145604568095897, 0.43287258152041397, 0.43428804928980463, 0.435702445496605, 0.4371157666509329, 0.43852800926555907, 0.43993916985591514, 0.4413492449401027, 0.4427582310389015, 0.4441661246757786, 0.4455729223768963, 0.44697862067112115, 0.44838321609003223, 0.4497867051679302, 0.4511890844418451, 0.45259035045154544, 0.4539904997395468, 0.4553895288511199, 0.45678743433429947, 0.4581842127398928, 0.45957986062148787, 0.46097437453546236, 0.4623677510409918, 0.4637599867000582, 0.46515107807745837, 0.4665410217408127, 0.4679298142605734, 0.4693174522100329, 0.4707039321653326, 0.4720892507054709, 0.4734734044123121, 0.4748563898705946, 0.4762382036679391, 0.4776188423948575, 0.478998302644761, 0.4803765810139686, 0.4817536741017153, 0.4831295785101609, 0.484504290844398, 0.48587780771246064, 0.4872501257253323, 0.4886212414969549, 0.48999115164423657, 0.4913598527870601, 0.49272734154829156, 0.49409361455378836, 0.4954586684324076, 0.49682249981601456, 0.4981851053394908, 0.49954648164074283, 0.5009066253607098, 0.5022655331433725, 0.5036232016357608, 0.5049796274879629, 0.5063348073531325, 0.5076887378874985, 0.5090414157503713, 0.5103928376041531, 0.5117430001143449, 0.5130918999495547, 0.5144395337815064, 0.5157858982850475, 0.5171309901381572, 0.5184748060219553, 0.5198173426207096, 0.5211585966218443, 0.5224985647159488, 0.523837243596785, 0.5251746299612957, 0.526510720509613, 0.5278455119450665, 0.5291790009741907, 0.530511184306734, 0.5318420586556667, 0.5331716207371886, 0.5344998672707373, 0.5358267949789967, 0.5371524005879043, 0.5384766808266602, 0.5397996324277347, 0.5411212521268759, 0.5424415366631188, 0.5437604827787924, 0.5450780872195286, 0.5463943467342691, 0.5477092580752745, 0.5490228179981318, 0.5503350232617624, 0.5516458706284303, 0.5529553568637499, 0.554263478736694, 0.5555702330196022, 0.556875616488188, 0.5581796259215475, 0.559482258102167, 0.5607835098159312, 0.5620833778521306, 0.5633818590034704, 0.564678950066077, 0.5659746478395076, 0.5672689491267565, 0.5685618507342639, 0.5698533494719238, 0.5711434421530912, 0.5724321255945909, 0.5737193966167244, 0.5750052520432786, 0.5762896887015329, 0.5775727034222676, 0.5788542930397714, 0.5801344543918494, 0.5814131843198306, 0.5826904796685761, 0.5839663372864865, 0.5852407540255101, 0.5865137267411501, 0.5877852522924731, 0.5890553275421161, 0.5903239493562945, 0.5915911146048104, 0.5928568201610592, 0.5941210629020386, 0.595383839708355, 0.5966451474642323, 0.5979049830575188, 0.5991633433796958, 0.600420225325884, 0.6016756257948523, 0.6029295416890247, 0.6041819699144885, 0.6054329073810014, 0.6066823510019997, 0.6079302976946054, 0.6091767443796341, 0.6104216879816026, 0.6116651254287361, 0.6129070536529765, 0.6141474695899893, 0.6153863701791715, 0.6166237523636591, 0.6178596130903343, 0.619093949309834, 0.620326757976556, 0.6215580360486677, 0.6227877804881126, 0.6240159882606185, 0.6252426563357052, 0.6264677816866908, 0.6276913612907006, 0.628913392128673, 0.6301338711853691, 0.6313527954493777, 0.6325701619131244, 0.6337859675728786, 0.6350002094287607, 0.6362128844847494, 0.6374239897486897, 0.6386335222322997, 0.6398414789511784, 0.6410478569248126, 0.6422526531765844, 0.6434558647337789, 0.6446574886275913, 0.6458575218931341, 0.6470559615694443, 0.6482528046994914, 0.6494480483301837, 0.6506416895123764, 0.6518337253008788, 0.6530241527544608, 0.6542129689358611, 0.6554001709117939, 0.6565857557529565, 0.6577697205340359, 0.658952062333717, 0.6601327782346886, 0.6613118653236518, 0.6624893206913265, 0.6636651414324585, 0.664839324645827, 0.6660118674342517, 0.6671827669045997, 0.668352020167793, 0.6695196243388155, 0.67068557653672, 0.6718498738846352, 0.6730125135097733, 0.6741734925434365, 0.6753328081210245, 0.6764904573820413, 0.6776464374701023, 0.6788007455329417, 0.6799533787224192, 0.6811043341945269, 0.6822536091093965, 0.6834012006313064, 0.6845471059286887, 0.685691322174136, 0.6868338465444083, 0.6879746762204404, 0.6891138083873485, 0.6902512402344372, 0.6913869689552065, 0.6925209917473585, 0.693653305812805, 0.6947839083576735, 0.6959127965923144, 0.6970399677313084, 0.6981654189934726, 0.6992891476018682, 0.7004111507838063, 0.7015314257708557, 0.7026499697988492, 0.7037667801078906, 0.7048818539423615, 0.7059951885509279, 0.7071067811865475, 0.708216629106476, 0.7093247295722739, 0.7104310798498135, 0.7115356772092853, 0.7126385189252055, 0.7137396022764213, 0.7148389245461194, 0.7159364830218311, 0.7170322749954402, 0.7181262977631888, 0.7192185486256846, 0.7203090248879069, 0.7213977238592142, 0.7224846428533499, 0.7235697791884493, 0.7246531301870467, 0.7257346931760809, 0.7268144654869029, 0.7278924444552817, 0.7289686274214116, 0.7300430117299178, 0.7311155947298641, 0.7321863737747585, 0.7332553462225601, 0.7343225094356856, 0.7353878607810158, 0.7364513976299024, 0.7375131173581739, 0.7385730173461422, 0.7396310949786097, 0.7406873476448749, 0.7417417727387392, 0.7427943676585137, 0.743845129807025, 0.744894056591622, 0.7459411454241821, 0.7469863937211177, 0.7480297989033825, 0.749071358396478, 0.7501110696304596, 0.7511489300399432, 0.7521849370641114, 0.75321908814672, 0.7542513807361038, 0.7552818122851837, 0.756310380251472, 0.7573370820970796, 0.7583619152887219, 0.7593848772977246, 0.7604059656000309, 0.7614251776762069, 0.7624425110114479, 0.7634579630955851, 0.7644715314230917, 0.7654832134930881, 0.7664930068093498, 0.7675009088803121, 0.7685069172190767, 0.769511029343418, 0.7705132427757893, 0.7715135550433284, 0.7725119636778645, 0.7735084662159233, 0.7745030601987338, 0.7754957431722345, 0.7764865126870786, 0.7774753662986409, 0.7784623015670235, 0.7794473160570615, 0.7804304073383297, 0.7814115729851482, 0.7823908105765881, 0.7833681176964782, 0.7843434919334101, 0.785316930880745, 0.7862884321366189, 0.7872579933039492, 0.7882256119904401, 0.7891912858085884, 0.7901550123756904, 0.7911167893138462, 0.7920766142499671, 0.7930344848157802, 0.7939903986478353, 0.79494435338751, 0.7958963466810158, 0.796846376179404, 0.797794439538571, 0.798740534419265, 0.7996846584870906, 0.8006268094125157, 0.8015669848708765, 0.8025051825423837, 0.8034414001121276, 0.8043756352700845, 0.805307885711122, 0.8062381491350047, 0.8071664232464003, 0.8080927057548846, 0.8090169943749475, 0.8099392868259987, 0.8108595808323734, 0.8117778741233377, 0.812694164433094, 0.813608449500787, 0.8145207270705094, 0.8154309948913069, 0.8163392507171839, 0.8172454923071099, 0.8181497174250234, 0.8190519238398392, 0.8199521093254524, 0.8208502716607448, 0.8217464086295903, 0.8226405180208598, 0.8235325976284275, 0.8244226452511754, 0.8253106586929996, 0.8261966357628152, 0.8270805742745618, 0.8279624720472091, 0.8288423269047619, 0.8297201366762659, 0.8305958991958127, 0.8314696123025452, 0.8323412738406634, 0.833210881659429, 0.8340784336131711, 0.8349439275612917, 0.8358073613682703, 0.8366687329036698, 0.8375280400421418, 0.8383852806634311, 0.8392404526523817, 0.8400935538989419, 0.840944582298169, 0.8417935357502353, 0.8426404121604323, 0.8434852094391766, 0.8443279255020151, 0.8451685582696296, 0.8460071056678422, 0.8468435656276206, 0.8476779360850832, 0.8485102149815037, 0.8493404002633166, 0.8501684898821222, 0.8509944817946918, 0.8518183739629726, 0.8526401643540922, 0.8534598509403649, 0.8542774316992952, 0.8550929046135841, 0.855906267671133, 0.8567175188650495, 0.8575266561936523, 0.8583336776604749, 0.8591385812742725, 0.859941365049025, 0.8607420270039436, 0.8615405651634744, 0.862336977557304, 0.8631312622203637, 0.8639234171928353, 0.8647134405201551, 0.8655013302530189, 0.8662870844473874, 0.86707070116449, 0.8678521784708306, 0.8686315144381912, 0.8694087071436383, 0.8701837546695257, 0.8709566551035008, 0.8717274065385089, 0.8724960070727971, 0.8732624548099202, 0.8740267478587445, 0.8747888843334528, 0.8755488623535492, 0.8763066800438636, 0.877062335534556, 0.8778158269611217, 0.8785671524643954, 0.8793163101905562, 0.880063298291132, 0.8808081149230036, 0.8815507582484103, 0.8822912264349533, 0.883029517655601, 0.8837656300886935, 0.8844995619179461, 0.8852313113324553, 0.8859608765267019, 0.8866882557005565, 0.8874134470592833, 0.8881364488135446, 0.8888572591794054, 0.8895758763783379, 0.8902922986372257, 0.8910065241883678, 0.891718551269484, 0.8924283781237179, 0.8931360029996426, 0.8938414241512638, 0.8945446398380251, 0.8952456483248117, 0.8959444478819547, 0.8966410367852359, 0.8973354133158912, 0.8980275757606156, 0.8987175224115672, 0.8994052515663711, 0.900090761528124, 0.9007740506053981, 0.9014551171122457, 0.9021339593682028, 0.9028105756982937, 0.9034849644330348, 0.904157123908439, 0.9048270524660196, 0.9054947484527943, 0.9061602102212899, 0.9068234361295453, 0.907484424541117, 0.9081431738250813, 0.9087996823560401, 0.9094539485141238, 0.9101059706849958, 0.9107557472598559, 0.9114032766354453, 0.9120485572140494, 0.9126915874035028, 0.9133323656171922, 0.9139708902740612, 0.9146071597986136, 0.9152411726209175, 0.9158729271766096, 0.916502421906898, 0.9171296552585672, 0.9177546256839811, 0.9183773316410876, 0.9189977715934213, 0.9196159440101086, 0.9202318473658704, 0.9208454801410263, 0.9214568408214985, 0.9220659278988153, 0.9226727398701148, 0.923277275238149, 0.9238795325112867, 0.9244795102035183, 0.925077206834458, 0.9256726209293492, 0.9262657510190666, 0.9268565956401209, 0.9274451533346614, 0.9280314226504806, 0.9286154021410173, 0.9291970903653602, 0.9297764858882515, 0.93035358728009, 0.9309283931169358, 0.9315009019805123, 0.932071112458211, 0.9326390231430941, 0.9332046326338985, 0.9337679395350392, 0.934328942456612, 0.9348876400143984, 0.9354440308298674, 0.93599811353018, 0.9365498867481924, 0.9370993491224588, 0.9376464992972356, 0.9381913359224842, 0.9387338576538741, 0.939274063152787, 0.9398119510863198, 0.940347520127287, 0.9408807689542256, 0.9414116962513969, 0.9419403007087906, 0.942466581022128, 0.9429905358928644, 0.9435121640281936, 0.9440314641410498, 0.9445484349501115, 0.9450630751798048, 0.9455753835603061, 0.9460853588275453, 0.9465929997232092, 0.9470983049947443, 0.94760127339536, 0.948101903684032, 0.9486001946255046, 0.9490961449902946, 0.9495897535546937, 0.9500810191007717, 0.95056994041638, 0.9510565162951535, 0.951540745536515, 0.9520226269456766, 0.9525021593336441, 0.9529793415172189, 0.9534541723190013, 0.9539266505673936, 0.9543967750966026, 0.954864544746643, 0.9553299583633393, 0.9557930147983301, 0.9562537129090695, 0.9567120515588305, 0.9571680296167083, 0.9576216459576222, 0.9580728994623192, 0.9585217890173758, 0.9589683135152021, 0.9594124718540429, 0.9598542629379817, 0.9602936856769431, 0.960730738986695, 0.9611654217888519, 0.9615977330108771, 0.9620276715860859, 0.9624552364536473, 0.9628804265585876, 0.9633032408517924, 0.9637236782900097, 0.9641417378358517, 0.9645574184577981, 0.9649707191301983, 0.9653816388332739, 0.9657901765531215, 0.9661963312817147, 0.9666001020169074, 0.967001487762435, 0.9674004875279185, 0.9677971003288655, 0.9681913251866733, 0.9685831611286311, 0.9689726071879229, 0.9693596624036293, 0.9697443258207298, 0.9701265964901059, 0.9705064734685425, 0.970883955818731, 0.9712590426092713, 0.9716317329146739, 0.9720020258153627, 0.9723699203976766, 0.9727354157538723, 0.9730985109821265, 0.9734592051865378, 0.9738174974771289, 0.9741733869698493, 0.9745268727865771, 0.9748779540551212, 0.9752266299092234, 0.9755728994885607, 0.9759167619387474, 0.976258216411337, 0.9765972620638246, 0.9769338980596487, 0.9772681235681935, 0.9775999377647907, 0.9779293398307218, 0.97825632895322, 0.9785809043254721, 0.9789030651466206, 0.9792228106217657, 0.9795401399619674, 0.9798550523842469, 0.980167547111589, 0.9804776233729444, 0.9807852804032304, 0.9810905174433341, 0.9813933337401133, 0.9816937285463989, 0.9819917011209965, 0.9822872507286887, 0.9825803766402359, 0.9828710781323792, 0.9831593544878415, 0.9834452049953297, 0.9837286289495359, 0.9840096256511397, 0.9842881944068098, 0.9845643345292053, 0.9848380453369782, 0.985109326154774, 0.9853781763132342, 0.985644595148998, 0.9859085820047033, 0.9861701362289889, 0.9864292571764954, 0.986685944207868, 0.9869401966897569, 0.9871920139948193, 0.9874413955017208, 0.9876883405951378, 0.9879328486657574, 0.9881749191102805, 0.9884145513314223, 0.9886517447379141, 0.9888864987445046, 0.9891188127719618, 0.989348686247074, 0.9895761186026509, 0.9898011092775262, 0.9900236577165575, 0.9902437633706288, 0.9904614256966512, 0.9906766441575645, 0.9908894182223387, 0.9910997473659748, 0.9913076310695066, 0.9915130688200017, 0.9917160601105629, 0.9919166044403294, 0.9921147013144779, 0.9923103502442241, 0.9925035507468237, 0.9926943023455739, 0.9928826045698137, 0.9930684569549263, 0.9932518590423394, 0.9934328103795266, 0.9936113105200084, 0.9937873590233535, 0.9939609554551797, 0.9941320993871551, 0.9943007903969989, 0.994467028068483, 0.9946308119914323, 0.9947921417617265, 0.9949510169813002, 0.9951074372581447, 0.9952614022063083, 0.9954129114458982, 0.99556196460308, 0.9957085613100801, 0.9958527012051857, 0.9959943839327459, 0.9961336091431725, 0.9962703764929413, 0.9964046856445924, 0.9965365362667313, 0.9966659280340299, 0.9967928606272266, 0.996917333733128, 0.997039347044609, 0.9971589002606139, 0.9972759930861571, 0.9973906252323237, 0.9975027964162702, 0.9976125063612252, 0.9977197547964906, 0.9978245414574415, 0.997926866085527, 0.9980267284282716, 0.9981241282392745, 0.9982190652782118, 0.9983115393108354, 0.998401550108975, 0.9984890974505379, 0.9985741811195097, 0.998656800905955, 0.9987369566060175, 0.9988146480219211, 0.99888987496197, 0.9989626372405491, 0.9990329346781247, 0.999100767101245, 0.9991661343425401, 0.9992290362407229, 0.9992894726405892, 0.9993474433930183, 0.9994029483549729, 0.9994559873895001, 0.9995065603657316, 0.9995546671588833, 0.9996003076502565, 0.999643481727238, 0.9996841892832999, 0.9997224302180006, 0.999758204436984, 0.9997915118519811, 0.999822352380809, 0.9998507259473718, 0.9998766324816606, 0.9999000719197535, 0.9999210442038161, 0.9999395492821014, 0.9999555871089498, 0.9999691576447897, 0.9999802608561371, 0.999988896715596, 0.9999950652018582, 0.9999987662997035]; diff --git a/src/lookup/lookup_table.rs b/src/lookup/lookup_table.rs index 0431979..f32c826 100644 --- a/src/lookup/lookup_table.rs +++ b/src/lookup/lookup_table.rs @@ -1,89 +1,153 @@ -use num_traits::sign::Signed; +use std::f32::consts as f32_consts; +use std::f64::consts as f64_consts; use num_traits::float::{Float, FloatConst}; -use num_traits::NumCast; -use std::ops::{Sub, Rem}; -use serde::{Serialize, Deserialize}; -// use packed_simd::f64x4; +use crate::lookup::TABLE_SIZE; +use crate::lookup::const_tables::*; -#[derive(Default, Debug, Serialize, Deserialize, Clone)] +// This function should never be used in a non-const context. +// It only exists as a workaround for the fact that const fn's cannot use iterators. +const fn make_ordinal( + input: [T; TABLE_SIZE], + mut map_target: [FloatOrd; TABLE_SIZE], +) -> () { + // let mut map_target = [FloatOrd::::new(); TABLE_SIZE]; + let mut index = 0; + while index < TABLE_SIZE { + map_target[index] = FloatOrd(input[index]); + index += 1; + } +} + + +// The following macros are to minimise the amount of boilerplate for static types on the lookup tables. +macro_rules! impl_fbitfbit_lookup_table { + ($key_type:ty, $value_type:ty) => { + impl FloatLookupTable<$key_type, $value_type> { + pub const fn new_const(keys: [$key_type; TABLE_SIZE], values: [$value_type; TABLE_SIZE]) -> Self { + let ord_keys: [FloatOrd<$key_type>; TABLE_SIZE] = [FloatOrd(0.0 as $key_type); TABLE_SIZE]; + make_ordinal(keys, ord_keys); + FloatLookupTable { + keys: ord_keys, + values, + } + } + } + }; +} + +macro_rules! impl_cycling_fbitfbit_lookup_table { + ($key_type:ty, $value_type:ty) => { + impl CyclingFloatLookupTable<$key_type, $value_type> { + pub const fn new_const(keys: [$key_type; TABLE_SIZE], values: [$value_type; TABLE_SIZE], lower_bound: $key_type, upper_bound: $key_type) -> Self { + CyclingFloatLookupTable { + lookup_table: FloatLookupTable::<$key_type, $value_type>::new_const(keys, values), + lower_bound, + upper_bound, + } + } + } + }; +} + + +#[derive(Default, Debug,Clone, Copy, PartialEq, PartialOrd)] +pub struct FloatOrd(pub T); +impl FloatOrd { + pub fn new() -> Self { + FloatOrd(T::zero()) + } +} +impl Eq for FloatOrd {} +impl Ord for FloatOrd { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.partial_cmp(other).unwrap_or(std::cmp::Ordering::Equal) + } +} + + +#[derive(Debug, Clone)] pub struct FloatLookupTable -where T1: Float, - T2: Float, +where + T1: Float, + T2: Float, { - keys: Vec, - values: Vec, + keys: [FloatOrd; TABLE_SIZE], + values: [T2; TABLE_SIZE], } impl FloatLookupTable -where T1: Float, - T2: Float, +where + T1: Float, + T2: Float, { - pub fn new(mut keys: Vec, mut values: Vec) -> Self { - let mut indices: Vec<_> = (0..keys.len()).collect(); - indices.sort_by(|&i, &j| keys[i].partial_cmp(&keys[j]).unwrap()); - for i in 0..keys.len() { - while i != indices[i] { - let swap_index = indices[i]; - keys.swap(i, swap_index); - values.swap(i, swap_index); - indices.swap(i, swap_index); - } + pub fn new(keys: [T1; TABLE_SIZE], values: [T2; TABLE_SIZE]) -> Self { + FloatLookupTable { + keys: keys.map(|key| FloatOrd(key)), + values, } - FloatLookupTable { keys, values } } - #[allow(dead_code)] - pub fn lookup(&self, key: T1) -> T2 { - match self.keys.binary_search_by(|probe| probe.partial_cmp(&key).unwrap()) { - Ok(index) => self.values[index], - Err(index) => { - let upper_key = &self.keys[index]; - let upper_val = &self.values[index]; - let low_index = index - 1; - let lower_key = &self.keys[low_index]; - let lower_val = &self.values[low_index]; - // select nearest neighbour - let diff_upper = (key - *upper_key).abs(); - let diff_lower = (key - *lower_key).abs(); - let mask = diff_lower <= diff_upper; - (*lower_val * T2::from(mask as u8).expect("Failed to unwrap mask")) + - (*upper_val * T2::from(!mask as u8).expect("Failed to unwrap !mask")) + pub fn get_next(&self, key: T1) -> T2 { + let ord_key = FloatOrd(key); + let mut lower_bound = 0; + let mut upper_bound = self.keys.len() - 1; + let mut mid = (lower_bound + upper_bound) / 2; + while upper_bound - lower_bound > 1 { + if self.keys[mid] < ord_key { + lower_bound = mid; + } else { + upper_bound = mid; } + mid = (lower_bound + upper_bound) / 2; } + self.values[mid] + } + + pub fn lookup(&self, key: T1) -> T2 { + self.get_next(key) } } +impl_fbitfbit_lookup_table!(f32, f32); +impl_fbitfbit_lookup_table!(f64, f64); +impl_fbitfbit_lookup_table!(f32, f64); +impl_fbitfbit_lookup_table!(f64, f32); -#[derive(Default, Debug, Serialize, Deserialize, Clone)] +#[derive(Debug, Clone)] pub struct CyclingFloatLookupTable -where T1: Float, - T2: Float, +where + T1: Float, + T2: Float, { lookup_table: FloatLookupTable, lower_bound: T1, upper_bound: T1, - bound_range: T1, } impl CyclingFloatLookupTable -where T1: Float, - T2: Float, +where + T1: Float, + T2: Float, { - pub fn new(keys: Vec, values: Vec, lower_bound: T1, upper_bound: T1) -> Self { + pub fn new(keys: [T1; TABLE_SIZE], values: [T2; TABLE_SIZE], lower_bound: T1, upper_bound: T1) -> Self { CyclingFloatLookupTable { lookup_table: FloatLookupTable::new(keys, values), - lower_bound: lower_bound, - upper_bound: upper_bound, - bound_range: upper_bound - lower_bound, + lower_bound, + upper_bound, } } pub fn lookup(&self, key: T1) -> T2 { - let key = (key % self.bound_range) + self.lower_bound; + let key = (key % (self.upper_bound - self.lower_bound)) + self.lower_bound; self.lookup_table.lookup(key) } } +impl_cycling_fbitfbit_lookup_table!(f32, f32); +impl_cycling_fbitfbit_lookup_table!(f64, f64); +impl_cycling_fbitfbit_lookup_table!(f32, f64); +impl_cycling_fbitfbit_lookup_table!(f64, f32); -#[derive(Default, Debug, Serialize, Deserialize, Clone)] + +#[derive(Debug, Clone)] pub struct EndoSinLookupTable where T: Float + FloatConst, @@ -94,22 +158,6 @@ impl EndoSinLookupTable where T: Float + FloatConst, { - pub fn new(precision: usize) -> Self { - let mut keys = Vec::with_capacity(precision); - let mut values = Vec::with_capacity(precision); - let upper_bound = T::PI(); - let step = T::FRAC_PI_2() / ::from(precision).unwrap(); - for i in 0..precision+1 { - let key = step * ::from(i).unwrap(); - let value = key.sin(); - keys.push(key); - values.push(value); - } - EndoSinLookupTable { - lookup_table: CyclingFloatLookupTable::new(keys, values, T::zero(), upper_bound), - } - } - #[allow(dead_code)] pub fn lookup(&self, key: T) -> T { if key < T::zero() { @@ -123,27 +171,57 @@ where } } } +impl EndoSinLookupTable +{ + pub const fn new() -> Self { + const UPPER_BOUND: f32 = f32_consts::PI; + + EndoSinLookupTable { + lookup_table: CyclingFloatLookupTable::::new_const(SIN_F32_KEYS, SIN_F32_VALUES, 0.0f32, UPPER_BOUND), + } + } +} +impl EndoSinLookupTable +{ + pub const fn new() -> Self { + let upper_bound = f64_consts::PI; + + EndoSinLookupTable { + lookup_table: CyclingFloatLookupTable::::new_const(SIN_F64_KEYS, SIN_F64_VALUES, 0.0f64, upper_bound), + } + } +} -#[derive(Default, Debug, Serialize, Deserialize, Clone)] +#[derive(Debug, Clone)] pub struct EndoCosLookupTable where - T: Float + FloatConst + Signed + Sub + Rem + NumCast + From, + T: Float + FloatConst, { lookup_table: EndoSinLookupTable, } impl EndoCosLookupTable where - T: Float + FloatConst + Signed + Sub + Rem + NumCast + From, + T: Float + FloatConst + std::fmt::Debug, { - pub fn new(precision: usize) -> Self { - EndoCosLookupTable { - lookup_table: EndoSinLookupTable::new(precision), - } - } - #[allow(dead_code)] pub fn lookup(&self, key: T) -> T { self.lookup_table.lookup(key + T::FRAC_PI_2()) } +} +impl EndoCosLookupTable +{ + pub const fn new() -> Self { + EndoCosLookupTable { + lookup_table: EndoSinLookupTable::::new(), + } + } +} +impl EndoCosLookupTable +{ + pub const fn new() -> Self { + EndoCosLookupTable { + lookup_table: EndoSinLookupTable::::new(), + } + } } \ No newline at end of file diff --git a/src/lookup/mod.rs b/src/lookup/mod.rs index ce14091..ada5f00 100644 --- a/src/lookup/mod.rs +++ b/src/lookup/mod.rs @@ -1,4 +1,6 @@ mod const_tables; pub mod lookup_table; -pub use const_tables::*; \ No newline at end of file +pub use const_tables::*; + +include!("config.rs"); \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..32533cc --- /dev/null +++ b/src/main.rs @@ -0,0 +1,12 @@ +use fastmath::LookupCos; + +fn main() { + let x = (-10000..10000) + .map(|a| (a as f64) / 1000.) + .collect::>(); + + let y = x.iter().map(|&x| x.lookup_cos()).collect::>(); + + // to ensure the compiler doesn't optimize away the function call, we print the result + println!("{:?}", y); +} \ No newline at end of file diff --git a/src/tests.rs b/src/tests.rs index f7e78a1..a5629a0 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -39,7 +39,7 @@ mod tests { fn pow2() -> Result<(), Box> { let percentage_error = calculate_percentage_error( &X.iter().map(|&x| x.fast_pow2()).collect::>(), - &X.iter().map(|&x| x.powi(2)).collect::>() + &X.iter().map(|&x| 2.0f64.powf(x)).collect::>() ); assert!(!percentage_error.is_nan(), "fast_pow2 percentage error is NaN"); assert!( @@ -77,6 +77,17 @@ mod tests { "fast_cos percentage error: {0}", percentage_error ); + // lookup + let percentage_error = calculate_percentage_error( + &X.iter().map(|&x| x.lookup_cos()).collect::>(), + &X.iter().map(|&x| x.cos()).collect::>() + ); + assert!(!percentage_error.is_nan(), "lookup_cos percentage error is NaN"); + assert!( + percentage_error < TOLERANCE, + "lookup_cos percentage error: {0}", + percentage_error + ); Ok(()) } @@ -114,7 +125,7 @@ mod tests { assert!( calculate_percentage_error( &X.iter().map(|&x| x.fast_pow2()).collect::>(), - &X.iter().map(|&x| x.powi(2)).collect::>() + &X.iter().map(|&x| 2.0f32.powf(x)).collect::>() ) < TOLERANCE ); Ok(()) @@ -139,6 +150,13 @@ mod tests { &X.iter().map(|&x| x.cos()).collect::>() ) < TOLERANCE ); + // lookup + assert!( + calculate_percentage_error( + &X.iter().map(|&x| x.lookup_cos()).collect::>(), + &X.iter().map(|&x| x.cos()).collect::>() + ) < TOLERANCE + ); Ok(()) }