cursed_linalg/
expm.rs

1use crate::Inv;
2
3// NB: We use the notation of
4//     https://www.cs.jhu.edu/~misha/ReadingSeminar/Papers/Moler03.pdf.
5//
6//     In particular:
7//
8//         e^{A} ≈ R_pq(A) ≔ [D_pq(A)]⁻¹ N_pq(A)
9//
10//     where
11//
12//         N_pq(A) ≔ Σ_j=0^p [(p + q - j)! p!] / [(p + q)! j! (p - j)!] A^j
13//
14//     and
15//
16//         D_pq(A) ≔ Σ_j=0^q [(p + q - j)! p!] / [(p + q)! j! (q - j)!] (-A)^j.
17
18/// Types that support the matrix exponential $e^{A}$.
19pub trait Expm {
20    /// Errors that can result from the [`expm`] method.
21    ///
22    /// [`expm`]: Expm::expm
23    type Error;
24    /// Type used to represent $e^{A}$ when calling [`expm`].
25    ///
26    /// [`expm`]: Expm::expm
27    type Output;
28
29    /// Returns the matrix exponential $e^{A}$ of a matrix $A$.
30    fn expm(&self) -> Result<Self::Output, Self::Error>;
31}
32
33impl<T> Expm for T
34where
35    T: Inv,
36{
37    type Error = <Self as Inv>::Error;
38    type Output = Self;
39
40    fn expm(&self) -> Result<Self::Output, Self::Error> {
41        // TODO: allow generalizing p, q.
42        todo!()
43    }
44}
45
46// fn pade_dinv()