@@ -51,28 +51,30 @@ cumsum_size(::NTuple{N,Integer}, A, dims) where N = error("Not implemented")
5151# diff
5252# ###
5353
54- @inline diff (a:: AbstractQuasiArray ; dims:: Integer = 1 ) = diff_layout (MemoryLayout (a), a, dims)
55- function diff_layout (LAY:: ApplyLayout{typeof(*)} , V:: AbstractQuasiVector , dims ... )
54+ @inline diff (a:: AbstractQuasiArray , order ... ; dims:: Integer = 1 ) = diff_layout (MemoryLayout (a), a, order ... ; dims)
55+ function diff_layout (LAY:: ApplyLayout{typeof(*)} , V:: AbstractQuasiVector , order ... ; dims = 1 )
5656 a = arguments (LAY, V)
57- * (diff (a[1 ]), tail (a)... )
57+ dims == 1 || throw (ArgumentError (" cannot differentiate a vector along dimension $dims " ))
58+ * (diff (a[1 ], order... ), tail (a)... )
5859end
5960
60- function diff_layout (LAY:: ApplyLayout{typeof(*)} , V:: AbstractQuasiMatrix , dims= 1 )
61+ function diff_layout (LAY:: ApplyLayout{typeof(*)} , V:: AbstractQuasiMatrix , order ... ; dims= 1 )
6162 a = arguments (LAY, V)
6263 @assert dims == 1 # for type stability, for now
6364 # if dims == 1
64- * (diff (a[1 ]), tail (a)... )
65+ * (diff (a[1 ], order ... ), tail (a)... )
6566 # else
6667 # *(front(a)..., diff(a[end]; dims=dims))
6768 # end
6869end
6970
70- diff_layout (:: MemoryLayout , A, dims... ) = diff_size (size (A), A, dims... )
71- diff_size (sz, a, dims... ) = error (" diff not implemented for $(typeof (a)) " )
71+ diff_layout (:: MemoryLayout , A, order ... ; dims... ) = diff_size (size (A), A, order ... ; dims... )
72+ diff_size (sz, a, order ... ; dims... ) = error (" diff not implemented for $(typeof (a)) " )
7273
7374diff (x:: Inclusion ; dims:: Integer = 1 ) = ones (eltype (x), diffaxes (x))
74- diff (c:: AbstractQuasiFill{<:Any,1} ; dims:: Integer = 1 ) = zeros (eltype (c), diffaxes (axes (c,1 )))
75- function diff (c:: AbstractQuasiFill{<:Any,2} ; dims:: Integer = 1 )
75+ diff (x:: Inclusion , order:: Int ; dims:: Integer = 1 ) = fill (ifelse (isone (order), one (eltype (x)), zero (eltype (x))), diffaxes (x))
76+ diff (c:: AbstractQuasiFill{<:Any,1} , order... ; dims:: Integer = 1 ) = zeros (eltype (c), diffaxes (axes (c,1 )))
77+ function diff (c:: AbstractQuasiFill{<:Any,2} , order... ; dims:: Integer = 1 )
7678 a,b = axes (c)
7779 if dims == 1
7880 zeros (eltype (c), diffaxes (a), b)
0 commit comments