nearest_spd: Nearest Symmetric Positive-definite Matrix In pracma: Practical Numerical Math Functions

Description

Find nearest (in Frobenius norm) symmetric positive-definite matrix to A.

Usage

 1 nearest_spd(A)

Arguments

 A square numeric matrix.

Details

"The nearest symmetric positive semidefinite matrix in the Frobenius norm to an arbitrary real matrix A is shown to be (B + H)/2, where H is the symmetric polar factor of B=(A + A')/2."
N. J. Highham

Value

Returns a matrix of the same size.

References

Nicholas J. Higham (1988). Computing a nearest symmetric positive semidefinite matrix. Linear Algebra and its Applications. Vol. 103, pp.103-118.

Examples

 1 2 3 4 5 6 7 8 A <- matrix(1:9, 3, 3) B <- nearest_spd(A); B # [,1] [,2] [,3] # [1,] 2.034900 3.202344 4.369788 # [2,] 3.202344 5.039562 6.876781 # [3,] 4.369788 6.876781 9.383774 norm(B - A, type = 'F') #  3.758517

Example output

[,1]     [,2]     [,3]
[1,] 2.034900 3.202344 4.369788
[2,] 3.202344 5.039562 6.876781
[3,] 4.369788 6.876781 9.383774
 3.758517

pracma documentation built on Dec. 11, 2021, 9:57 a.m.