use crate::lane::Lane;
use crate::mode::Rate;
use multidouble::field::Fl;
pub type State<T, const B: usize> = Vec<Fl<T, B>>;
pub struct Work<T: Lane, const B: usize> {
pub kt: usize,
pub c: Vec<Vec<Fl<T, B>>>,
pub aux: Vec<Vec<Fl<T, B>>>,
pub rate: Rate,
}
impl<T: Lane, const B: usize> Work<T, B> {
pub fn new(nf: usize, naux: usize, kt: usize) -> Self {
let v = || vec![Fl::<T, B>::zero(); kt + 2];
Work {
kt,
c: (0..nf).map(|_| v()).collect(),
aux: (0..naux).map(|_| v()).collect(),
rate: Rate::ZERO,
}
}
}
pub trait Equations<const B: usize>: Sync {
const NF: usize;
const NL: usize;
const NR: usize;
const NG: usize = 0;
const NAUX: usize = 0;
const POINTWISE: bool = false;
type Prep: Sync + Default;
fn prepare(&self, _zh: &[f64], _zl: &[f64]) -> Self::Prep {
Self::Prep::default()
}
fn prepare_rate(&self, zh: &[f64], zl: &[f64], _rate: Rate) -> Self::Prep {
self.prepare(zh, zl)
}
fn try_prepare(&self, zh: &[f64], zl: &[f64]) -> Result<Self::Prep, String> {
Ok(self.prepare(zh, zl))
}
fn try_prepare_rate(&self, zh: &[f64], zl: &[f64], rate: Rate) -> Result<Self::Prep, String> {
Ok(self.prepare_rate(zh, zl, rate))
}
fn taylor_coeffs<T: Lane>(&self, x0: f64, g: &[T], w: &mut Work<T, B>);
fn left_state<T: Lane>(&self, x: f64, data: &[Fl<T, B>], g: &[T], prep: &Self::Prep) -> State<T, B>;
fn right_state<T: Lane>(&self, x: f64, data: &[Fl<T, B>], g: &[T], prep: &Self::Prep) -> State<T, B>;
}