use alloc::vec::Vec;
use super::stl_result::strength;
use super::Float;
#[derive(Clone, Debug)]
pub struct MstlResult<T: Float = f32> {
pub(crate) seasonal: Vec<Vec<T>>,
pub(crate) trend: Vec<T>,
pub(crate) remainder: Vec<T>,
}
impl<T: Float> MstlResult<T> {
pub fn seasonal(&self) -> &[Vec<T>] {
&self.seasonal[..]
}
pub fn trend(&self) -> &[T] {
&self.trend
}
pub fn remainder(&self) -> &[T] {
&self.remainder
}
pub fn seasonal_strength(&self) -> Vec<f64> {
self.seasonal()
.iter()
.map(|s| strength(s, self.remainder()))
.collect()
}
pub fn trend_strength(&self) -> f64 {
strength(self.trend(), self.remainder())
}
pub fn into_parts(self) -> (Vec<Vec<T>>, Vec<T>, Vec<T>) {
(self.seasonal, self.trend, self.remainder)
}
}