mat.size: Sizes a matrix down to its mask but doesn't etch the values...

View source: R/mat.size.R

mat.sizeR Documentation

Sizes a matrix down to its mask but doesn't etch the values within

Description

Transforms a matrix called org, represented by \mathbf{Z} = (z_{ij})_{p\times q}, using a matrix called mask, represented by \mathbf{M} = (m_{ij})_{p \times q}.
Both matrices, org and mask have the same dimensionality, i.e. p \times q.
org is real or complex, but mask is necessarily boolean, i.e. \mathbf{Z} \in \mathbb{C}^{p\times q}\,\wedge \, \mathbf{M}\in\mathbb{B}^{p\times q}.
mat.size weans org down to the bare minimum size equivalent to mask, but does NOT etch the org at all.
This is the difference between mat.size and mat.mask(org, mask, drop.dat = T).
See also mat.mask and description

Usage

mat.size(org, mask)

Arguments

org

The original data \mathbf{Z}=(z_{ij})_{p\times q} that you want to mask.
Can be numeric, complex or boolean.

mask

The masking matrix \mathbf{M} = (m_{ij})_{p \times q} that you want to use as a mask.
Necessarily boolean.
Should have the same dimensions as the org matrix.

Details

mat.size doesn't etch the matrix org, only sizes it.
Please see figure below.
mat.size.png

Value

The returned value is always a matrix

Author(s)

Chitran Ghosal

Examples

##3.build the function
para <- function(X, Y){
  return((X^2 + Y^2) - (X^2 + Y^2) + 1)
}
##convert to an array, plot and calculate
arr <- func_2_arr(func = para, X = seq(-1.5, 1.5, by = 0.01), Y = seq(-1.5, 1.5, by = 0.01))
plot2D.arr(arr = arr)
##define the mask and then plot it as a matrix
M <- arr[,,2]^2 + arr[,,3]^2 <= 1
image(M, asp=1.0)
##mask matrix M1 and plot
M1 <- mat.mask(org = arr[,,1], mask = M, drop.dat = T)
image(M1, asp=1.0)
##size matrix M2 and plot
M2 <- mat.size(org = arr[,,1], mask = M)
image(M2, asp=1.0)

Chitran1987/StatsChitran documentation built on June 8, 2025, 2:24 a.m.