Learn R Programming

cpr (version 0.4.1)

build_tensor: Build Tensor

Description

Tensor products of Matrices.

Usage

build_tensor(x = NULL, y = NULL, ...)

Value

a matrix

A matrix

Arguments

x

a matrix

y

a matrix

...

additional numeric matrices to build the tensor product

See Also

vignette("cnr", package = "cpr") for details on tensor products.

Examples

Run this code

A <- matrix(1:4, nrow = 10, ncol = 20)
B <- matrix(1:6, nrow = 10, ncol = 6)

# Two ways of building the same tensor product
tensor1 <- build_tensor(A, B)
tensor2 <- do.call(build_tensor, list(A, B))
all.equal(tensor1, tensor2)

# a three matrix tensor product
tensor3 <- build_tensor(A, B, B)
str(tensor3)

Run the code above in your browser using DataLab