Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

tile

Return an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.

Usage

var tile = require( '@stdlib/ndarray/base/tile' );

tile( x, reps )

Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.

var array = require( '@stdlib/ndarray/array' );

var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
// returns <ndarray>[ [ 1, 2 ], [ 3, 4 ] ]

var y = tile( x, [ 2, 2 ] );
// returns <ndarray>[ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]

The function accepts the following arguments:

  • x: input ndarray.
  • reps: list specifying the number of times to repeat elements of an input ndarray along each dimension.

Notes

  • The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input ndarray is treated as if singleton dimensions were prepended.
  • The function always copies data to a new ndarray.

Examples

var array = require( '@stdlib/ndarray/array' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var tile = require( '@stdlib/ndarray/base/tile' );

// Create a 2x2 array:
var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
console.log( ndarray2array( x ) );

// Tile the array to 4x4:
var out = tile( x, [ 2, 2 ] );
console.log( ndarray2array( out ) );