public function entrywise(self $value) : self { $this->checkEqualSize($value); return $this->map(function (float $element, int $i, int $j) use($value) { return $element * $value->get($i, $j); }); }
public function testEntrywise() { $matrix1 = new Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]); $matrix2 = $matrix1->transpose(); static::assertEquals([[1, 8, 21], [8, 25, 48], [21, 48, 81]], $matrix1->entrywise($matrix2)->toArray()); }