map() public method

Iterates over the current matrix with a callback function to return a new matrix with the mapped values. $callback takes four arguments: - The current matrix element - The current row - The current column - The matrix being iterated over
public map ( callable $callback ) : self
$callback callable
return self
 public function testMap()
 {
     $matrix = new Matrix([[1, 2], [3, 4]]);
     $mapped = $matrix->map(function ($value, $row, $column) {
         return $value + $row + $column;
     });
     static::assertEquals(1, $mapped->get(0, 0));
     static::assertEquals(3, $mapped->get(0, 1));
     static::assertEquals(4, $mapped->get(1, 0));
     static::assertEquals(6, $mapped->get(1, 1));
 }