def chol(A):
A = np.array(A)<EOL>assert A.shape[<NUM_LIT:0>] == A.shape[<NUM_LIT:1>], "<STR_LIT>"<EOL>L = [[<NUM_LIT:0.0>] * len(A) for _ in range(len(A))]<EOL>for i in range(len(A)):<EOL><INDENT>for j in range(i + <NUM_LIT:1>):<EOL><INDENT>s = sum(L[i][k] * L[j][k] for k in range(j))<EOL>L[i][j] = (<EOL>(A[i][i] - s) ** <NUM_LIT:0.5> if (i == j) else (<NUM_LIT:1.0> / L[j][j] * (A[i][j] - s))<EOL>)<EOL><DEDENT><DEDENT>return np.array(L)<EOL>
Calculate the lower triangular matrix of the Cholesky decomposition of
a symmetric, positive-definite matrix.