inner: Matrix Inner Product

View source: R/utility.R

innerR Documentation

Matrix Inner Product

Description

Calculate the custom matrix inner product z of two matrices, x and y, where z[i,j] = FUN(x[,i], y[,j]).

Usage

inner(x, y, FUN = "crossprod", ...)

Arguments

x, y

matrix or Matrix.

FUN

function or a character(1) name of base function. The function should take in two vectors as input and output a numeric(1) result.

...

additional parameters for FUN.

Value

matrix, inner product of x and y.

Examples

x <- matrix(1:6, 2, 3)
y <- matrix(7:12, 2, 3)
## The default is equivalent to `crossprod(x, y)`
inner(x, y)
## We can compute the pair-wise Euclidean distance of columns.
EuclideanDistance = function(x, y) crossprod(x, y)^2
inner(x, y, EuclideanDistance)


epca documentation built on July 26, 2023, 5:47 p.m.