Skip to content

Conversation

@lkdvos
Copy link
Member

@lkdvos lkdvos commented Sep 19, 2025

This PR slightly refactors the truncation implementation, by separating out the interface from the implementation, more similar to the other parts of the library.

Additionally, I ported over truncerror (TruncationError), based on TensorKit.jl and TensorAlgebra.jl

I tentatively renamed it from truncerr to truncerror, I'm not sure how useful it is to shorten that name further. Happy to change that back if we don't like this.

@codecov
Copy link

codecov bot commented Sep 19, 2025

Codecov Report

❌ Patch coverage is 81.92771% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/interface/truncation.jl 70.83% 14 Missing ⚠️
src/algorithms.jl 88.88% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/MatrixAlgebraKit.jl 100.00% <ø> (ø)
src/implementations/truncation.jl 98.57% <100.00%> (+10.15%) ⬆️
src/algorithms.jl 92.80% <88.88%> (-0.31%) ⬇️
src/interface/truncation.jl 70.83% <70.83%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lkdvos lkdvos force-pushed the ld-trunc branch 8 times, most recently from 1022ad7 to da2c0dc Compare September 19, 2025 11:18
@mtfishman
Copy link
Collaborator

mtfishman commented Sep 19, 2025

Additionally, I ported over truncerror (TruncationError), based on TensorKit.jl and TensorAlgebra.jl

Great, it will be nice to have a shared implementation to use.

I tentatively renamed it from truncerr to truncerror, I'm not sure how useful it is to shorten that name further. Happy to change that back if we don't like this.

truncerror looks good to me.

@Jutho
Copy link
Member

Jutho commented Sep 19, 2025

Great PR.

One thing it does not address is (not saying that it should) is that in the AD rules for truncated factorizations, I will need to reproduce the logic of truncate!(alg, out, strategy), i.e. manually call findtruncated(_sorted) and then to the actual truncation in the right way for that alg / out combination.

@lkdvos lkdvos enabled auto-merge (squash) September 21, 2025 08:10
@lkdvos lkdvos merged commit 2d6443e into main Sep 21, 2025
9 of 10 checks passed
@lkdvos lkdvos deleted the ld-trunc branch September 21, 2025 08:29
lkdvos added a commit that referenced this pull request Sep 21, 2025
* Refactor truncation implementation

* relax norm types

* Add TruncationError

* update docs

* Add some tests

* move definition of `&`

* Add `notrunc` docstrings

* update `findtruncated_sorted` docstring
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.

3 participants