Skip to content

[performance improvement] Vectorize Rayleigh–Ritz projection fallback#8

Open
singularitti wants to merge 1 commit into
PARSEC-real-space-code:mainfrom
singularitti:main
Open

[performance improvement] Vectorize Rayleigh–Ritz projection fallback#8
singularitti wants to merge 1 commit into
PARSEC-real-space-code:mainfrom
singularitti:main

Conversation

@singularitti

@singularitti singularitti commented May 13, 2026

Copy link
Copy Markdown
Member

Description

This PR improves the MATLAB fallback path for Rayleigh–Ritz projection construction.

Previously, several diagonalization routines built G with nested MATLAB loops:

G(i,j) = Vin(:,i)' * W(:,j);
G(j,i) = G(i,j);

This PR adds rayleighRitzProduct, which computes:

G = Vin' * W;
G = triu(G) + triu(G,1)';

That keeps the same upper-triangle-then-mirror behavior while using MATLAB’s optimized matrix multiplication.

Updated call sites:

  • chefsi1.m
  • chsubsp.m
  • first_filt.m
  • lanczos.m
  • lanczosForChsubsp.m

Validation

  • Confirmed all replaced loops used the same for j=1:m, for i=1:j indexing pattern.
  • Confirmed m matches the relevant projected basis column count: n2 or mev.
  • Confirmed the replacement matches the existing Rayleighritz.c 0-based loop logic.

Add rayleighRitzProduct to replace repeated MATLAB nested loops for
building the Rayleigh-Ritz projection matrix with a BLAS-backed matrix
multiply. Preserve the old upper-triangle-then-mirror behavior so the
MATLAB fallback remains consistent with the existing MEX implementation.
@singularitti singularitti changed the title Vectorize Rayleigh-Ritz projection fallback Vectorize Rayleigh–Ritz projection fallback May 13, 2026
@singularitti singularitti changed the title Vectorize Rayleigh–Ritz projection fallback [performance improvement] Vectorize Rayleigh–Ritz projection fallback May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant