@@ -51,28 +51,30 @@ cumsum_size(::NTuple{N,Integer}, A, dims) where N = error("Not implemented")
51
51
# diff
52
52
# ###
53
53
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 )
56
56
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)... )
58
59
end
59
60
60
- function diff_layout (LAY:: ApplyLayout{typeof(*)} , V:: AbstractQuasiMatrix , dims= 1 )
61
+ function diff_layout (LAY:: ApplyLayout{typeof(*)} , V:: AbstractQuasiMatrix , order ... ; dims= 1 )
61
62
a = arguments (LAY, V)
62
63
@assert dims == 1 # for type stability, for now
63
64
# if dims == 1
64
- * (diff (a[1 ]), tail (a)... )
65
+ * (diff (a[1 ], order ... ), tail (a)... )
65
66
# else
66
67
# *(front(a)..., diff(a[end]; dims=dims))
67
68
# end
68
69
end
69
70
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)) " )
72
73
73
74
diff (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 )
76
78
a,b = axes (c)
77
79
if dims == 1
78
80
zeros (eltype (c), diffaxes (a), b)
0 commit comments