got test to compile
This commit is contained in:
parent
1fe4ef956b
commit
bdccc81874
|
@ -151,7 +151,7 @@ where
|
|||
/// TODO rewrite comment (current version is taken verbatim from eigen)
|
||||
/// TODO insures that code is correct for complex numbers, eigen uses abs2 and conj
|
||||
/// https://eigen.tuxfamily.org/dox/LLT_8h_source.html
|
||||
pub fn rank_one_update<R2: Dim, C2: Dim, S2>(&mut self, x: &Matrix<N, R2, U1, S2>, sigma: N)
|
||||
pub fn rank_one_update<R2: Dim, S2>(&mut self, x: &Matrix<N, R2, U1, S2>, sigma: N)
|
||||
where
|
||||
S2: Storage<N, R2, U1>,
|
||||
DefaultAllocator: Allocator<N, R2, U1>,
|
||||
|
|
|
@ -79,19 +79,22 @@ macro_rules! gen_tests(
|
|||
}
|
||||
|
||||
fn cholesky_rank_one_update(_n: usize) -> bool {
|
||||
let m = RandomSDP::new(U4, || random::<$scalar>().0).unwrap();
|
||||
let mut m = RandomSDP::new(U4, || random::<$scalar>().0).unwrap();
|
||||
let x = Vector4::<$scalar>::new_random().map(|e| e.0);
|
||||
let sigma : $scalar = 1.;
|
||||
let sigma = random::<$scalar>().0; // random::<$scalar>().0;
|
||||
let one = sigma*0. + 1.; // TODO this is dirty but $scalar appears to not be a scalar type
|
||||
|
||||
// updates cholesky decomposition and reconstructs m
|
||||
let mut chol = m.clone().cholesky().unwrap();
|
||||
chol.rank_one_update(&x, sigma);
|
||||
let m_chol_updated = chol.l() * chol.l().adjoint();
|
||||
|
||||
// updates m manually
|
||||
let m_updated = m + sigma * x * x.transpose();
|
||||
m.syger(sigma, &x, &x, one); // m += sigma * x * x.adjoint()
|
||||
|
||||
// updates cholesky deomposition and reconstruct m
|
||||
let mut chol = m.clone().cholesky().unwrap();
|
||||
chol.rank_one_update(x, sigma);
|
||||
let m_chol_updated = chol.l() * chol.l().transpose();
|
||||
println!("m : {:?}", m);
|
||||
|
||||
relative_eq!(m_updated, m_chol_updated, epsilon = 1.0e-7)
|
||||
relative_eq!(m, m_chol_updated, epsilon = 1.0e-7)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue