11
2- struct FirstDerivative{T} <: AbstractVector{T}
3- x:: AbstractVector{<:Real}
4- y:: AbstractVector{T}
2+ struct FirstDerivative{T, X <: AbstractVector{<:Real} , Y <: AbstractVector{<: Real} } <: AbstractVector{T}
3+ x:: X
4+ y:: Y
55 bc:: NTuple{2} {T}
66 direction:: Symbol
7- function FirstDerivative {T} (x, y, bc, direction) where {T}
7+ 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)) " ))
1010 direction ∈ (:upward , :downward ) || throw (ArgumentError (" direction must be :upward or :downward" ))
11- return new (x, y, bc, direction)
11+ return new {float(eltype(y)), typeof(x), typeof(y)} (x, y, bc, direction)
1212 end
1313end
1414
15- function FirstDerivative (x:: AbstractVector , y:: AbstractVector ; bc = (0 , 0 ), direction = :upward )
16- FirstDerivative {eltype(y)} (x, y, bc, direction)
15+ function FirstDerivative (x, y; bc = (0 , 0 ), direction = :upward )
16+ FirstDerivative (x, y, bc, direction)
1717end
1818
1919Base. size (d:: FirstDerivative ) = (length (d. x), 1 )
@@ -40,19 +40,19 @@ function Base.getindex(d::FirstDerivative{T}, i::Int) where {T}
4040end
4141
4242
43- struct SecondDerivative{T} <: AbstractVector{T}
44- x:: AbstractVector{<:Real}
45- y:: AbstractVector{T}
43+ struct SecondDerivative{T, X <: AbstractVector{<:Real} , Y <: AbstractVector{<: Real} } <: AbstractVector{T}
44+ x:: X
45+ y:: Y
4646 bc:: NTuple{2} {T}
47- function SecondDerivative {T} (x, y, bc) where {T}
47+ function SecondDerivative (x, y, bc)
4848 length (x) == length (y) || throw (DimensionMismatch (
4949 " cannot match grid of length $(length (x)) with vector of length $(length (y)) " ))
50- return new (x, y, bc)
50+ return new {float(eltype(y)), typeof(x), typeof(y)} (x, y, bc)
5151 end
5252end
5353
54- function SecondDerivative (x:: AbstractVector , y:: AbstractVector ; bc = (0 , 0 ))
55- SecondDerivative {eltype(y)} (x, y, bc)
54+ function SecondDerivative (x, y; bc = (0 , 0 ))
55+ SecondDerivative (x, y, bc)
5656end
5757
5858Base. size (d:: SecondDerivative ) = (length (d. x), 1 )
0 commit comments