@stdlib/array-base-cartesian-square
v0.2.2
Published
Return the Cartesian square.
Downloads
222
Readme
cartesianSquare
Return the Cartesian square.
Installation
npm install @stdlib/array-base-cartesian-square
Usage
var cartesianSquare = require( '@stdlib/array-base-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-base-linspace' );
var cartesianSquare = require( '@stdlib/array-base-cartesian-square' );
var x = linspace( 0, 5, 6 );
var out = cartesianSquare( x );
// returns [ [ 0, 0 ], [ 0, 1 ], ..., [ 5, 4 ], [ 5, 5 ] ]
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.