use crate::dim::Dim;
use crate::matrix::FdMatrix;
use super::random_depth_core;
#[must_use = "expensive computation whose result should not be discarded"]
pub fn random_projection_1d(data_obj: &FdMatrix, data_ori: &FdMatrix, nproj: usize) -> Vec<f64> {
random_projection_1d_seeded(data_obj, data_ori, nproj, None)
}
#[must_use = "expensive computation whose result should not be discarded"]
pub fn random_projection_1d_seeded(
data_obj: &FdMatrix,
data_ori: &FdMatrix,
nproj: usize,
seed: Option<u64>,
) -> Vec<f64> {
random_depth_core(
data_obj,
data_ori,
nproj,
seed,
0.0,
|acc, d| acc + d,
|acc, n| acc / n as f64,
)
}
#[must_use = "expensive computation whose result should not be discarded"]
pub fn random_projection(
data_obj: &FdMatrix,
data_ori: &FdMatrix,
nproj: usize,
dim: Dim,
) -> Vec<f64> {
match dim {
Dim::One | Dim::Two => random_projection_1d(data_obj, data_ori, nproj),
}
}
#[deprecated(
since = "0.30.0",
note = "redundant with `random_projection(…, Dim::Two)`; body just forwards to `random_projection_1d`"
)]
#[must_use = "expensive computation whose result should not be discarded"]
pub fn random_projection_2d(data_obj: &FdMatrix, data_ori: &FdMatrix, nproj: usize) -> Vec<f64> {
random_projection_1d(data_obj, data_ori, nproj)
}