Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cholesky does not throw error on asymmetric matrix #1029

Open
antonott opened this issue Sep 1, 2023 · 0 comments
Open

Cholesky does not throw error on asymmetric matrix #1029

antonott opened this issue Sep 1, 2023 · 0 comments

Comments

@antonott
Copy link

antonott commented Sep 1, 2023

The matrix { { 2, 0 }, { 1, 2 } } is not symmetric, hence not positive definite. Yet the code

using MathNet.Numerics.LinearAlgebra;
var m = Matrix<double>.Build.DenseOfArray(new double[,] { { 2, 0 }, { 1, 2 } });
m.Cholesky();

does not produce an error.

This seems like a bug to me, since the Cholesky decomposition is typically only defined for (symmetric) positive definite matrices, and especially since the documentation for the Cholesky<T> class says:

The computation of the Cholesky factorization is done at construction time. If the matrix is not symmetric or positive definite, the constructor will throw an exception.

I am not sure what precise algorithm is used for computing the factorization, but apparently it does not (always) catch non-symmetry. Maybe an explicit symmetry check is needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant