Guide

Documentation may not be accurate as this is a beta stage package undergoing changes. Get started with tutorials which are more up to date.

Scalar & vector fields

Scalar & vector fields are represented as 2d/3d arrays of canonically scalars or vectors. Array values can alternatively be any type that Supports addition & multiplication.

Customizable grid

GridType
Grid(cell, rmax::AbstractFloat)
Grid(
    cell::AbstractMatrix,
    sz::Union{AbstractVector,Tuple};
    origin = (sz .+ 1) ./ 2,
    )

Grid is specified by its discrete cell vectors (column-wise matrix), overall size and origin. For a uniform Cartesian 5x5 grid discretized at 0.1 with a centered origin, we get cell = [0.1 0; 0 0.1] & origin = [3, 3]. Grid cell can in general be noncartesian.

Particle mesh placement and interpolation

Base.getMethod
Base.get(field::AbstractArray, grid::Grid, rvec::AbstractVector)
Base.put!(
    field::AbstractArray,
    grid::Grid,
    rvec::AbstractVector,
    val::AbstractVector,
)

With grid info we can interpolate a scalar or vector field at any location. We can also place a scalar or vector point source anywhere with automatic normalization wrt discretization. Both work via a proximity weighted average of the closest grid points (in general up to 4 in 2d and 8 in 3d).

Finite difference equivariant operators

OpType
Op(radfunc, rmax, cell::Matrix; kw...)

constructs equivariant operator

function (m::Op)(x::AbstractArray, )
DelFunction

" Del(cell; pad = :same, border = :smooth)

constructs gradient operator

LaplacianFunction
Laplacian(cell; pad = :same, border = :smooth)

constructs Laplacian operator

Examples

GaussianFunction
Gaussian(cell, σ, rmax; kw...)

constructs Gaussian diffusion operator

Lower level utilities

Convolutions

Feature rich convolution and cross correlation functions with options for padding, stride, boundary conditions, and custom products (tensor field convolutions).

cvconvFunction
cvconv(x, f; product = *, stride = 1, pad = 0, alg = nothing)

"convolution" in computer vision for any dimension, same as Cross correlation. Automatically uses FFT for big kernels. For convolution in signal processing , use dspconv instead.

x input array f filter array product product in convolution, eg *, dot pad amount of padding or padding option

  • any integer number of pixels on each boundary
  • :same: adds enough padding so ouoverlapdotut is same size as input
  • :outer: ouoverlapdotut size is size(x) .+ size(f) .- 1

border type of padding

  • 0 value pixels
  • :replicate repeats edge values
  • :circular periodic BC
  • :smooth continuous derivatives at boundaries useful for differential operators
  • :reflect reflects interior across boundaries which are not repeated
  • :symmetric same as :reflect but with boundaries repeated

alg specifies convolution algorithm

  • nothing Automatically chooses fastest algorithm
  • :direct convolution, scales as O(n^2)
  • :fft Fourier convolution, scales as O(n log(n))

Convolutions in other Julia packages, fewer features but perhaps more optimized for speed in their specific use cases

  • ImageFiltering.imfilter. Its docs has excellent mathematical explaination of convolutions and correlation as well as padding/border options
  • DSP.conv DSP.xcor
  • Flux.conv
dspconvFunction
dspconv(x, f; product = *,pad = :outer,border=0)

Convolution in signal processing. For "convolution" in computer vision, use cvconv instead. Automatically uses FFT for big kernels. By default output size is size(x) .+ size(f) .- 1. See cvconv for its keyword options which also apply here