Skip to content

[WIP] Add datatype, in-place one!/unmatricize!, make scalar/similar_map public#205

Draft
mtfishman wants to merge 2 commits into
mainfrom
mf/nextgen-followups-round1
Draft

[WIP] Add datatype, in-place one!/unmatricize!, make scalar/similar_map public#205
mtfishman wants to merge 2 commits into
mainfrom
mf/nextgen-followups-round1

Conversation

@mtfishman

@mtfishman mtfishman commented Jul 8, 2026

Copy link
Copy Markdown
Member

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}), complementing scalartype/eltype, which give the element type alone. It recurses through array wrappers via parent and terminates on a plain array, with a type-level base case datatype(::Type{<:AbstractArray}). scalar and similar_map become public.

one!(A, ndims_codomain::Val) fills A in 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 aliasing A (a dense reshape). unmatricize!(a_dest, m, ndims_codomain::Val) scatters a fused matrix back into an existing array, the split-axes counterpart of unmatricizeperm!.

svd_trunc now 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

  • Exercise the new API from the downstream migration before marking ready.

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.
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.83333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 76.94%. Comparing base (8567e35) to head (d32f1be).

Files with missing lines Patch % Lines
src/factorizations.jl 92.85% 1 Missing ⚠️
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     
Flag Coverage Δ
docs 22.24% <16.66%> (-0.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

`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.
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