Skip to content

Commit a1e2a62

Browse files
authored
Add KronExpansionLayout for A*X*B' (#206)
* Add KronExpansionLayout for A*X*B' * Support for KronExpansion sum and vec for Expansios * Update Project.toml * increase coverage * Update ci.yml * run test
1 parent 97a41a4 commit a1e2a62

File tree

9 files changed

+57
-18
lines changed

9 files changed

+57
-18
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,5 @@ jobs:
4949
- uses: julia-actions/julia-processcoverage@v1
5050
- uses: codecov/codecov-action@v5
5151
with:
52-
file: lcov.info
5352
token: ${{ secrets.CODECOV_TOKEN }}
54-
fail_ci_if_error: false
53+
file: lcov.info

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ContinuumArrays"
22
uuid = "7ae1f121-cc2c-504b-ac30-9b923412ae5c"
3-
version = "0.19.4"
3+
version = "0.19.5"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
@@ -38,7 +38,7 @@ Infinities = "0.1"
3838
IntervalSets = "0.7"
3939
LazyArrays = "2"
4040
Makie = "0.20, 0.21, 0.22, 0.24"
41-
QuasiArrays = "0.12"
41+
QuasiArrays = "0.12.2"
4242
RecipesBase = "1.0"
4343
StaticArrays = "1.0"
4444
julia = "1.10"

docs/src/index.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,38 +68,40 @@ plotgrid
6868
```@docs
6969
ContinuumArrays.TransformFactorization
7070
```
71-
7271
```@docs
7372
ContinuumArrays.AbstractConcatBasis
7473
```
7574
```@docs
76-
ContinuumArrays.MulPlan
75+
ContinuumArrays.basis
7776
```
7877
```@docs
79-
ContinuumArrays.PiecewiseBasis
78+
ContinuumArrays.HvcatBasis
8079
```
8180
```@docs
82-
ContinuumArrays.Map
81+
ContinuumArrays.InvPlan
8382
```
8483
```@docs
85-
ContinuumArrays.MappedFactorization
84+
ContinuumArrays.KronExpansionLayout
8685
```
8786
```@docs
88-
ContinuumArrays.basis
87+
ContinuumArrays.Map
8988
```
9089
```@docs
91-
ContinuumArrays.InvPlan
90+
ContinuumArrays.MappedFactorization
9291
```
9392
```@docs
94-
ContinuumArrays.VcatBasis
93+
ContinuumArrays.MulPlan
9594
```
9695
```@docs
97-
ContinuumArrays.WeightedFactorization
96+
ContinuumArrays.PiecewiseBasis
9897
```
9998
```@docs
100-
ContinuumArrays.HvcatBasis
99+
ContinuumArrays.ProjectionFactorization
101100
```
102101
```@docs
103-
ContinuumArrays.ProjectionFactorization
102+
ContinuumArrays.VcatBasis
104103
```
104+
```@docs
105+
ContinuumArrays.WeightedFactorization
105106
```
107+

src/ContinuumArrays.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import QuasiArrays: cardinality, checkindex, QuasiAdjoint, QuasiTranspose, Inclu
1919
ApplyQuasiArray, ApplyQuasiMatrix, LazyQuasiArrayApplyStyle, AbstractQuasiArrayApplyStyle, AbstractQuasiLazyLayout,
2020
LazyQuasiArray, LazyQuasiVector, LazyQuasiMatrix, LazyLayout, LazyQuasiArrayStyle, _factorize, _cutdim,
2121
AbstractQuasiFill, UnionDomain, sum_size, sum_layout, _cumsum, cumsum_layout, applylayout, equals_layout, layout_broadcasted, PolynomialLayout, dot_size,
22-
diff_layout, diff_size, AbstractQuasiVecOrMat
22+
diff_layout, diff_size, AbstractQuasiVecOrMat, vec_layout
2323
import InfiniteArrays: Infinity, InfAxes
2424
import AbstractFFTs: Plan
2525

src/bases/bases.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,17 @@ function copy(M::Mul{<:AdjointMappedBasisLayouts, <:MappedBasisLayouts})
793793
end
794794

795795

796+
#######
797+
# reshape/vec
798+
#######
799+
800+
function vec_layout(::ExpansionLayout, f)
801+
P,c = basis(f), coefficients(f)
802+
@assert isone(size(c,2))
803+
P * vec(c)
804+
end
805+
806+
796807

797808
include("basisconcat.jl")
798809
include("basiskron.jl")

src/bases/basiskron.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
struct KronBasisLayout <: AbstractBasisLayout end
22

3-
QuasiArrays.kronlayout(::AbstractBasisLayout...) = KronBasisLayout()
3+
QuasiArrays.kronlayout(::AbstractBasisLayout...) = KronBasisLayout()
4+
5+
"""
6+
KronExpansionLayout
7+
8+
is a MemoryLayout corresponding to a quasi-matrix corresponding to the 2D expansion K[x,y] == A[x]*X*B[y]'
9+
"""
10+
struct KronExpansionLayout{LayA, LayB} <: AbstractLazyLayout end
11+
applylayout(::Type{typeof(*)}, ::LayA, ::CoefficientLayouts, ::AdjointBasisLayout{LayB}) where {LayA <: AbstractBasisLayout, LayB <: AbstractBasisLayout} = KronExpansionLayout{LayA,LayB}()
12+
sublayout(::KronExpansionLayout, inds) = sublayout(ApplyLayout{typeof(*)}(), inds)
13+
sum_layout(::KronExpansionLayout, F, dims...) = sum_layout(ApplyLayout{typeof(*)}(), F, dims...)

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ end
8484
include("test_splines.jl")
8585
include("test_chebyshev.jl")
8686
include("test_basisconcat.jl")
87+
include("test_basiskron.jl")
8788

8889
@testset "Grids/values" begin
8990
L = LinearSpline(1:5)

test/test_basiskron.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ using ContinuumArrays, QuasiArrays, StaticArrays, Test
66

77
xy = axes(K,1)
88
f = xy -> ((x,y) = xy; exp(x*cos(y)))
9-
K \ f.(xy)
9+
@test_broken K \ f.(xy)
10+
end
1011

12+
@testset "KronExpansion" begin
13+
L = LinearSpline(range(0,1; length=4))
14+
C = reshape(Vector(1:16), 4, 4)
15+
F = L * C * L'
16+
@test sum(F) 8.5
17+
@test sum(F; dims=1)[1,0.1] 3.7
18+
@test sum(F; dims=2)[0.1,1] 7.3
19+
20+
@test F[0.1,:][0.2] F[:,0.2][0.1] F[0.1,0.2]
1121
end

test/test_splines.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,4 +654,10 @@ import ContinuumArrays: basis, AdjointBasisLayout, ExpansionLayout, BasisLayout,
654654
f = x -> abs(x) 1 ? 1 : "hi"
655655
@test expand(L,f)[0.1] 1
656656
end
657+
658+
@testset "vec" begin
659+
L = LinearSpline([-1,0,1])
660+
F = L * randn(3,1)
661+
@test vec(F)[0.1] == F[0.1,1]
662+
end
657663
end

0 commit comments

Comments
 (0)