You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NOT bitwise identical: this commit reassociates floating-point products,
so results differ from the original at the ~1e-15 relative level (verified
below). The algorithm and the physics are unchanged.
(d) Replace the nl x nl buffer product with an nl x ns contraction.
Original:
v42 := lamat * maux (nl x nl dgemm, reuses v42 as buffer)
cf := v42 * v3^T (nl x ns)
New (associativity Lambda*M^-1*v3^T = Lambda*(M^-1*v3^T)):
tmp := maux * v3^T (nl x ns)
cf := lamat * tmp (nl x ns)
Removes the nl x nl buffer and lowers that stage from O(N^6) to O(N^5).
tmp is nl x ns = O(N^3), negligible.
(e) Optional argument use_v4_symmetry (default .false. -> old safe behavior).
When .true. (standard case: v4 permutation-symmetric after
ApplySymmetryToTensor4 / use_symmetries=True), the reordered copy
v42(ja,ka)=v4(w,z,x,y) equals the plain column-major reshape of v4, so
v4 is fed directly to the first dgemm (lda=nl) and the whole nl x nl
v42 array is never allocated. INVALID for use_symmetries=False, hence
it is opt-in only, never the silent default. The optional argument is
interface-compatible: existing callers that omit it are unaffected.
Peak internal nl x nl arrays: default path lamat+v42+maux (3 units, v42
freed right after the first dgemm); symmetry path lamat+maux (2 units).
Standalone test (n_mode=6, symmetrized v3/v4), vs original:
default path : max abs diff 2.1e-16, max elementwise rel diff 7.6e-15
symmetry path: max abs diff 1.1e-16, max elementwise rel diff 1.8e-14
Both far below the 1e-12 tolerance.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
0 commit comments