mx: Numerical and Symbolic Matrix Product

View source: R/operators.R

mxR Documentation

Numerical and Symbolic Matrix Product

Description

Multiplies two numeric or character matrices, if they are conformable. If one argument is a vector, it will be promoted to either a row or column matrix to make the two arguments conformable. If both are vectors of the same length, it will return the inner product (as a matrix).

Usage

mx(x, y)

x %mx% y

Arguments

x

numeric or character matrix.

y

numeric or character matrix.

Value

matrix.

Functions

  • x %mx% y: binary operator.

References

Guidotti E (2022). "calculus: High-Dimensional Numerical and Symbolic Calculus in R." Journal of Statistical Software, 104(5), 1-37. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v104.i05")}

See Also

Other matrix algebra: mxdet(), mxinv(), mxtr()

Examples

### numeric inner product 
x <- 1:4
mx(x, x)

### symbolic inner product 
x <- letters[1:4]
mx(x, x)

### numeric matrix product
x <- letters[1:4]
y <- diag(4)
mx(x, y)

### symbolic matrix product
x <- array(1:12, dim = c(3,4))
y <- letters[1:4]
mx(x, y)

### binary operator
x <- array(1:12, dim = c(3,4))
y <- letters[1:4]
x %mx% y


calculus documentation built on March 31, 2023, 11:03 p.m.