magic (version 1.6-1)

apad: Pad arrays

Description

Generalized padding for arrays of arbitrary dimension

Usage

apad(a, l, e = NULL, method = "ext", post = TRUE)

Arguments

a

Array to be padded

l

Amount of padding to add. If a vector of length greater than one, it is interpreted as the extra extent of a along each of its dimensions (standard recycling is used). If of length one, interpret as the dimension to be padded, in which case the amount is given by argument l.

e

If l is of length one, the amount of padding to add to dimension l

method

String specifying the values of the padded elements. See details section.

post

Boolean, with default TRUE meaning to append to a and FALSE meaning to prepend.

Author

Robin K. S. Hankin

Details

Argument method specifies the values of the padded elements. It can be either “ext”, “mirror”, or “rep”.

Specifying ext (the default) uses a padding value given by the “nearest” element of a, as measured by the Manhattan metric.

Specifying mirror fills the array with alternate mirror images of a; while rep fills it with unreflected copies of a.

See Also

adiag

Examples

Run this code

apad(1:10,4,method="mirror")


a <- matrix(1:30,5,6)

apad(a,c(4,4))
apad(a,c(4,4),post=FALSE)

apad(a,1,5)

apad(a,c(5,6),method="mirror")
apad(a,c(5,6),method="mirror",post=FALSE)

Run the code above in your browser using DataLab