int rows = sigma.rows();
double[] sigmaInv = new double[rows];
for (int i = 0; i < rows; ++i)
sigmaInv[i] = 1d / sigma.get(i, i);
DiagonalMatrix sigmaInvMatrix = new DiagonalMatrix(sigmaInv);
UtimesSigmaInv =
Matrices.multiply(U, sigmaInvMatrix);
// Update the field with the new reference to the precomputed matrix
UtimesSigmaInvRef = new WeakReference<Matrix>(UtimesSigmaInv);