ContinuumArrays.jl
A Julia package for working with bases as quasi-arrays
The Basis interface
To add your own bases, subtype Basis and overload the following routines:
axes(::MyBasis) = (Inclusion(mydomain), OneTo(mylength))grid(::MyBasis, ::Integer)getindex(::MyBasis, x, ::Integer)==(::MyBasis, ::MyBasis)
Optional overloads are:
plan_transform(::MyBasis, sizes::NTuple{N,Int}, region)to plan a transform, for a tensor
product of the specified sizes, similar to plan_fft.
diff(::MyBasis, dims=1)to support differentiation andDerivative.grammatrix(::MyBasis)to supportQ'Q.ContinuumArrays._sum(::MyBasis, dims)andContinuumArrays._cumsum(::MyBasis, dims)to support definite and indefinite integeration.plotgrid(::MyBasis, n...): returnngrid points suitable for plotting the basis. The default value fornis 10,000.
Differential Operators
ContinuumArrays.Derivative — TypeDerivative(axis)
represents the differentiation (or finite-differences) operator on the specified axis.
ContinuumArrays.Laplacian — TypeLaplacian(axis)
represents the laplacian operator Δ on the specified axis.
ContinuumArrays.AbsLaplacian — TypeAbsLaplacian(axis)
represents the positive-definite/negative/absolute-value laplacian operator |Δ| ≡ -Δ on the specified axis.
ContinuumArrays.laplacian — Functionabslaplacian(A, k=1)computes $Δ^k * A$.
ContinuumArrays.abslaplacian — Functionabslaplacian(A, α=1)computes $|Δ|^α * A$.
ContinuumArrays.weaklaplacian — Functionweaklaplacian(A)represents the weak Laplacian.
Routines
ContinuumArrays.transform — Functiontransform(A, f)finds the coefficients of a function f expanded in a basis defined as the columns of a quasi matrix A. It is equivalent to
A \ f.(axes(A,1))ContinuumArrays.plan_transform — Functionplan_transform(basis, (n₁,…,nₘ), [dims])plans a transform applying the transform to an array specified by the sizes (n₁,…,nₘ). If nₖ is an integer then this gives the size in that dimension. If nₖ is a Block then the array in that dimension is specified by axes(basis,1)[Block.(Base.oneto(nₖ)]. The array it acts on should correspond to samples on the points specified by grid(basis, (n₁,…,nₘ)).
If dims is an integer or tuple of integers then the transform is only applied to that dimension. If dims is omitted then every dimension is transformed.
plan_transform(basis, A::AbstractArray, [dims])is equivalent to plan_transform(basis, size(A), [dims]).
ContinuumArrays.expand — Functionexpand(A, f)expands a function f im a basis defined as the columns of a quasi matrix A. It is equivalent to
A / A \ f.(axes(A,1))expand(v)finds a natural basis for a quasi-vector and expands in that basis.
ContinuumArrays.grid — Functiongrid(P, n...)Creates a grid of points. if n is unspecified it will be sufficient number of points to determine size(P,2) coefficients. If n is an integer or Block its enough points to determine n coefficients. If n is a tuple then it returns a tuple of grids corresponding to a tensor-product. That is, a 5⨱6 2D transform would be
(x,y) = grid(P, (5,6))
plan_transform(P, (5,6)) * f.(x, y')and a 5×6×7 3D transform would be
(x,y,z) = grid(P, (5,6,7))
plan_transform(P, (5,6,7)) * f.(x, y', reshape(z,1,1,:))ContinuumArrays.plotgrid — Functionplotgrid(P, n...)returns a grid of points suitable for plotting. This may include endpoints or singular points not included in grid. n specifies the number of coefficients.
Interal Routines
ContinuumArrays.TransformFactorization — TypeTransformFactorization(grid, plan)associates a planned transform with a grid. That is, if F is a TransformFactorization, then F \ f is equivalent to F.plan * f[F.grid].
ContinuumArrays.AbstractConcatBasis — TypeAbstractConcatBasisis an abstract type representing a block diagonal basis but with modified axes.
ContinuumArrays.basis — Functionbasis(v)gives a basis for expanding given quasi-vector.
ContinuumArrays.HvcatBasis — TypeVcatBasisis an analogue of Basis that hvcats the values, so they are matrix valued.
ContinuumArrays.InvPlan — TypeInvPlan(factorization, dims)Takes a factorization and supports it applied to different dimensions.
ContinuumArrays.KronExpansionLayout — TypeKronExpansionLayoutis a MemoryLayout corresponding to a quasi-matrix corresponding to the 2D expansion K[x,y] == A[x]XB[y]'
ContinuumArrays.Map — TypeA subtype of Map is used as a one-to-one map between two domains via view. The domain of the map m is axes(m,1) and the range is union(m).
Maps must also overload invmap to give the inverse of the map, which is equivalent to invmap(m)[x] == findfirst(isequal(x), m).
ContinuumArrays.MappedFactorization — TypeMappedFactorization(F, map)remaps a factorization to a different domain. That is, if M is a MappedFactorization then M \ f is equivalent to F \ f[map]
ContinuumArrays.MulPlan — TypeMulPlan(matrix, [plan], dims)Takes a matrix and supports it applied to different dimensions, after applying a plan.
ContinuumArrays.PiecewiseBasis — TypePiecewiseBasis(args...)is an analogue of Basis that takes the union of the first axis, and the second axis is a blocked concatenatation of args. If there is overlap, it uses the first in order.
ContinuumArrays.ProjectionFactorization — TypeProjectionFactorization(F, inds)projects a factorization to a subset of coefficients. That is, if P is a ProjectionFactorization then P \ f is equivalent to (F \ f)[inds]
ContinuumArrays.VcatBasis — TypeVcatBasisis an analogue of Basis that vcats the values.
ContinuumArrays.WeightedFactorization — TypeWeightedFactorization(w, F)weights a factorization F by w.