Skip to main content

diffsol/context/
nalgebra.rs

1use crate::DiffsolError;
2
3/// Context for the nalgebra backend.
4///
5/// Batching (`nbatch > 1`) is not supported by this backend; use the CUDA
6/// backend instead.
7#[derive(Copy, Clone, Debug, PartialEq)]
8pub struct NalgebraContext {}
9
10impl NalgebraContext {
11    pub fn new() -> Self {
12        Self {}
13    }
14}
15
16impl Default for NalgebraContext {
17    fn default() -> Self {
18        Self::new()
19    }
20}
21
22impl crate::Context for NalgebraContext {
23    fn clone_with_nbatch(&self, nbatch: usize) -> Result<Self, DiffsolError> {
24        if nbatch != 1 {
25            Err(DiffsolError::Other(
26                "NalgebraContext does not support batching (nbatch > 1). Use the CUDA backend instead."
27                    .to_string(),
28            ))
29        } else {
30            Ok(Self {})
31        }
32    }
33}