pub struct CpuEngine { /* private fields */ }Expand description
CPU compute engine using SIMD and rayon parallelism.
Owns a dedicated rayon::ThreadPool so that the cpu_threads
configuration is always honoured, regardless of whether any other
code has already initialised the rayon global pool. Operations
that benefit from data-parallelism (autocorrelation, dot product
on large vectors) are dispatched onto this pool when the input
exceeds PARALLEL_THRESHOLD.
Implementations§
Source§impl CpuEngine
impl CpuEngine
Sourcepub fn new(config: ComputeConfig) -> Result<Self, ComputeError>
pub fn new(config: ComputeConfig) -> Result<Self, ComputeError>
Creates a new CPU compute engine with the given configuration.
The dedicated thread pool is sized according to
ComputeConfig::cpu_threads (0 = number of available cores).
Sourcepub fn thread_pool(&self) -> &ThreadPool
pub fn thread_pool(&self) -> &ThreadPool
Returns a reference to the owned thread pool.
Sourcepub fn num_threads(&self) -> usize
pub fn num_threads(&self) -> usize
Returns the number of threads in the pool.
Sourcepub fn batch_z_score(&self, values: &[f64]) -> Result<Vec<f64>, ComputeError>
pub fn batch_z_score(&self, values: &[f64]) -> Result<Vec<f64>, ComputeError>
Compute z-scores for a batch of values.
Uses sample variance (Bessel’s correction, n − 1); all arithmetic in
f64. A constant series (zero standard deviation) yields all-zero
z-scores.
§Errors
Returns ComputeError::InsufficientData if values has fewer than
2 elements.
Trait Implementations§
Source§impl ComputeEngine for CpuEngine
impl ComputeEngine for CpuEngine
Source§fn batch_dot_product(&self, a: &[f64], b: &[f64]) -> Result<f64, ComputeError>
fn batch_dot_product(&self, a: &[f64], b: &[f64]) -> Result<f64, ComputeError>
Source§fn batch_matrix_solve(
&self,
a_flat: &[f64],
b: &[f64],
n: usize,
) -> Result<Vec<f64>, ComputeError>
fn batch_matrix_solve( &self, a_flat: &[f64], b: &[f64], n: usize, ) -> Result<Vec<f64>, ComputeError>
Source§fn batch_exponential_smooth(
&self,
values: &[f64],
alpha: f64,
) -> Result<Vec<f64>, ComputeError>
fn batch_exponential_smooth( &self, values: &[f64], alpha: f64, ) -> Result<Vec<f64>, ComputeError>
Source§fn batch_difference(
&self,
values: &[f64],
d: usize,
) -> Result<Vec<f64>, ComputeError>
fn batch_difference( &self, values: &[f64], d: usize, ) -> Result<Vec<f64>, ComputeError>
Source§fn batch_autocorrelation(
&self,
values: &[f64],
max_lag: usize,
) -> Result<Vec<f64>, ComputeError>
fn batch_autocorrelation( &self, values: &[f64], max_lag: usize, ) -> Result<Vec<f64>, ComputeError>
Auto Trait Implementations§
impl !RefUnwindSafe for CpuEngine
impl !UnwindSafe for CpuEngine
impl Freeze for CpuEngine
impl Send for CpuEngine
impl Sync for CpuEngine
impl Unpin for CpuEngine
impl UnsafeUnpin for CpuEngine
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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