check_commute: Symbolically Represent Matrix Commutation

Description Usage Arguments Value Examples

View source: R/check_commute.R

Description

This function generates symbolic matrices representing those that might commute with a particular matrix M (i.e., AM = MA). This only applies to square matrices; passing a nonsquare matrix will cause an error. This function returns a matrix of the input matrix's dimension, with each element consisting of an equation, where the left side is that element's value multiplying on the left and the right its value multiplying on the right. All matrices whose elements satisfy all the equations commute with M.

All n x n matrices trivially commute with the corresponding identity and zero matrix, as well as the inverse, if it exists.

Usage

1
2
3
4
5
6
7
check_commute(
  m,
  syms = matrix(rep_len(letters, length.out = prod(dim(m))), nrow = nrow(m), byrow =
    TRUE),
  latex = FALSE,
  sink = TRUE
)

Arguments

m

An n x n matrix of dimension greater than 1 whose commutativity will be tested.

syms

Character vector of symbols to use to represent the commuting matrix A. Must have the same dimensions as @param m. Defaults to the first n^2 letters of the alphabet, entered rowwise, as is conventional. If @param m has dimension 6 (implying 36 elements) or greater, letters are recycled as needed. If @param syms includes digits and/or punctuation, an error results.

latex

is false.

sink

Argument passed on to mat2latex. Defaults to FALSE, ignored if

Value

An n x n matrix, where each element is an equation whose left-hand side represents that element's value in AM and the right-hand side its value in MA.

Examples

1
2
3
4
check_commute(matrix(1:4, nrow = 2))
#Automatically drops zeroed terms
m <- matrix(sample(-1:1, 9, replace = TRUE), nrow = 3)
check_commute(m)

ryan-heslin/matador documentation built on Dec. 22, 2021, 8:17 p.m.