flight_solver/cls/setup/
ls.rs1use nalgebra::{allocator::Allocator, Const, DefaultAllocator, DimMin, DimName};
8
9use crate::cls::types::{Mat, VecN};
10
11pub fn setup_a<const NU: usize, const NV: usize>(b_mat: &Mat<NV, NU>, wv: &VecN<NV>) -> Mat<NV, NU>
15where
16 Const<NV>: DimName + DimMin<Const<NU>, Output = Const<NU>>,
17 Const<NU>: DimName,
18 DefaultAllocator: Allocator<Const<NV>, Const<NU>>
19 + Allocator<Const<NV>, Const<NV>>
20 + Allocator<Const<NU>, Const<NU>>
21 + Allocator<Const<NV>>
22 + Allocator<Const<NU>>,
23{
24 let mut a: Mat<NV, NU> = Mat::zeros();
25 for j in 0..NU {
26 for i in 0..NV {
27 a[(i, j)] = wv[i] * b_mat[(i, j)];
28 }
29 }
30 a
31}
32
33pub fn setup_b<const NV: usize>(v: &VecN<NV>, wv: &VecN<NV>) -> VecN<NV>
35where
36 Const<NV>: DimName,
37 DefaultAllocator: Allocator<Const<NV>>,
38{
39 let mut b: VecN<NV> = VecN::zeros();
40 for i in 0..NV {
41 b[i] = wv[i] * v[i];
42 }
43 b
44}