Skip to content

Commit

Permalink
Add intersect for Inclusion, lazy adjoints (#61)
Browse files Browse the repository at this point in the history
* Add intersect for Inclusion, lazy adjoints

* v0.4.9

* Array materialize if axes are Base.OneTo
  • Loading branch information
dlfivefifty authored Mar 17, 2021
1 parent c599a83 commit 59c557c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "QuasiArrays"
uuid = "c4ea9172-b204-11e9-377d-29865faadc5c"
authors = ["Sheehan Olver <solver@mac.com>"]
version = "0.4.8"
version = "0.4.9"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
2 changes: 1 addition & 1 deletion src/QuasiArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Base: @_inline_meta, DimOrInd, OneTo, @_propagate_inbounds_meta, @_noinli
index_shape, to_shape, unsafe_length, @nloops, @ncall, unalias, _unaliascopy,
to_index, to_indices, _to_subscript_indices, _splatmap, dataids,
compute_stride1, compute_offset1, fill_to_length
import Base: Slice, IdentityUnitRange, ScalarIndex, RangeIndex, view, viewindexing, ensure_indexable, index_dimsum,
import Base: Slice, IdentityUnitRange, ScalarIndex, RangeIndex, view, viewindexing, mightalias, ensure_indexable, index_dimsum,
check_parent_index_match, reindex, _isdisjoint, unsafe_indices, _unsafe_ind2sub,
_ind2sub, _sub2ind, _ind2sub_recurse, _lookup, SubArray,
parentindices, reverse, ndims, checkbounds, uncolon,
Expand Down
4 changes: 4 additions & 0 deletions src/indices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ in(x, S::Inclusion) = x in S.domain
Base.issubset(S::Inclusion, d) = S.domain d
Base.issubset(S::Inclusion, d::Inclusion) = S.domain d.domain

intersect(x::Inclusion...) = Inclusion{mapreduce(eltype,promote_type,x)}(intersect(map(domain,x)...))
# use UnionDomain to support intervals
union(x::Inclusion...) = Inclusion{mapreduce(eltype,promote_type,x)}(UnionDomain(map(domain,x)...))

checkindex(::Type{Bool}, inds::Inclusion{T}, i::T) where T = i inds
checkindex(::Type{Bool}, inds::Inclusion, i) = i inds
checkindex(::Type{Bool}, inds::Inclusion, ::Colon) = true
Expand Down
2 changes: 1 addition & 1 deletion src/lazyquasiarrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct QuasiLazyLayout <: AbstractLazyLayout end
MemoryLayout(::Type{<:LazyQuasiArray}) = QuasiLazyLayout()
lazymaterialize(F, args::Union{AbstractQuasiArray,AbstractArray}...) = copy(ApplyQuasiArray(F, args...))
concretize(A::AbstractQuasiArray) = convert(QuasiArray, A)

transposelayout(::QuasiLazyLayout) = QuasiLazyLayout()

# Inclusions are left lazy. This could be refined to only be the case where the cardinality is infinite
BroadcastStyle(::Type{<:Inclusion}) = LazyQuasiArrayStyle{1}()
Expand Down
8 changes: 5 additions & 3 deletions src/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ end
struct QuasiArrayLayout <: MemoryLayout end
MemoryLayout(::Type{<:AbstractQuasiArray}) = QuasiArrayLayout()

copy(M::Mul{QuasiArrayLayout,QuasiArrayLayout}) = QuasiArray(M)
copy(M::Mul{QuasiArrayLayout}) = QuasiArray(M)
copy(M::Mul{<:Any,QuasiArrayLayout}) = QuasiArray(M)
_quasi_mul(M, _) = QuasiArray(M)
_quasi_mul(M, ::NTuple{N,OneTo{Int}}) where N = Array(QuasiArray(M))
copy(M::Mul{QuasiArrayLayout,QuasiArrayLayout}) = _quasi_mul(M, axes(M))
copy(M::Mul{QuasiArrayLayout}) = _quasi_mul(M, axes(M))
copy(M::Mul{<:Any,QuasiArrayLayout}) = _quasi_mul(M, axes(M))
copy(M::Mul{<:AbstractLazyLayout,QuasiArrayLayout}) = ApplyQuasiArray(M)
copy(M::Mul{ApplyLayout{typeof(\)},QuasiArrayLayout}) = ApplyQuasiArray(M)
copy(M::Mul{QuasiArrayLayout,<:AbstractLazyLayout}) = ApplyQuasiArray(M)
Expand Down
2 changes: 0 additions & 2 deletions src/quasiconcat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ function getindex(f::ApplyQuasiMatrix{T,typeof(hcat)}, k::Number, j::Number) whe
throw(BoundsError(f, (k,j)))
end

union(x::Inclusion...) = Inclusion{mapreduce(eltype,promote_type,x)}(UnionDomain(map(domain,x)...))

"""
UnionVcat
Expand Down

2 comments on commit 59c557c

@dlfivefifty
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/32169

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.9 -m "<description of version>" 59c557cb4149610c332cbec1f96e7d0410ce0f5e
git push origin v0.4.9

Please sign in to comment.