mat_2_arr: Creates a rank-3 array from a matrix

View source: R/mat_2_arr.R

mat_2_arrR Documentation

Creates a rank-3 array from a matrix

Description

Takes a matrix, (z_{ij})_{m \times n}, pertaining to an image along with limits of the x and the y axis values.
Returns a rank-3 array, T_{m,n,p}, which is 3-slice, i.e. p \in \{1, 2, 3\}.
T_{m,n,1} is the matrix, (z_{ij})_{m \times n}, while T_{m,n,2} and T_{m,n,3} are the X-natrix and the Y-matrix.
Please see details

Usage

mat_2_arr(mat, x.lim, y.lim)

Arguments

mat

The input matrix, (z_{ij})_{m \times n}

x.lim

The limits of the x-values of the X \times Y grid of the matrix.
x.lim = c(xmin, xmax)

y.lim

The limits of the y-values of the X \times Y grid of the matrix.
y.lim = c(ymin, ymax)

Details

For clearer picture of the structure of the rank-3 array T_{m,n,p}, see image below.
array.png

Value

Returns a rank-3 array, T_{m,n,p}, which is 3-slice, i.e. p \in \{1, 2, 3\}

Author(s)

Chitran Ghosal

Examples

###Build the matrix
sines <- function(X, Y){
  l1 <- 2*X +3*Y
  l2 <- 4*X + 2*Y
  return(sin(l1) + sin(l2))
}
M <- function_2D(X = seq(-10, 10, by = 0.01), Y = seq(-5, 5, by = 0.01), func = sines)


#Call the mat_2_arr function
arr <- mat_2_arr(mat = M, x.lim = c(-10, 10), y.lim = c(-5, 5))

#Plot the built array to verify
plot2D.arr(arr = arr)


Chitran1987/StatsChitran documentation built on Feb. 23, 2025, 8:30 p.m.