JuliaLinearAlgebra / LinearMaps.jl

A Julia package for defining and working with linear maps, also known as linear transformations or linear operators acting on vectors. The only requirement for a LinearMap is that it can act on a vector (by multiplication) efficiently.
Other
303 stars 42 forks source link

Introduce `KhatriRaoMap` and `FaceSplittingMap` #191

Closed dkarrasch closed 1 year ago

dkarrasch commented 2 years ago

This is a major improvement for a narrow, but potentially interesting case: https://github.com/MichielStock/Kronecker.jl/issues/91.

EDIT: I realized it makes sense to introduce a KhatriRaoMap type, which corresponds to "columnwise Kronecker products". For not too small matrices A and B with equal number of columns (say larger than 5), map-vector-application is faster than what you get for a materialized matrix-vector product, besides the added benefit that this is lazy! In other languages, explicit versions seem to be pretty standard, see:

https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.khatri_rao.html https://www.rdocumentation.org/packages/Matrix/versions/1.4-1/topics/KhatriRao

Unfortunately, I couldn't find an improved way to implement the rowwise Kronecker product, or "face-splitting product", but since it's related to the adjoint/transpose of the Khatri-Rao product, it's included anyway.

codecov[bot] commented 2 years ago

Codecov Report

Base: 99.58% // Head: 99.47% // Decreases project coverage by -0.11% :warning:

Coverage data is based on head (e088b23) compared to base (bd10c6c). Patch coverage: 96.96% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #191 +/- ## ========================================== - Coverage 99.58% 99.47% -0.12% ========================================== Files 18 19 +1 Lines 1460 1526 +66 ========================================== + Hits 1454 1518 +64 - Misses 6 8 +2 ``` | [Impacted Files](https://codecov.io/gh/JuliaLinearAlgebra/LinearMaps.jl/pull/191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaLinearAlgebra) | Coverage Δ | | |---|---|---| | [src/LinearMaps.jl](https://codecov.io/gh/JuliaLinearAlgebra/LinearMaps.jl/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaLinearAlgebra#diff-c3JjL0xpbmVhck1hcHMuamw=) | `100.00% <ø> (ø)` | | | [src/khatrirao.jl](https://codecov.io/gh/JuliaLinearAlgebra/LinearMaps.jl/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaLinearAlgebra#diff-c3JjL2toYXRyaXJhby5qbA==) | `96.72% <96.72%> (ø)` | | | [src/kronecker.jl](https://codecov.io/gh/JuliaLinearAlgebra/LinearMaps.jl/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaLinearAlgebra#diff-c3JjL2tyb25lY2tlci5qbA==) | `98.84% <100.00%> (+0.03%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaLinearAlgebra). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaLinearAlgebra)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

dkarrasch commented 1 year ago

@PythonNut Do you wanna take a look and see if it's useful for you?