RosettaCodeData/Task/Cholesky-decomposition/Sidef/cholesky-decomposition-1.sidef
2016-12-05 23:44:36 +01:00

13 lines
367 B
Text

func cholesky(matrix) {
var chol = matrix.len.of { matrix.len.of(0) }
for row in ^matrix {
for col in (0..row) {
var x = matrix[row][col]
for i in (0..col) {
x -= (chol[row][i] * chol[col][i])
}
chol[row][col] = (row == col ? x.sqrt : x/chol[col][col])
}
}
return chol
}