gives an array with m zeros of padding on every side.

pads with m elements at the beginning and n elements at the end.

pads with mi, ni elements at level i in array.

# Details and Options

• The following forms of padding can be specified:
•  c a constant c {c1,c2,…} cyclic repetition of constants c1,… "Extrapolated" polynomial extrapolation of elements "Fixed" repetitions of the elements on each boundary "Periodic" cyclic repetitions of the complete array "Reflected" reflections of the array in the boundary "ReflectedDifferences" reflections of the differences between elements "Reversed" reversals of the complete array "ReversedDifferences" reversals of the differences between elements "ReversedNegation" negated reversals of the array
• The padding value "Fixed" indicates that the elements added at each corner should be copies of the elements at the corners of the original array.
• "Reversed" indicates that the outermost elements in the array should be repeated as the innermost elements in the padding. "Reflected" specifies that these elements should not be repeated.
• With the padding value "Extrapolated", the degree of polynomial used is specified by the option InterpolationOrder.
• ArrayPad works with SparseArray objects.
• ArrayPad[array,-m] removes m elements from each side of array.

# Examples

open allclose all

## Basic Examples(6)

Pad the edges of a list with 0s:

Pad the edges of a matrix:

Specify different padding on each side:

Pad according to a named rule:

Pad by 5 elements on each row and 1 element on each column:

## Scope(12)

Remove elements from each edge of an array:

Specify different padding for each edge:

Pad only the first level of an array:

Pad with the reversal of the list:

Pad with the negative of the reversal:

The differences are reflected about the edge of the original array:

Pad using extrapolation of different orders:

Pad using the maximal extrapolation order:

## Options(3)

### InterpolationOrder(3)

Specify the order of interpolation for "Extrapolated" padding:

By default, linear interpolation is used:

Use the maximum possible order, in this case order 3:

## Applications(1)

Lay out tiles by reflecting about their edges:

## Properties & Relations(2)

ArrayPad[list,{-n,0}] is effectively Drop[list,n] for a one-dimensional list:

## Possible Issues(2)

A single number or pair of numbers is interpreted to apply in each dimension:

Explicitly specify the padding amount in each dimension:

Normally even empty array dimensions are padded:

With padding types that depend on array values, only nonempty array dimensions are padded:

## Neat Examples(1)

Visualize the different named padding rules: