use super::context::Bounds;
use crate::structures::numerics::culvert::constants;
use numr::dtype::DType;
use numr::runtime::Runtime;
use numr::tensor::Tensor;
pub(crate) struct SeriesTensors<R: Runtime<DType = DType>> {
pub(crate) asin: Vec<Bounds<R>>,
pub(crate) area: Vec<Bounds<R>>,
pub(crate) moment: Vec<Bounds<R>>,
}
impl<R: Runtime<DType = DType>> SeriesTensors<R> {
pub(crate) fn constant(m: usize, device: &R::Device) -> numr::error::Result<Self> {
let bounds = |table: &[[u64; 2]]| -> numr::error::Result<Vec<Bounds<R>>> {
table
.iter()
.map(|[lower, upper]| {
Ok([
Tensor::<R>::full_scalar(&[m], DType::F64, f64::from_bits(*lower), device)?,
Tensor::<R>::full_scalar(&[m], DType::F64, f64::from_bits(*upper), device)?,
])
})
.collect()
};
Ok(Self {
asin: bounds(&constants::ASIN)?,
area: bounds(&constants::AREA)?,
moment: bounds(&constants::MOMENT)?,
})
}
}