ArrayPad
✖
ArrayPad
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 pads full arrays of any depth.
- ArrayPad works with SparseArray objects.
- ArrayPad[array,-m] removes m elements from each side of array.
Examples
open allclose allBasic Examples (6)Summary of the most common use cases
Pad the edges of a list with 0s:

https://wolfram.com/xid/0tzy3rvs-cij4mg


https://wolfram.com/xid/0tzy3rvs-koulz

Specify different padding on each side:

https://wolfram.com/xid/0tzy3rvs-ne5w3g


https://wolfram.com/xid/0tzy3rvs-ci1cs4

Pad according to a named rule:

https://wolfram.com/xid/0tzy3rvs-5fjuj

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

https://wolfram.com/xid/0tzy3rvs-u5l3g6

Scope (12)Survey of the scope of standard use cases

https://wolfram.com/xid/0tzy3rvs-dzdkvw

Remove elements from each edge of an array:

https://wolfram.com/xid/0tzy3rvs-knngs


https://wolfram.com/xid/0tzy3rvs-mkgvda


https://wolfram.com/xid/0tzy3rvs-mt39t

Specify different padding for each edge:

https://wolfram.com/xid/0tzy3rvs-degbwo

Pad only the first level of an array:

https://wolfram.com/xid/0tzy3rvs-egsd77

Pad by repeating periodically:

https://wolfram.com/xid/0tzy3rvs-dehf7e

Pad with the reversal of the list:

https://wolfram.com/xid/0tzy3rvs-qpkfr

Pad with the negative of the reversal:

https://wolfram.com/xid/0tzy3rvs-ldsb8a

Pad by reflecting about the edge:

https://wolfram.com/xid/0tzy3rvs-sme52

Pad antisymmetrically about the value at the edge:

https://wolfram.com/xid/0tzy3rvs-ntyqgp


https://wolfram.com/xid/0tzy3rvs-ipk9j

Pad antisymmetrically about the edge of the array with reversed differences:

https://wolfram.com/xid/0tzy3rvs-pojqqw

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

https://wolfram.com/xid/0tzy3rvs-cvlic9

Pad using linear extrapolation:

https://wolfram.com/xid/0tzy3rvs-bsohej

Pad using extrapolation of different orders:

https://wolfram.com/xid/0tzy3rvs-bevzfp

Pad using the maximal extrapolation order:

https://wolfram.com/xid/0tzy3rvs-5gbef

Generalizations & Extensions (1)Generalized and extended use cases
ArrayPad works with SparseArray objects:

https://wolfram.com/xid/0tzy3rvs-9ikxw


https://wolfram.com/xid/0tzy3rvs-jqt25

Options (3)Common values & functionality for each option
InterpolationOrder (3)
Specify the order of interpolation for "Extrapolated" padding:

https://wolfram.com/xid/0tzy3rvs-mv9mcx

By default, linear interpolation is used:

https://wolfram.com/xid/0tzy3rvs-ebuzqx

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

https://wolfram.com/xid/0tzy3rvs-b1hl4

Applications (1)Sample problems that can be solved with this function
Properties & Relations (2)Properties of the function, and connections to other functions
PadLeft[list,n] and PadRight[list,n] pad to make a list of length n:

https://wolfram.com/xid/0tzy3rvs-kqmb9k


https://wolfram.com/xid/0tzy3rvs-c3x83m

ArrayPad[list,n] pads with n additional elements on each side:

https://wolfram.com/xid/0tzy3rvs-bhmmq

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

https://wolfram.com/xid/0tzy3rvs-jl2r46

ArrayPad[list,{0,-n}] is effectively Drop[list,-n]:

https://wolfram.com/xid/0tzy3rvs-mmsai

Possible Issues (2)Common pitfalls and unexpected behavior
A single number or pair of numbers is interpreted to apply in each dimension:

https://wolfram.com/xid/0tzy3rvs-i0m1so


Explicitly specify the padding amount in each dimension:

https://wolfram.com/xid/0tzy3rvs-happol

Normally even empty array dimensions are padded:

https://wolfram.com/xid/0tzy3rvs-gq9a2b

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

https://wolfram.com/xid/0tzy3rvs-kco7sx

Neat Examples (1)Surprising or curious use cases
Wolfram Research (2008), ArrayPad, Wolfram Language function, https://reference.wolfram.com/language/ref/ArrayPad.html.
Text
Wolfram Research (2008), ArrayPad, Wolfram Language function, https://reference.wolfram.com/language/ref/ArrayPad.html.
Wolfram Research (2008), ArrayPad, Wolfram Language function, https://reference.wolfram.com/language/ref/ArrayPad.html.
CMS
Wolfram Language. 2008. "ArrayPad." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ArrayPad.html.
Wolfram Language. 2008. "ArrayPad." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ArrayPad.html.
APA
Wolfram Language. (2008). ArrayPad. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ArrayPad.html
Wolfram Language. (2008). ArrayPad. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ArrayPad.html
BibTeX
@misc{reference.wolfram_2025_arraypad, author="Wolfram Research", title="{ArrayPad}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/ArrayPad.html}", note=[Accessed: 24-March-2025
]}
BibLaTeX
@online{reference.wolfram_2025_arraypad, organization={Wolfram Research}, title={ArrayPad}, year={2008}, url={https://reference.wolfram.com/language/ref/ArrayPad.html}, note=[Accessed: 24-March-2025
]}