Skip to content

Commit

Permalink
Update derivatives.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieugomez committed Jun 12, 2024
1 parent ca88d00 commit 94e7955
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/derivatives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Base.size(d::FirstDerivative) = (length(d.x), 1)
Base.IndexStyle(d::FirstDerivative) = IndexLinear()

function Base.getindex(d::FirstDerivative{T}, i::Int) where {T}
(; x, y, bc, direction) = d
x, y, bc, direction = d.x, d.y, d.bc, d.direction
if direction == :upward
if i == length(x)
return convert(T, bc[end])
Expand Down Expand Up @@ -62,7 +62,7 @@ Base.size(d::SecondDerivative) = (length(d.x), 1)
Base.IndexStyle(d::SecondDerivative) = IndexLinear()

function Base.getindex(d::SecondDerivative{T}, i::Int) where {T}
(; x, y, bc) = d
x, y, bc = d.x, d.y, d.bc
Δxp = x[min(i, length(x)-1)+1] - x[min(i, length(x)-1)]
Δxm = x[max(i-1, 1) + 1] - x[max(i-1, 1)]
Δx = (Δxm + Δxp) / 2
Expand Down

0 comments on commit 94e7955

Please sign in to comment.