view ext/DiffinitiveSparseArrayKitExt.jl @ 2080:0f949681d3d3 refactor/sbp_operators/direction_check tip

Check that direction of first/second derivative operators is within the dimension of the grid. Add 1D functions for first/second derivative operators that take a direction.
author Vidar Stiernström <vidar.stiernstrom@gmail.com>
date Fri, 20 Feb 2026 12:01:05 +0100
parents 471a948cd2b2
children
line wrap: on
line source

module DiffinitiveSparseArrayKitExt

using Diffinitive
using Diffinitive.LazyTensors

using SparseArrayKit
using Tokens

"""
    SparseArray(t::LazyTensor)

The sparse tensor representation of `t` with range dimensions to the left and
domain dimensions to the right. If `L` is a `LazyTensor` with range and
domain dimension 2 and `v` a 2-tensor, then `A = SparseArray(t)` is
constructed so that `∑ₖ∑ₗA[i,j,k,l]*v[k,l] == L*v`.
"""
function SparseArrayKit.SparseArray(t::LazyTensor)
    v = ArrayToken(:v, domain_size(t)...)
    return Tokens._to_tensor(t*v, range_size(t), domain_size(t))
end

end