added real constraint on sigma
This commit is contained in:
parent
e49ecdc0a1
commit
80d2efcb5d
|
@ -8,6 +8,7 @@ use crate::base::{DefaultAllocator, Matrix, MatrixMN, MatrixN, SquareMatrix};
|
||||||
use crate::constraint::{SameNumberOfRows, ShapeConstraint};
|
use crate::constraint::{SameNumberOfRows, ShapeConstraint};
|
||||||
use crate::dimension::{Dim, DimSub, Dynamic, U1};
|
use crate::dimension::{Dim, DimSub, Dynamic, U1};
|
||||||
use crate::storage::{Storage, StorageMut};
|
use crate::storage::{Storage, StorageMut};
|
||||||
|
use crate::RealField;
|
||||||
|
|
||||||
/// The Cholesky decomposition of a symmetric-definite-positive matrix.
|
/// The Cholesky decomposition of a symmetric-definite-positive matrix.
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
|
@ -151,12 +152,18 @@ where
|
||||||
/// TODO rewrite comment (current version is taken verbatim from eigen)
|
/// TODO rewrite comment (current version is taken verbatim from eigen)
|
||||||
/// TODO insures that code is correct for complex numbers, eigen uses abs2 and conj
|
/// TODO insures that code is correct for complex numbers, eigen uses abs2 and conj
|
||||||
/// https://eigen.tuxfamily.org/dox/LLT_8h_source.html
|
/// https://eigen.tuxfamily.org/dox/LLT_8h_source.html
|
||||||
pub fn rank_one_update<R2: Dim, S2>(&mut self, x: &Matrix<N, R2, U1, S2>, sigma: N)
|
/// TODO insure that sigma is a real
|
||||||
where
|
pub fn rank_one_update<R2: Dim, S2, N2: RealField>(
|
||||||
|
&mut self,
|
||||||
|
x: &Matrix<N, R2, U1, S2>,
|
||||||
|
sigma: N2,
|
||||||
|
) where
|
||||||
|
N: From<N2>,
|
||||||
S2: Storage<N, R2, U1>,
|
S2: Storage<N, R2, U1>,
|
||||||
DefaultAllocator: Allocator<N, R2, U1>,
|
DefaultAllocator: Allocator<N, R2, U1>,
|
||||||
ShapeConstraint: SameNumberOfRows<R2, D>,
|
ShapeConstraint: SameNumberOfRows<R2, D>,
|
||||||
{
|
{
|
||||||
|
let sigma = <N>::from(sigma);
|
||||||
let n = x.nrows();
|
let n = x.nrows();
|
||||||
let mut temp = x.clone_owned();
|
let mut temp = x.clone_owned();
|
||||||
for k in 0..n {
|
for k in 0..n {
|
||||||
|
|
|
@ -83,9 +83,12 @@ macro_rules! gen_tests(
|
||||||
use nalgebra::Vector3;
|
use nalgebra::Vector3;
|
||||||
let mut m = RandomSDP::new(U3, || random::<$scalar>().0).unwrap();
|
let mut m = RandomSDP::new(U3, || random::<$scalar>().0).unwrap();
|
||||||
let x = Vector3::<$scalar>::new_random().map(|e| e.0);
|
let x = Vector3::<$scalar>::new_random().map(|e| e.0);
|
||||||
let mut 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 in this file
|
// TODO this is dirty but $scalar appears to not be a scalar type in this file
|
||||||
sigma = one; // TODO placeholder
|
let zero = random::<$scalar>().0 * 0.;
|
||||||
|
let one = zero + 1.;
|
||||||
|
let sigma = random::<f64>(); // needs to be a real
|
||||||
|
let sigma_scalar = zero + sigma;
|
||||||
|
|
||||||
// updates cholesky decomposition and reconstructs m
|
// updates cholesky decomposition and reconstructs m
|
||||||
let mut chol = m.clone().cholesky().unwrap();
|
let mut chol = m.clone().cholesky().unwrap();
|
||||||
|
@ -93,7 +96,7 @@ macro_rules! gen_tests(
|
||||||
let m_chol_updated = chol.l() * chol.l().adjoint();
|
let m_chol_updated = chol.l() * chol.l().adjoint();
|
||||||
|
|
||||||
// updates m manually
|
// updates m manually
|
||||||
m.ger(sigma, &x, &x, one); // m += sigma * x * x.adjoint()
|
m.ger(sigma_scalar, &x, &x, one); // m += sigma * x * x.adjoint()
|
||||||
|
|
||||||
println!("sigma : {}", sigma);
|
println!("sigma : {}", sigma);
|
||||||
println!("m updated : {}", m);
|
println!("m updated : {}", m);
|
||||||
|
|
Loading…
Reference in New Issue