MCordingley\LinearAlgebra\Matrix::entrywise PHP Метод

entrywise() публичный Метод

public entrywise ( self $value ) : self
$value self
Результат self
    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);
        });
    }

Usage Example

Пример #1
0
 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());
 }