differential_equations/linalg/util.rs
1//! Linear algebra helper operations
2
3use crate::traits::{Real, State};
4
5pub fn dot<T, Y>(a: &Y, b: &Y) -> T
6where
7 T: Real,
8 Y: State<T>,
9{
10 a.dot(b)
11}
12
13pub fn norm<T, Y>(a: Y) -> T
14where
15 T: Real,
16 Y: State<T>,
17{
18 a.norm_squared().sqrt()
19}
20
21pub fn component_multiply<T, Y>(a: &Y, b: &Y) -> Y
22where
23 T: Real,
24 Y: State<T>,
25{
26 a.component_mul(b)
27}
28
29pub fn component_square<T: Real, Y: State<T>>(v: &Y) -> Y {
30 v.component_mul(v)
31}