Skip to content

Add TruncationUnion to support supplying minimal ranks#183

Merged
lkdvos merged 9 commits intomainfrom
ld-truncmin
Mar 11, 2026
Merged

Add TruncationUnion to support supplying minimal ranks#183
lkdvos merged 9 commits intomainfrom
ld-truncmin

Conversation

@lkdvos
Copy link
Member

@lkdvos lkdvos commented Mar 7, 2026

This adds a new composite truncation strategy based on the concept of taking unions instead of intersections of existing truncations.
This allows for more advanced combinations, such as minimal tolerances, multiple split regions etc, in a very agnostic way that should work with other truncation schemes we don't even know about.

Fixes #181.

lkdvos and others added 4 commits March 7, 2026 13:02
`TruncationUnion` is the symmetric counterpart to `TruncationIntersection`,
keeping values that are present in *any* component strategy. `NoTruncation`
acts as the absorbing element (union with "keep all" = keep all).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
`minrank` provides a lower bound on the number of kept values, composing with
other constraints via `TruncationUnion`. When no upper-bound constraints are
active, `minrank` alone returns `truncrank(minrank)` directly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add examples for the `minrank` keyword argument and the `|` operator,
and add `@docs` entries for `TruncationIntersection` and `TruncationUnion`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lkdvos lkdvos added the documentation Improvements or additions to documentation label Mar 7, 2026
@github-actions
Copy link

github-actions bot commented Mar 7, 2026

After the build completes, the updated documentation will be available here

lkdvos and others added 2 commits March 7, 2026 14:15
Mirrors the existing `_ind_intersect` overrides: collect GPU index vectors
to CPU before computing the union, since `union` does not work on GPU arrays.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 44.68085% with 26 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/implementations/truncation.jl 38.09% 13 Missing ⚠️
src/interface/truncation.jl 55.00% 9 Missing ⚠️
...ixAlgebraKitAMDGPUExt/MatrixAlgebraKitAMDGPUExt.jl 33.33% 2 Missing ⚠️
...MatrixAlgebraKitCUDAExt/MatrixAlgebraKitCUDAExt.jl 33.33% 2 Missing ⚠️
Files with missing lines Coverage Δ
src/MatrixAlgebraKit.jl 100.00% <ø> (ø)
...ixAlgebraKitAMDGPUExt/MatrixAlgebraKitAMDGPUExt.jl 68.08% <33.33%> (-2.37%) ⬇️
...MatrixAlgebraKitCUDAExt/MatrixAlgebraKitCUDAExt.jl 70.00% <33.33%> (-2.35%) ⬇️
src/interface/truncation.jl 66.19% <55.00%> (-3.81%) ⬇️
src/implementations/truncation.jl 81.08% <38.09%> (-10.04%) ⬇️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lkdvos lkdvos requested review from Jutho and kshyatt March 9, 2026 18:08
true
```

Use `maxrank` together with a tolerance to keep at most `maxrank` values above the tolerance (intersection):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the tolerance be both/either relative/absolute?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes to all, although for this particular set of examples I think the focus is more on the fact that you can combine them, not necessarily on what trunctol accepts, which should be listed in the docstrings

@test length(diagview(S2)) == 2
@test collect(diagview(S2)) ≈ collect(diagview(S)[1:2])
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am probably too tired, but this looks like two times the same identical block of code / set of tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, but with the addition of the alg. The goal here is to test certain operations for the supplied alg, while the goal above is to test if things work for an array type if you have not specified alg.

@lkdvos lkdvos merged commit bb27392 into main Mar 11, 2026
5 of 9 checks passed
@lkdvos lkdvos deleted the ld-truncmin branch March 11, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow one to set a minimum dimension when truncating.

3 participants