File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -51,14 +51,17 @@ where
5151}
5252
5353/// Random Hermite Positive-definite matrix
54+ ///
55+ /// - Eigenvalue of matrix must be larger than 1 (thus non-singular)
56+ ///
5457pub fn random_hpd < A , S > ( n : usize ) -> ArrayBase < S , Ix2 >
5558where
5659 A : RandNormal + Conjugate + LinalgScalar ,
5760 S : DataOwned < Elem = A > + DataMut ,
5861{
5962 let a: Array2 < A > = random ( ( n, n) ) ;
6063 let ah: Array2 < A > = conjugate ( & a) ;
61- replicate ( & ah. dot ( & a) )
64+ ArrayBase :: eye ( n ) + & ah. dot ( & a)
6265}
6366
6467/// construct matrix from diag
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ fn solve_random_t() {
2323fn rcond ( ) {
2424 macro_rules! rcond {
2525 ( $elem: ty, $rows: expr, $atol: expr) => {
26- let a: Array2 <$elem> = random ( ( $rows, $rows ) ) ;
26+ let a: Array2 <$elem> = random_hpd ( $rows) ;
2727 let rcond = 1. / ( a. opnorm_one( ) . unwrap( ) * a. inv( ) . unwrap( ) . opnorm_one( ) . unwrap( ) ) ;
2828 assert_aclose!( a. rcond( ) . unwrap( ) , rcond, $atol) ;
2929 assert_aclose!( a. rcond_into( ) . unwrap( ) , rcond, $atol) ;
You can’t perform that action at this time.
0 commit comments