Add entries around an array using the chosen padding mode.
Numeric.shape.pad(input, width, method = 'constant', value = 0)Adds entries around the array using the chosen mode.
- Parameters:
input: Array to padwidth: Number of entries added on each sidemethod: Padding method applied to the arrayvalue: Constant value used by constant padding
- Returns: Padded array with the added entries
- NumPy: Equivalent to
np.pad.
import Numeric from '@neabyte/numerix'
const values = Numeric.shape.pad([1, 2], 1)
console.log(values)
// [0,1,2,0]import Numeric from '@neabyte/numerix'
const values = Numeric.shape.pad([1, 2], [1, 2])
console.log(values)
// [0,1,2,0,0]import Numeric from '@neabyte/numerix'
const values = Numeric.shape.pad([1, 2], 1, 'edge')
console.log(values)
// [1,1,2,2]import Numeric from '@neabyte/numerix'
const values = Numeric.shape.pad([1, 2], 1, 'constant', 9)
console.log(values)
// [9,1,2,9]