Added tests to constant kernel

This commit is contained in:
2020-12-19 13:39:12 +01:00
parent aca4284ddd
commit 2708403923
8 changed files with 113 additions and 11 deletions

View File

@@ -11,6 +11,7 @@ pub use matern32::Matern32;
pub use matern52::Matern52;
pub trait Kernel {
fn k_mat(&self, ts1: &[f64], ts2: Option<&[f64]>) -> ArrayD<f64>;
fn k_diag(&self, ts: &[f64]) -> Array1<f64>;
fn order(&self) -> usize;
fn state_mean(&self, t: f64) -> Array1<f64>;
@@ -18,6 +19,14 @@ pub trait Kernel {
fn measurement_vector(&self) -> Array1<f64>;
fn feedback(&self) -> Array2<f64>;
fn noise_effect(&self) -> Array2<f64> {
unimplemented!();
}
fn noise_density(&self) -> Array2<f64> {
unimplemented!();
}
fn transition(&self, t0: f64, t1: f64) -> Array2<f64> {
let f = self.feedback();
@@ -51,6 +60,10 @@ pub trait Kernel {
}
impl Kernel for Vec<Box<dyn Kernel>> {
fn k_mat(&self, _ts1: &[f64], _ts2: Option<&[f64]>) -> ArrayD<f64> {
unimplemented!();
}
fn k_diag(&self, ts: &[f64]) -> Array1<f64> {
self.iter()
.fold(Array1::zeros(ts.len()), |k_diag: Array1<f64>, kernel| {