Vector products: Difference between revisions

m
J: a couple minor variations on the cross product themes
m (J: a couple minor variations on the cross product themes)
Line 2,302:
 
<syntaxhighlight lang="j">cross=: (1&|.@[ * 2&|.@]) - 2&|.@[ * 1&|.@]</syntaxhighlight>
or
<syntaxhighlight lang="j">cross=: {{ ((1|.x)*2|.y) - (2|.x)*1|.y }}</syntaxhighlight>
 
 
However, there are other valid approaches. For example, a "generalized approach" based on [[j:Essays/Complete Tensor]]:
Line 2,312 ⟶ 2,315:
An alternative definition for cross (based on finding the determinant of a 3 by 3 matrix where one row is unit vectors) could be:
<syntaxhighlight lang="j">cross=: [: > [: -&.>/ .(*&.>) (<"1=i.3) , ,:&:(<"0)</syntaxhighlight>
or
<syntaxhighlight lang="j">cross=: {{ >-L:0/ .(*L:0) (<"1=i.3), x,:&:(<"0) y}}</syntaxhighlight>
 
With an implementation of cross product and inner product, the rest of the task becomes trivial:
6,962

edits