Drop second attempt at static matrices

I couldn't get this one working, and the first attempt seems fine.
This commit is contained in:
Aaron Fenyes 2024-08-13 13:29:58 -07:00
parent fb51e00503
commit d864ab5abe

View File

@ -1,7 +1,5 @@
use nalgebra::{*, allocator::Allocator}; use nalgebra::{*, allocator::Allocator};
use std::f64::consts::{PI, E}; use std::f64::consts::{PI, E};
/*use std::ops::Sub;*/
/*use typenum::{B1, UInt, UTerm};*/
/* dynamic matrices */ /* dynamic matrices */
pub fn rand_eigval_series(dim: usize, time_res: usize) -> Vec<OVector<Complex<f64>, Dyn>> { pub fn rand_eigval_series(dim: usize, time_res: usize) -> Vec<OVector<Complex<f64>, Dyn>> {
@ -105,42 +103,3 @@ pub fn rand_eigval_series(dim: usize, time_res: usize) -> Vec<OVector<Complex<f6
} }
eigval_series eigval_series
}*/ }*/
/* another attempt at static matrices. i couldn't get the types to work out */
/*pub fn random_eigval_series<const N: usize>(time_res: usize) -> Vec<OVector<Complex<f64>, Const<N>>>
where
Const<N>: ToTypenum,
<Const<N> as ToTypenum>::Typenum: Sub<UInt<UTerm, B1>>,
<<Const<N> as ToTypenum>::Typenum as Sub<UInt<UTerm, B1>>>::Output: ToConst
{
// initialize the random matrix
/*let mut rand_mat = SMatrix::<f64, N, N>::zeros();
for n in 0..N*N {
rand_mat[n] = E*((n*n) as f64) % 2.0 - 1.0;
}*/
let rand_mat = OMatrix::<f64, Const<N>, Const<N>>::from_fn(|j, k| {
let n = j*N + k;
E*((n*n) as f64) % 2.0 - 1.0
});
// initialize the rotation step
let mut rot_step = OMatrix::<f64, Const<N>, Const<N>>::identity();
let max_freq = 4;
for n in (0..N).step_by(2) {
let ang = PI * ((n % max_freq) as f64) / (time_res as f64);
let ang_cos = ang.cos();
let ang_sin = ang.sin();
rot_step[(n, n)] = ang_cos;
rot_step[(n+1, n)] = ang_sin;
rot_step[(n, n+1)] = -ang_sin;
rot_step[(n+1, n+1)] = ang_cos;
}
// find the eigenvalues
let mut eigvals = Vec::<OVector<Complex<f64>, Const<N>>>::with_capacity(time_res);
unsafe { eigvals.set_len(time_res); }
for t in 0..time_res {
eigvals[t] = rand_mat.complex_eigenvalues();
}
eigvals
}*/