From 5aa2527f533c75cafe1daf9c030f4f465f0e291f Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 28 Sep 2020 14:41:12 -0400 Subject: [PATCH 1/1] mjo/ldlt.py: avoid some intermediate variables in ldlt_fast(). --- mjo/ldlt.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mjo/ldlt.py b/mjo/ldlt.py index d113df3..4561528 100644 --- a/mjo/ldlt.py +++ b/mjo/ldlt.py @@ -195,18 +195,15 @@ def ldlt_fast(A): # Update the "next" block of A that we'll work on during # the following iteration. I think it's faster to get the # entries of a row than a column here? - v = vector(ring, A[k,k+1:n].list()) - b = v.column()*v.row()/alpha for i in range(n-k-1): for j in range(i+1): - # Something goes wrong if I try to access the kth row/column - # of A to save the intermediate "b" here... - A[k+1+i,k+1+j] = A[k+1+i,k+1+j] - b[i,j] + A[k+1+i,k+1+j] = A[k+1+i,k+1+j] - A[k,k+1+i]*A[k,k+1+j]/alpha A[k+1+j,k+1+i] = A[k+1+i,k+1+j] # keep it symmetric! # Store the "new" (kth) column of L. for i in range(n-k-1): - L[k+i+1,k] = v[i]/alpha + # Set the lower-left "half" from the upper-right "half"... + L[k+i+1,k] = A[k,k+1+i]/alpha I = A.matrix_space().identity_matrix() P = matrix.column( I.row(p[j]) for j in range(n) ) -- 2.44.2