code: public void setToInverseL( double a[] ) {
          // TODO reorder these operations to avoid cache misses
          
          // inverts the lower triangular system and saves the result
          // in the upper triangle to minimize cache misses
          for( int i =0; i < n; i++ ) {
              double el_ii = t[i*n+i];
              for( int j = 0; j <= i; j++ ) {
                  double sum = (i==j) ? 1.0 : 0;
                  for( int k=i-1; k >=j; k-- ) {
                      sum -= t[i*n+k]*a[j*n+k];
                  }
                  a[j*n+i] = sum / el_ii;
              }
          }
          // solve the system and handle the previous solution being in the upper triangle
          // takes advantage of symmetry
          for( int i=n-1; i>=0; i-- ) {
              double el_ii = t[i*n+i];
  
              for( int j = 0; j <= i; j++ ) {
                  double sum = (i<j) ? 0 : a[j*n+i];
                  for( int k=i+1;k<n;k++) {
                      sum -= t[k*n+i]*a[j*n+k];
                  }
                  a[i*n+j] = a[j*n+i] = sum / el_ii;
              }
          }
      }
docs: Sets the matrix to the inverse using a lower triangular matrix.