vector_cross_product.Rd
The vector cross product u×v for u,v∈R3 is defined in elementary school as
u×v=(u2v3−u3v2,u2v3−u3v2,u2v3−u3v2).
Function vcp3()
is a convenience wrapper for this. However, the
vector cross product may easily be generalized to a product of
n−1-tuples of vectors in Rn, given by
package function vector_cross_product()
.
Vignette vector_cross_product
, supplied with the package, gives
an extensive discussion of vector cross products, including formal
definitions and verification of identities.
vector_cross_product(M)
vcp3(u,v)
Returns a vector
A joint function profile for vector_cross_product()
and
vcp3()
is given with the package at
vignette("vector_cross_product")
.
vector_cross_product(matrix(1:6,3,2))
#> [1] -3 6 -3
M <- matrix(rnorm(30),6,5)
LHS <- hodge(as.1form(M[,1])^as.1form(M[,2])^as.1form(M[,3])^as.1form(M[,4])^as.1form(M[,5]))
RHS <- as.1form(vector_cross_product(M))
LHS-RHS # zero to numerical precision
#> An alternating linear map from V^1 to R with V=R^6:
#> val
#> 6 = 8.881784e-16
#> 3 = 8.881784e-16
#> 4 = 1.332268e-15
#> 2 = -1.776357e-15
#> 1 = -1.110223e-15
#> 5 = -7.771561e-16
# Alternatively:
hodge(Reduce(`^`,sapply(seq_len(5),function(i){as.1form(M[,i])},simplify=FALSE)))
#> An alternating linear map from V^1 to R with V=R^6:
#> val
#> 4 = 3.808014
#> 3 = 6.846451
#> 1 = -1.078148
#> 5 = 0.435129
#> 2 = 5.008247
#> 6 = 3.890867