Skip to content

Commit 9a2f8d3

Browse files
authored
== for Inclusion and affine maps (#105)
* == for Inclusion and affine maps * Update runtests.jl
1 parent fe30154 commit 9a2f8d3

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
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.8.2"
3+
version = "0.8.3"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/bases/bases.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ end
5959
@inline copy(L::Ldiv{<:AbstractBasisLayout,BroadcastLayout{typeof(+)}}) = +(broadcast(\,Ref(L.A),arguments(L.B))...)
6060
@inline copy(L::Ldiv{<:AbstractBasisLayout,BroadcastLayout{typeof(+)},<:Any,<:AbstractQuasiVector}) =
6161
transform_ldiv(L.A, L.B)
62+
@inline copy(L::Ldiv{Lay,BroadcastLayout{typeof(+)},<:Any,<:AbstractQuasiVector}) where Lay<:MappedBasisLayouts =
63+
copy(Ldiv{Lay,LazyLayout}(L.A,L.B))
6264

6365
@inline function copy(L::Ldiv{<:AbstractBasisLayout,BroadcastLayout{typeof(-)}})
6466
a,b = arguments(L.B)
@@ -85,7 +87,7 @@ end
8587
demap(A)\demap(B)
8688
end
8789

88-
function copy(P::Ldiv{<:MappedBasisLayouts,<:AbstractLazyLayout})
90+
function copy(P::Ldiv{<:MappedBasisLayouts,<:AbstractLazyLayout,<:Any,<:AbstractQuasiVector})
8991
A,B = P.A, P.B
9092
demap(A) \ B[invmap(basismap(A))]
9193
end

src/maps.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ copy(A::AbstractAffineQuasiVector) = A
7373
inbounds_getindex(A::AbstractAffineQuasiVector{<:Any,<:Any,<:Inclusion}, k::Number) = A.A*k .+ A.b
7474
isempty(A::AbstractAffineQuasiVector) = isempty(A.x)
7575
==(a::AbstractAffineQuasiVector, b::AbstractAffineQuasiVector) = a.A == b.A && a.x == b.x && a.b == b.b
76+
==(a::AbstractAffineQuasiVector, b::Inclusion) = a == affine(b,b)
77+
==(a::Inclusion, b::AbstractAffineQuasiVector) = affine(a,a) == b
7678

7779
BroadcastStyle(::Type{<:AbstractAffineQuasiVector}) = LazyQuasiArrayStyle{1}()
7880

@@ -104,7 +106,6 @@ invmap(d::AbstractAffineQuasiVector) = affine(union(d), axes(d,1))
104106

105107

106108

107-
108109
struct AffineMap{T,D,R} <: AbstractAffineQuasiVector{T,T,D,T}
109110
domain::D
110111
range::R

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,10 @@ end
447447
@test L[y,:] \ (L[y,:] * c) c
448448
@test ContinuumArrays.demap(L[y,:] * c) == L*c
449449
end
450+
451+
@testset "Mapped and BroadcastLayout{typeof(+)}" begin
452+
@test L[y,:] \ (y .+ y) L[y,:] \ (2y)
453+
end
450454
end
451455

452456
@testset "diff" begin

test/test_maps.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import ContinuumArrays: AffineQuasiVector
2525
@test_throws BoundsError y[Inclusion(0..2)]
2626

2727
@test y == y
28+
29+
@test x == affine(x,x)
30+
@test affine(x,x) == x
2831
end
2932

3033
@testset "find" begin

0 commit comments

Comments
 (0)