1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use crate::{access, chem::Rate};
use ndarray::Array1;
#[derive(Clone)]
pub struct Reaction {
rate: Rate,
coeffs: Array1<f64>,
}
impl Reaction {
access!(coeffs, Array1<f64>);
#[inline]
#[must_use]
pub fn new(rate: Rate, coeffs: Array1<f64>) -> Self {
debug_assert!(!coeffs.is_empty());
Self { rate, coeffs }
}
#[inline]
#[must_use]
pub fn rate(&self, concs: &Array1<f64>) -> Array1<f64> {
self.rate.rate(concs) * &self.coeffs
}
#[allow(clippy::missing_const_for_fn)]
#[inline]
#[must_use]
pub fn components(self) -> (Rate, Array1<f64>) {
(self.rate, self.coeffs)
}
}