genMatrixMult: Generalized matrix multiplication

Description Usage Arguments Value Author(s) See Also Examples

View source: R/genMatrixMult.r

Description

Computes a generalized matrix multiplication, where sum and product functions (elemet-wise and summary functions) can be replaced by arbitrary functions.

Usage

1
genMatrixMult(A, B, FUNelement = "*", FUNsummary = sum)

Arguments

A

The first matrix.

B

The second matrix.

FUNelement

Element-wise operator.

FUNsummary

Summary function.

Value

A character vector or matrix.

Author(s)

Aleš Žiberna

See Also

matmult

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Operations can be anything
x <- matrix(letters[1:8], ncol = 2)
y <- matrix(1:10, nrow = 2)

genMatrixMult(x, y, FUNelement = paste,
FUNsummary = function(x) paste(x, collapse = "|"))

# Binary logic
set.seed(1)
x <- matrix(rbinom(8, size = 1, prob = 0.5) == 1, ncol = 2)
y <- matrix(rbinom(10, size = 1, prob = 0.5) == 1, nrow = 2)
genMatrixMult(x, y, FUNelement = "*", FUNsummary = any)

blockmodelingRoxygen2 documentation built on June 9, 2020, 3:30 p.m.