Skip to content

Commit

Permalink
refactor: clean up 3-tuple cross product into more readable form
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Oct 20, 2024
1 parent 371681f commit 9d36064
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions stdlib/LinearAlgebra/src/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,11 @@ function cross(a::AbstractVector, b::AbstractVector)
if !(length(a) == length(b) == 3)
throw(DimensionMismatch("cross product is only defined for vectors of length 3"))
end
collect(cross((a[1], a[2], a[3]), (b[1], b[2], b[3])))
end
function cross(a::Tuple{Vararg{Any, 3}}, b::Tuple{Vararg{Any, 3}})
a1, a2, a3 = a
b1, b2, b3 = b
collect(cross((a1, a2, a3), (b1, b2, b3)))
end
function cross((a1, a2, a3)::Tuple{Vararg{Any, 3}}, (b1, b2, b3)::Tuple{Vararg{Any, 3}})
(a2*b3-a3*b2, a3*b1-a1*b3, a1*b2-a2*b1)
end

Expand Down

0 comments on commit 9d36064

Please sign in to comment.