ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Division.php
Go to the documentation of this file.
1<?php
2
3namespace Matrix\Operators;
4
7use \Matrix\Matrix;
8use \Matrix\Functions;
9
11{
19 public function execute($value, string $type = 'division'): Operator
20 {
21 if (is_array($value)) {
22 $value = new Matrix($value);
23 }
24
25 if (is_object($value) && ($value instanceof Matrix)) {
26 $value = Functions::inverse($value, $type);
27
28 return $this->multiplyMatrix($value, $type);
29 } elseif (is_numeric($value)) {
30 return $this->multiplyScalar(1 / $value, $type);
31 }
32
33 throw new Exception('Invalid argument for division');
34 }
35}
An exception for terminatinating execution or to throw for unit testing.
static inverse(Matrix $matrix, string $type='inverse')
Return the inverse of this matrix.
Definition: Functions.php:232
execute($value, string $type='division')
Execute the division.
Definition: Division.php:19
multiplyScalar($value, string $type='multiplication')
Execute the multiplication for a scalar.
multiplyMatrix(Matrix $value, string $type='multiplication')
Execute the multiplication for a matrix.
Class for the creating "special" Matrices.
Definition: Builder.php:11
$type