The vector cross product \(\mathbf{u}\times\mathbf{v}\) for \(\mathbf{u},\mathbf{v}\in\mathbb{R}^3\) is defined in elementary school as

$$ \mathbf{u}\times\mathbf{v}=\left(u_2v_3-u_3v_2,u_2v_3-u_3v_2,u_2v_3-u_3v_2\right). $$

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 \(\mathbb{R}^n\), 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)

Arguments

M

Matrix with one more row than column; columns are interpreted as vectors

u,v

Vectors of length 3, representing vectors in \(\mathbb{R}^3\)

Value

Returns a vector

Details

A joint function profile for vector_cross_product() and vcp3() is given with the package at vignette("vector_cross_product").

Author

Robin K. S. Hankin

See also

cross

Examples


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  =  -1.332268e-15
#>  3  =  -1.873501e-16
#>  4  =  -6.661338e-16
#>  2  =   7.389922e-16
#>  5  =  -8.881784e-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  =   1.09009902
#>  3  =  -0.05436012
#>  1  =   2.95278363
#>  5  =   2.97561675
#>  2  =  -0.02783152
#>  6  =   3.24270154