PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.8
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.8
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 3.10.4 All 148 releases
visualizer / vendor / markbaker / matrix / classes / src / Operators / Division.php

Division.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.4.8, at vendor/markbaker/matrix/classes/src/Operators/Division.php

39 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Matrix\Operators;
4
5 use \Matrix\Matrix;
6 use \Matrix\Functions;
7 use Matrix\Exception;
8
9 class Division extends Multiplication
10 {
11 /**
12 * Execute the division
13 *
14 * @param mixed $value The matrix or numeric value to divide the current base value by
15 * @throws Exception If the provided argument is not appropriate for the operation
16 * @return $this The operation object, allowing multiple divisions to be chained
17 **/
18 public function execute($value)
19 {
20 if (is_array($value)) {
21 $value = new Matrix($value);
22 }
23
24 if (is_object($value) && ($value instanceof Matrix)) {
25 try {
26 $value = Functions::inverse($value);
27 } catch (Exception $e) {
28 throw new Exception('Division can only be calculated using a matrix with a non-zero determinant');
29 }
30
31 return $this->multiplyMatrix($value);
32 } elseif (is_numeric($value)) {
33 return $this->multiplyScalar(1 / $value);
34 }
35
36 throw new Exception('Invalid argument for division');
37 }
38 }
39