public static function createIdentityMatrix($dimensions)
    {
        $grid = static::createFilledMatrix(null, $dimensions)->toArray();

        for ($x = 0; $x < $dimensions; ++$x) {
            $grid[$x][$x] = 1;
        }

        return new Matrix($grid);
    }
public static function createIdentityMatrix($dimensions)
    {
        $grid = static::createFilledMatrix(null, $dimensions)->toArray();

        for ($x = 0; $x < $dimensions; ++$x) {
            $grid[$x][$x] = 1;
        }

        return new Matrix($grid);
    }
public static function createIdentityMatrix ( $ dimensions ) { $ grid = static :: createFilledMatrix ( null , $ dimensions ) -> toArray ( ) ; for ( $ x = 0 ; $ x < $ dimensions ; ++ $ x ) { $ grid [ $ x ] [ $ x ] = 1 ; } return new Matrix ( $ grid ) ; }
Create a new identity matrix of specified dimensions
This will always be a square matrix, with the number of rows and columns matching the provided dimension

@param int $dimensions
@return Matrix
@throws Exception
Create a new identity matrix of specified dimensions This will always be a square matrix with the number of rows and columns matching the provided dimension