Skip to content

cholesky decomposition fails for certain cases #207

@rakki-18

Description

@rakki-18

I was trying to benchmark the Cholesky decomposition method and noticed that the method gives error for certain matrices.
Script to reproduce the error:

	|aPMMatrix expected|
	aPMMatrix := PMMatrix rows: #( #(4 20 8 2 18) #(20 116 80 18 126) #(8 80 117 32 135) #(2 18 32 73 109) #(18 126 135 109 272)).
        expected := PMMatrix rows: #( #(2 10 4 1 9) #(0 4 10 2 9) #(0 0 1 8 9) #(0 0 0 2 5) #(0 0 0 0 2)).
 
	aPMMatrix = (expected transpose * expected). "true"
        aPMMatrix choleskyDecomposition 

Calculating Cholesky decomposition for the above aPMMatrix gives the error, sqrt undefined for number less than zero.

diagonalValue := ((self at: j at: j) - rowSum) sqrt.

This line in the Cholesky decomposition method is causing the error where it is trying to calculate the square root of a negative number.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions