use twine_core::model::Snapshot;
pub trait EquationProblem<const N: usize> {
type Input;
type Output;
type InputError: std::error::Error + Send + Sync + 'static;
type ResidualError: std::error::Error + Send + Sync + 'static;
fn input(&self, x: &[f64; N]) -> Result<Self::Input, Self::InputError>;
fn residuals(
&self,
input: &Self::Input,
output: &Self::Output,
) -> Result<[f64; N], Self::ResidualError>;
fn residuals_from_snapshot(
&self,
snap: &Snapshot<Self::Input, Self::Output>,
) -> Result<[f64; N], Self::ResidualError> {
self.residuals(&snap.input, &snap.output)
}
}