Fix spectral clustering failure on MKL build #168
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed the spectral clustering test failure that occurred on CRAN's MKL (Intel Math Kernel Library) builds.
Problem
The test for
SpectralClusteringwas failing on MKL builds becauseeigen()returns eigenvectors in different column orders across BLAS implementations when eigenvalues are equal or very close. The test data contained many identical eigenvalues (e.g., 24 eigenvalues all equal to 1.1), causing different orderings.Solution
Modified the test in
tests/testthat/test-spectral_clustering.Rto verify mathematical properties rather than exact matrix equality:t(M) %*% M = I)This approach is robust across all BLAS implementations because it doesn't depend on column ordering while still verifying correctness.
Testing
Fixes #167
Original prompt
This section details on the original issue you should resolve
<issue_title>Spectral clustering failing on MKL</issue_title>
<issue_description>Spectral clustering is working fine on most platforms, but on CRAN's MKL build it fails with: