hasEqualShape

Test if two ndarrays have the same shape.

Usage

var hasEqualShape = require( '@stdlib/ndarray/base/assert/has-equal-shape' );

hasEqualShape( x, y )

Tests if two ndarrays have the same shape.

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

var x = array( [ 1, 2, 3, 4 ] );
var y = array( [ 5, 6, 7, 8 ] );

var bool = hasEqualShape( x, y );
// returns true

Examples

var array = require( '@stdlib/ndarray/array' );
var hasEqualShape = require( '@stdlib/ndarray/base/assert/has-equal-shape' );

var x1 = array( [ [ 1, 2 ], [ 3, 4 ] ] );
var y1 = array( [ [ 5, 6 ], [ 7, 8 ] ] );

var bool = hasEqualShape( x1, y1 );
// returns true

var x2 = array( [ [ 1, 2 ], [ 3, 4 ] ] );
var y2 = array( [ [ 5, 6 ], [ 7, 8 ], [ 9, 10 ] ] );

bool = hasEqualShape( x2, y2 );
// returns false
Did you find this page helpful?