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?
The matrix
{ { 2, 0 }, { 1, 2 } }
is not symmetric, hence not positive definite. Yet the codedoes 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: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?