onionmat: Onionic matrices

onionmatR Documentation

Onionic matrices

Description

Simple functionality for quaternionic and octonionic matrices, intended for use in the jordan package. Use idiom like matrix(Him,4,5) or matrix(roct(6),2,3) to create an onionmat object, a matrix of onions.

The package is intended to match base R's matrix functionality in the sense that standard R idiom just goes through for onionic matrices. Determinants are not well-defined for quaternionic or octonionic matrices, and matrix inverses are not implemented.

Usage

newonionmat(d, M)
onionmat(data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL)
as.onionmat(x)
is.onionmat(x)
onionmat_negative(e1)
onionmat_inverse(e1)
onionmat_prod_onionmat(e1,e2)
onionmat_power_onionmat(...)
onionmat_prod_single(x,y)
onionmat_power_single(e1,e2)
onionmat_plus_onionmat(e1,e2)
matrix_arith_onion(e1,e2)
onion_arith_matrix(e1,e2)
matrix_plus_onion(e1,e2)
matrix_prod_onion(e1,e2)
## S4 method for signature 'onionmat,onionmat'
cprod(x,y)
## S4 method for signature 'onionmat,missing'
cprod(x,y)
## S4 method for signature 'onionmat,ANY'
cprod(x,y)
## S4 method for signature 'ANY,ANY'
cprod(x,y)
## S4 method for signature 'onion,missing'
cprod(x,y)
## S4 method for signature 'onion,onion'
cprod(x,y)
## S4 method for signature 'onion,onionmat'
cprod(x,y)
## S4 method for signature 'onionmat,onion'
cprod(x,y)
## S4 method for signature 'onionmat,onionmat'
tcprod(x,y)
## S4 method for signature 'onionmat,missing'
tcprod(x,y)
## S4 method for signature 'onionmat,ANY'
tcprod(x,y)
## S4 method for signature 'ANY,ANY'
tcprod(x,y)
## S4 method for signature 'onion,missing'
cprod(x,y)
## S4 method for signature 'onion,onion'
cprod(x,y)
## S4 method for signature 'onion,onionmat'
cprod(x,y)
## S4 method for signature 'onionmat,onion'
cprod(x,y)
## S4 method for signature 'onionmat'
t(x)
## S4 method for signature 'onion'
t(x)
## S4 method for signature 'onionmat'
ht(x)
## S4 method for signature 'onion'
ht(x)
nrow(x)
ncol(x)
herm_onion_mat(real_diagonal, onions)
onionmat_complex(z)
onionmat_conjugate(z)
onionmat_imag(z)
onionmat_re(z)
onionmat_mod(z)
onionmat_matrixprod_onionmat(x,y)
onion_matrixprod_onionmat(x,y)
onionmat_matrixprod_numeric(x,y)
onionmat_matrixprod_onion(x,y)

Arguments

d, M

data and matrix index

x, y, z, e1, e2

Objects of class onionmat

data, nrow, ncol, byrow, dimnames

In function onionmat(), as for matrix()

...

Further arguments (currently ignored)

real_diagonal, onions

In function herm_onion_mat(), on- and off- diagonal elements of an Hermitian matrix

Details

An object of class onionmat is a two-element list, the first of which is an onion, and the second an index matrix of integers used for tracking attributes such as dimensions and dimnames. This device makes the extraction and replacement methods easy. Use getM() to access the index matrix and getd() to access the onionic vector.

The S4 method for matrix() simply dispatches to onionmat(), which is a drop-in replacement for matrix().

Function drop() has a method for onionmat objects.

Function newonionmat() is lower-level. It also creates onionmat objects, but takes two arguments: an onion and a matrix; the matrix argument can be used to specify additional attributes via attr(), but this ability is not currently used in the package.

Functions such as onionmat_plus_onionmat() are low-level helper functions, not really designed for the end-user.

Vignette onionmat shows some use-cases.

The print method for onionmat objects is sensitive to option show_onionmats_in_place. If TRUE, it prints the matrix elements in-place, using onion_to_string(). It works best when option show_onions_compactly is effective.

Author(s)

Robin K. S. Hankin

Examples


matrix(rquat(28),4,7)

M <- onionmat(rquat(10),2,5)
cprod(M) 

Re(M)
Re(M) <- 0.3

romat() %*% rquat(6)

a <- rsomat()
a            # default
options("show_onionmats_in_place" = TRUE)
a
options("show_onionmats_in_place" = FALSE) # restore default



RobinHankin/onion documentation built on April 20, 2024, 2:05 p.m.