[WIP] Add datatype, in-place one!/unmatricize!, make scalar/similar_map public#205
Draft
mtfishman wants to merge 2 commits into
Draft
[WIP] Add datatype, in-place one!/unmatricize!, make scalar/similar_map public#205mtfishman wants to merge 2 commits into
mtfishman wants to merge 2 commits into
Conversation
Small additive utilities on the tensor-algebra interface: a `datatype` storage-type accessor, public `scalar` and `similar_map`, and the in-place `one!` / `unmatricize!` primitives.
2 tasks
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #205 +/- ##
==========================================
- Coverage 80.32% 76.94% -3.38%
==========================================
Files 23 23
Lines 869 885 +16
==========================================
- Hits 698 681 -17
- Misses 171 204 +33
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
`svd_trunc` now returns `(U, S, Vᴴ, ϵ)`, matching MatrixAlgebraKit's four-output `svd_trunc`, where `ϵ` is the 2-norm of the discarded singular values. This gives downstream callers the truncation error cheaply and without catastrophic cancellation, instead of recomputing it from norms.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Small additive utilities on the tensor-algebra interface.
datatype(a)returns the underlying storage array type, the element type together with the container/device (e.g.Matrix{Float64}), complementingscalartype/eltype, which give the element type alone. It recurses through array wrappers viaparentand terminates on a plain array, with a type-level base casedatatype(::Type{<:AbstractArray}).scalarandsimilar_mapbecome public.one!(A, ndims_codomain::Val)fillsAin place with the identity across a codomain/domain split and returns it. It matricizes, fills the fused matrix, and scatters back only when the matricized form is a detached copy (a graded gather) rather than a view aliasingA(a dense reshape).unmatricize!(a_dest, m, ndims_codomain::Val)scatters a fused matrix back into an existing array, the split-axes counterpart ofunmatricizeperm!.svd_truncnow returns the truncation errorϵ, the 2-norm of the discarded singular values, as a fourth output, so callers get it cheaply and without catastrophic cancellation instead of recomputing it from norms.TODO