Skip to content

QuasiArrays v0.6 #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.5'
- '^1.6.0-0'
- '1.6'
os:
- ubuntu-latest
- macOS-latest
Expand Down
10 changes: 5 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ContinuumArrays"
uuid = "7ae1f121-cc2c-504b-ac30-9b923412ae5c"
version = "0.7.5"
version = "0.8.0"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand All @@ -17,18 +17,18 @@ RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

[compat]
ArrayLayouts = "0.6, 0.7"
ArrayLayouts = "0.7"
BandedMatrices = "0.16"
BlockArrays = "0.15.1"
FillArrays = "0.11"
InfiniteArrays = "0.10"
Infinities = "0.1"
IntervalSets = "0.5"
LazyArrays = "0.21"
QuasiArrays = "0.5.1"
QuasiArrays = "0.6"
RecipesBase = "1.0"
StaticArrays = "0.12, 1"
julia = "1.5"
StaticArrays = "1.0"
julia = "1.6"

[extras]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
2 changes: 1 addition & 1 deletion src/ContinuumArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import QuasiArrays: cardinality, checkindex, QuasiAdjoint, QuasiTranspose, Inclu
QuasiDiagonal, MulQuasiArray, MulQuasiMatrix, MulQuasiVector, QuasiMatMulMat,
ApplyQuasiArray, ApplyQuasiMatrix, LazyQuasiArrayApplyStyle, AbstractQuasiArrayApplyStyle, AbstractQuasiLazyLayout,
LazyQuasiArray, LazyQuasiVector, LazyQuasiMatrix, LazyLayout, LazyQuasiArrayStyle, _factorize,
AbstractQuasiFill, UnionDomain
AbstractQuasiFill, UnionDomain, __sum
import InfiniteArrays: Infinity, InfAxes

export Spline, LinearSpline, HeavisideSpline, DiracDelta, Derivative, ℵ₁, Inclusion, Basis, WeightedBasis, grid, plotgrid, transform, affine, ..
Expand Down
18 changes: 0 additions & 18 deletions src/bases/bases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -391,32 +391,14 @@ end
# sum
####

_sum(V::AbstractQuasiArray, dims) = __sum(MemoryLayout(typeof(V)), V, dims)
_sum(V::AbstractQuasiArray, ::Colon) = __sum(MemoryLayout(typeof(V)), V, :)
sum(V::AbstractQuasiArray; dims=:) = _sum(V, dims)

__sum(L, Vm, _) = error("Override for $L")
function __sum(::SubBasisLayout, Vm, dims)
@assert dims == 1
sum(parent(Vm); dims=dims)[:,parentindices(Vm)[2]]
end
function __sum(LAY::ApplyLayout{typeof(*)}, V::AbstractQuasiVector, ::Colon)
a = arguments(LAY, V)
first(apply(*, sum(a[1]; dims=1), tail(a)...))
end

__sum(::AdjointBasisLayout, Vm::AbstractQuasiMatrix, dims) = permutedims(sum(Vm'; dims=(isone(dims) ? 2 : 1)))

# sum is equivalent to hitting by ones(n) on the left or rifght
function __sum(LAY::ApplyLayout{typeof(*)}, V::AbstractQuasiMatrix, d::Int)
a = arguments(LAY, V)
if d == 1
*(sum(first(a); dims=1), tail(a)...)
else
@assert d == 2
*(most(a)..., sum(last(a); dims=2))
end
end

function __sum(::MappedBasisLayouts, V::AbstractQuasiArray, dims)
kr = basismap(V)
Expand Down
5 changes: 3 additions & 2 deletions src/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ function getindex(δ::DiracDelta{T}, x::Number) where T
end


@simplify *(A::QuasiAdjoint{<:Any,<:DiracDelta}, B::AbstractQuasiVector) = B[parent(A).x]
@simplify *(A::QuasiAdjoint{<:Any,<:DiracDelta}, B::AbstractQuasiMatrix) = B[parent(A).x,:]
dot(δ::DiracDelta, B::AbstractQuasiVector) = B[δ.x]
@simplify *(A::QuasiAdjoint{<:Any,<:DiracDelta}, B::AbstractQuasiVector) = dot(parent(A),B)

show(io::IO, δ::DiracDelta) = print(io, "δ at $(δ.x) over $(axes(δ,1))")
show(io::IO, ::MIME"text/plain", δ::DiracDelta) = show(io, δ)
Expand All @@ -99,7 +100,7 @@ struct Derivative{T,D} <: LazyQuasiMatrix{T}
axis::Inclusion{T,D}
end

Derivative{T}(axis::A) where {T,A<:Inclusion} = Derivative{T,A}(axis)
Derivative{T}(axis::Inclusion{<:Any,D}) where {T,D} = Derivative{T,D}(axis)
Derivative{T}(domain) where T = Derivative{T}(Inclusion(domain))

axes(D::Derivative) = (D.axis, D.axis)
Expand Down
4 changes: 3 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using ContinuumArrays, QuasiArrays, LazyArrays, IntervalSets, FillArrays, LinearAlgebra, BandedMatrices, FastTransforms, InfiniteArrays, Test, Base64, RecipesBase
import ContinuumArrays: ℵ₁, materialize, AffineQuasiVector, BasisLayout, AdjointBasisLayout, SubBasisLayout, ℵ₁,
MappedBasisLayout, AdjointMappedBasisLayout, MappedWeightedBasisLayout, TransformFactorization, Weight, WeightedBasisLayout, SubWeightedBasisLayout, WeightLayout,
Expansion, basis, invmap, Map, checkpoints, _plotgrid
Expansion, basis, invmap, Map, checkpoints, _plotgrid, mul
import QuasiArrays: SubQuasiArray, MulQuasiMatrix, Vec, Inclusion, QuasiDiagonal, LazyQuasiArrayApplyStyle, LazyQuasiArrayStyle
import LazyArrays: MemoryLayout, ApplyStyle, Applied, colsupport, arguments, ApplyLayout, LdivStyle, MulStyle

Expand Down Expand Up @@ -34,6 +34,7 @@ import LazyArrays: MemoryLayout, ApplyStyle, Applied, colsupport, arguments, App
@testset "Derivative" begin
x = Inclusion(-1..1)
D = Derivative(x)
@test D == Derivative{Float64}(x) == Derivative{Float64}(-1..1)
@test D*x ≡ QuasiOnes(x)
@test D^2 * x ≡ QuasiZeros(x)
@test D*[x D*x] == [D*x D^2*x]
Expand Down Expand Up @@ -137,6 +138,7 @@ end
δ = DiracDelta(1.2,1..3)
L = LinearSpline([1,2,3])
@test @inferred(δ'L) ≈ [0.8, 0.2, 0.0]
@test δ'f == mul(δ',f) == dot(δ,f) == f[1.2]

@test @inferred(L'L) == SymTridiagonal([1/3,2/3,1/3], [1/6,1/6])

Expand Down