pub struct PowerTables {
pub factr: [[u32; 2]; 256],
pub logint: [f64; 256],
}Expand description
Tables that voxlap precomputes once in initvoxlap and reuses
across every meltsphere / setsphere call.
Both tables are indexed by an integer z ∈ [0, SETSPHMAXRAD):
factr[z]is voxlap’s prime-decomposition cache. Ifzis prime,factr[z][0] == 0. Ifzis composite,factr[z][0] * factr[z][1] == zandfactr[z][0]is the smallest prime divisor ofz.factr[2][0]is forced to 0.logint[z] = ln(z)(natural log) forz >= 1;logint[0]is unused.
Used by PowerTables::build_tempfloatbuf to compute
i^curpow cheaply: prime indices go through exp(ln(i) * curpow), composite indices fold into a multiplication of two
already-computed entries (avoiding pow per index).
Fields§
§factr: [[u32; 2]; 256]§logint: [f64; 256]Implementations§
Source§impl PowerTables
impl PowerTables
Sourcepub fn new() -> Self
pub fn new() -> Self
Mirror of voxlap’s initvoxlap factr-/logint-init block
(voxlap5.c:12224-12236). Sieves the prime decomposition and
fills logint[i] = ln(i).
Sourcepub fn build_tempfloatbuf(&self, hitrad: i32, curpow: f32) -> [f32; 256]
pub fn build_tempfloatbuf(&self, hitrad: i32, curpow: f32) -> [f32; 256]
Build a per-call tempfloatbuf such that
tempfloatbuf[i] ≈ i.powf(curpow) for i ∈ [0, hitrad].
hitrad + 1 is filled with the IEEE-754 max-finite-float
sentinel (0x7f7fffff) so the int-bit-pattern comparisons
in meltsphere terminate cleanly at the table edge.
Port of voxlap5.c:10240-10252. hitrad is clamped to
SETSPHMAXRAD - 2.
Trait Implementations§
Source§impl Clone for PowerTables
impl Clone for PowerTables
Source§fn clone(&self) -> PowerTables
fn clone(&self) -> PowerTables
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PowerTables
impl Debug for PowerTables
Auto Trait Implementations§
impl Freeze for PowerTables
impl RefUnwindSafe for PowerTables
impl Send for PowerTables
impl Sync for PowerTables
impl Unpin for PowerTables
impl UnsafeUnpin for PowerTables
impl UnwindSafe for PowerTables
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more