1-
1+ # bc corresponds to value of first derivative outside the grid. Default to (0, 0), which corresponds to reflecting.
22struct FirstDerivative{T, X <: AbstractVector{<:Real} , Y <: AbstractVector{<: Real} } <: AbstractVector{T}
33 x:: X
44 y:: Y
@@ -7,20 +7,20 @@ struct FirstDerivative{T, X <: AbstractVector{<:Real}, Y <: AbstractVector{<: Re
77 function FirstDerivative (x, y, bc, direction)
88 size (x) == size (y) || throw (DimensionMismatch (
99 " cannot match grid of length $(length (x)) with vector of length $(length (y)) " ))
10- direction ∈ (:upward , :downward ) || throw (ArgumentError (" direction must be :upward or :downward " ))
10+ direction ∈ (:forward , :backward ) || throw (ArgumentError (" direction must be :forward or :backward " ))
1111 return new {float(eltype(y)), typeof(x), typeof(y)} (x, y, bc, direction)
1212 end
1313end
1414
15- FirstDerivative (x, y; bc = (0 , 0 ), direction = :upward ) = FirstDerivative (x, y, bc, direction)
15+ FirstDerivative (x, y; bc = (0 , 0 ), direction = :forward ) = FirstDerivative (x, y, bc, direction)
1616
1717Base. size (d:: FirstDerivative ) = (length (d. x), 1 )
1818
1919Base. IndexStyle (d:: FirstDerivative ) = IndexLinear ()
2020
2121function Base. getindex (d:: FirstDerivative{T} , i:: Int ) where {T}
2222 x, y, bc, direction = d. x, d. y, d. bc, d. direction
23- if direction == :upward
23+ if direction == :forward
2424 if i == length (x)
2525 return convert (T, bc[end ])
2626 else
0 commit comments