Change ns and xs to be a vec instead of array

This commit is contained in:
2020-12-14 23:15:21 +01:00
parent 63dccce7d0
commit 113168d7d0

View File

@@ -14,8 +14,8 @@ pub struct RecursiveFitter {
ts: Vec<f64>, ts: Vec<f64>,
ms: Vec<f64>, // TODO Replace with a vec ms: Vec<f64>, // TODO Replace with a vec
vs: Array1<f64>, // TODO Replace with a vec vs: Array1<f64>, // TODO Replace with a vec
ns: ArrayD<f64>, // TODO Replace with a vec ns: Vec<f64>, // TODO Replace with a vec
xs: ArrayD<f64>, // TODO Replace with a vec xs: Vec<f64>, // TODO Replace with a vec
is_fitted: bool, is_fitted: bool,
h: Array1<f64>, h: Array1<f64>,
i: Array2<f64>, i: Array2<f64>,
@@ -40,8 +40,8 @@ impl RecursiveFitter {
ts: Vec::new(), ts: Vec::new(),
ms: Vec::new(), ms: Vec::new(),
vs: Array1::zeros(0), vs: Array1::zeros(0),
ns: Array::zeros(0).into_dyn(), ns: Vec::new(),
xs: Array::zeros(0).into_dyn(), xs: Vec::new(),
is_fitted: true, is_fitted: true,
h, h,
i: Array::eye(m), i: Array::eye(m),
@@ -99,13 +99,11 @@ impl Fitter for RecursiveFitter {
} }
// Usual variables. // Usual variables.
let zeros = Array::zeros(n_new).into_dyn();
self.ts.extend(self.ts_new.iter()); self.ts.extend(self.ts_new.iter());
self.ms.extend(iter::repeat(0.0).take(n_new)); self.ms.extend(iter::repeat(0.0).take(n_new));
self.vs = stack![Axis(0), self.vs, self.kernel.k_diag(&self.ts_new)]; self.vs = stack![Axis(0), self.vs, self.kernel.k_diag(&self.ts_new)];
self.ns = stack![Axis(0), self.ns, zeros]; self.ns.extend(iter::repeat(0.0).take(n_new));
self.xs = stack![Axis(0), self.xs, zeros]; self.xs.extend(iter::repeat(0.0).take(n_new));
// Initialize the predictive, filtering and smoothing distributions. // Initialize the predictive, filtering and smoothing distributions.
for t in &self.ts_new { for t in &self.ts_new {