Skip to content

Latest commit

 

History

History
65 lines (43 loc) · 1.18 KB

repeat.md

File metadata and controls

65 lines (43 loc) · 1.18 KB

repeat

Repeat each element or tile the whole array several times.

API

Numeric.shape.repeat(input, repeats, times, level)

Repeats entries or tiles the whole array.

  • Parameters:
    • input: Array whose entries are repeated
    • repeats: Number of repetitions applied
    • times: When true tiles the whole array instead
    • level: Optional axis when repeating a matrix or tile flag
  • Returns: Array holding the repeated values
  • NumPy: Covers np.repeat, np.tile, ndarray.repeat through a single Numerix method.

Examples

Repeat each element

import Numeric from '@neabyte/numerix'

const values = Numeric.shape.repeat([1, 2], 2)

console.log(values)
// [1,1,2,2]

Tile the whole array

import Numeric from '@neabyte/numerix'

const values = Numeric.shape.repeat([1, 2], 2, true)

console.log(values)
// [1,2,1,2]

Repeat each element three times

import Numeric from '@neabyte/numerix'

const values = Numeric.shape.repeat([1, 2], 3)

console.log(values)
// [1,1,1,2,2,2]

Tile a matrix

import Numeric from '@neabyte/numerix'

const matrix = Numeric.shape.repeat([[1, 2]], 2, true)

console.log(matrix)
// [[1,2,1,2]]