Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix curl calling 3d function for 1d and 2d vectors #222

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/automatic_differentiation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,16 @@ function curl(f::F, v::Vec{3}) where F
end
return c
end
curl(f::F, v::Vec{1, T}) where {F, T} = curl(f, Vec{3}((v[1], T(0), T(0))))
curl(f::F, v::Vec{2, T}) where {F, T} = curl(f, Vec{3}((v[1], v[2], T(0))))
function curl(f::F, v::Vec{2}) where {F}
@inbounds begin
∇f = gradient(f, v)
c = Vec{3}((zero(eltype(∇f)), zero(eltype(∇f)), ∇f[2,1] - ∇f[1,2]))
end
return c
end
function curl(f::F, v::Vec{1, T}) where {F, T}
return zero(Vec{3, eltype(f(v))}) / oneunit(T)
end

"""
laplace(f, x)
Expand Down
Loading