PluginProbe
TablePress – Tables in WordPress made easy / 3.0
TablePress – Tables in WordPress made easy v3.0
3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 2.4.4 All 44 releases
tablepress / libraries / vendor / Matrix / Operators / Division.php

Division.php in TablePress – Tables in WordPress made easy 3.0, at libraries/vendor/Matrix/Operators/Division.php

36 lines 958 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TablePress\Matrix\Operators;
4
5 use TablePress\Matrix\Div0Exception;
6 use TablePress\Matrix\Exception;
7 use \TablePress\Matrix\Matrix;
8 use \TablePress\Matrix\Functions;
9
10 class Division extends Multiplication
11 {
12 /**
13 * Execute the division
14 *
15 * @param mixed $value The matrix or numeric value to divide the current base value by
16 * @throws Exception If the provided argument is not appropriate for the operation
17 * @return $this The operation object, allowing multiple divisions to be chained
18 **/
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 }
36