NdArray::is_square

Check that it's a square matrix.

Description

bool NdArray::is_square()

Parameters

This function has no parameters.

Return Values

A boolean. True if it's a square matrix, false otherwise.

Examples

Example #1: Testing some matrices

use SciPhp\NumPhp as np;

// false, it's a 1-dim
np::ar([123])->is_square();

// true, it's a 3x3
np::ar(
 [[
123],
  [
123],
  [
123]]
)->
is_square();

// false, it's a 4x3
np::ar(
 [[
123],
  [
123],
  [
123],
  [
123]]
)->
is_square();

See Also