use std::rc::Rc;
pub type CouplingFn = dyn Fn(&[f64], &mut [f64]);
pub struct Coupling {
source: String,
target: String,
apply: Rc<CouplingFn>,
}
impl Coupling {
pub fn new<F>(source: &str, target: &str, apply: F) -> Self
where
F: Fn(&[f64], &mut [f64]) + 'static,
{
Self {
source: source.to_string(),
target: target.to_string(),
apply: Rc::new(apply),
}
}
pub fn source(&self) -> &str {
&self.source
}
pub fn target(&self) -> &str {
&self.target
}
pub fn apply(&self, src: &[f64], input: &mut [f64]) {
(self.apply)(src, input);
}
}