Learn R Programming

rvec (version 1.0.1)

rvec-matrix-mult: Matrix Multiplication with Rvecs

Description

Matrix multiplication %*% can be used with rvecs, provided that the version of R in use is version 4.3.0 or higher.

Usage

# S4 method for Matrix,rvec
%*%(x, y)

# S4 method for rvec,Matrix %*%(x, y)

Value

An rvec if one or both of the inputs is an rvec; otherwise the default %*% result.

Arguments

x, y

Vectors, matrices, or rvecs

Details

Multiplying an rvec by a matrix produces an rvec, with no dimensions. This is different from an ordinary R vector: multiplying an ordinary vector by a matrix produces a row or column matrix.

Examples

Run this code
if (getRversion() >= "4.3.0") {
  A <- matrix(c(10, 10, 10,
                11, 11, 11),
              nrow = 2, byrow = TRUE)
  x <- rvec(list(c(1, 2),
                 c(3, 4),
                 c(5, 6)))
  A %*% x
}

Run the code above in your browser using DataLab