cartesianSquare
Return the Cartesian square.
Usage
var cartesianSquare = require( '@stdlib/array/cartesian-square' );
cartesianSquare( x )
Returns the Cartesian square.
var x = [ 1, 2 ];
var out = cartesianSquare( x );
// returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ]
If provided an empty array, the function returns an empty array.
var out = cartesianSquare( [] );
// returns []
Examples
var linspace = require( '@stdlib/array/linspace' );
var cartesianSquare = require( '@stdlib/array/cartesian-square' );
var x = linspace( 0, 5, 6 );
var out = cartesianSquare( x );
// returns [ [ 0, 0 ], [ 0, 1 ], ..., [ 5, 4 ], [ 5, 5 ] ]