Skip to content

Commit 993e047

Browse files
committed
Add identity matrix for random_hpd
1 parent 7137414 commit 993e047

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/generate.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff 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+
///
5457
pub fn random_hpd<A, S>(n: usize) -> ArrayBase<S, Ix2>
5558
where
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

0 commit comments

Comments
 (0)