From 75160b12821f7f4299cce7f0b69c83c1502ae071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Mon, 27 May 2024 13:08:29 +0200 Subject: 2024-02-19 upstream --- .../matrix/classes/src/Operations/add.php | 46 +++++++++++++++++++++ .../matrix/classes/src/Operations/directsum.php | 46 +++++++++++++++++++++ .../matrix/classes/src/Operations/divideby.php | 46 +++++++++++++++++++++ .../matrix/classes/src/Operations/divideinto.php | 47 ++++++++++++++++++++++ .../matrix/classes/src/Operations/multiply.php | 46 +++++++++++++++++++++ .../matrix/classes/src/Operations/subtract.php | 46 +++++++++++++++++++++ 6 files changed, 277 insertions(+) create mode 100644 vendor/markbaker/matrix/classes/src/Operations/add.php create mode 100644 vendor/markbaker/matrix/classes/src/Operations/directsum.php create mode 100644 vendor/markbaker/matrix/classes/src/Operations/divideby.php create mode 100644 vendor/markbaker/matrix/classes/src/Operations/divideinto.php create mode 100644 vendor/markbaker/matrix/classes/src/Operations/multiply.php create mode 100644 vendor/markbaker/matrix/classes/src/Operations/subtract.php (limited to 'vendor/markbaker/matrix/classes/src/Operations') diff --git a/vendor/markbaker/matrix/classes/src/Operations/add.php b/vendor/markbaker/matrix/classes/src/Operations/add.php new file mode 100644 index 0000000..5ac9a5e --- /dev/null +++ b/vendor/markbaker/matrix/classes/src/Operations/add.php @@ -0,0 +1,46 @@ + $matrixValues The matrices to add + * @return Matrix + * @throws Exception + */ +if (!function_exists(__NAMESPACE__ . '\\add')) { + function add(...$matrixValues): Matrix + { + if (count($matrixValues) < 2) { + throw new Exception('Addition operation requires at least 2 arguments'); + } + + $matrix = array_shift($matrixValues); + + if (is_array($matrix)) { + $matrix = new Matrix($matrix); + } + if (!$matrix instanceof Matrix) { + throw new Exception('Addition arguments must be Matrix or array'); + } + + $result = new Addition($matrix); + + foreach ($matrixValues as $matrix) { + $result->execute($matrix); + } + + return $result->result(); + } +} diff --git a/vendor/markbaker/matrix/classes/src/Operations/directsum.php b/vendor/markbaker/matrix/classes/src/Operations/directsum.php new file mode 100644 index 0000000..21c0c62 --- /dev/null +++ b/vendor/markbaker/matrix/classes/src/Operations/directsum.php @@ -0,0 +1,46 @@ + $matrixValues The matrices to add + * @return Matrix + * @throws Exception + */ +if (!function_exists(__NAMESPACE__ . '\\directsum')) { + function directsum(...$matrixValues): Matrix + { + if (count($matrixValues) < 2) { + throw new Exception('DirectSum operation requires at least 2 arguments'); + } + + $matrix = array_shift($matrixValues); + + if (is_array($matrix)) { + $matrix = new Matrix($matrix); + } + if (!$matrix instanceof Matrix) { + throw new Exception('DirectSum arguments must be Matrix or array'); + } + + $result = new DirectSum($matrix); + + foreach ($matrixValues as $matrix) { + $result->execute($matrix); + } + + return $result->result(); + } +} diff --git a/vendor/markbaker/matrix/classes/src/Operations/divideby.php b/vendor/markbaker/matrix/classes/src/Operations/divideby.php new file mode 100644 index 0000000..5dd0b19 --- /dev/null +++ b/vendor/markbaker/matrix/classes/src/Operations/divideby.php @@ -0,0 +1,46 @@ + $matrixValues The matrices to divide + * @return Matrix + * @throws Exception + */ +if (!function_exists(__NAMESPACE__ . '\\divideby')) { + function divideby(...$matrixValues): Matrix + { + if (count($matrixValues) < 2) { + throw new Exception('Division operation requires at least 2 arguments'); + } + + $matrix = array_shift($matrixValues); + + if (is_array($matrix)) { + $matrix = new Matrix($matrix); + } + if (!$matrix instanceof Matrix) { + throw new Exception('Division arguments must be Matrix or array'); + } + + $result = new Division($matrix); + + foreach ($matrixValues as $matrix) { + $result->execute($matrix); + } + + return $result->result(); + } +} diff --git a/vendor/markbaker/matrix/classes/src/Operations/divideinto.php b/vendor/markbaker/matrix/classes/src/Operations/divideinto.php new file mode 100644 index 0000000..dfbb2df --- /dev/null +++ b/vendor/markbaker/matrix/classes/src/Operations/divideinto.php @@ -0,0 +1,47 @@ + $matrixValues The numbers to divide + * @return Matrix + * @throws Exception + */ +if (!function_exists(__NAMESPACE__ . '\\divideinto')) { + function divideinto(...$matrixValues): Matrix + { + if (count($matrixValues) < 2) { + throw new Exception('Division operation requires at least 2 arguments'); + } + + $matrix = array_pop($matrixValues); + $matrixValues = array_reverse($matrixValues); + + if (is_array($matrix)) { + $matrix = new Matrix($matrix); + } + if (!$matrix instanceof Matrix) { + throw new Exception('Division arguments must be Matrix or array'); + } + + $result = new Division($matrix); + + foreach ($matrixValues as $matrix) { + $result->execute($matrix); + } + + return $result->result(); + } +} diff --git a/vendor/markbaker/matrix/classes/src/Operations/multiply.php b/vendor/markbaker/matrix/classes/src/Operations/multiply.php new file mode 100644 index 0000000..45ecc77 --- /dev/null +++ b/vendor/markbaker/matrix/classes/src/Operations/multiply.php @@ -0,0 +1,46 @@ + $matrixValues The matrices to multiply + * @return Matrix + * @throws Exception + */ +if (!function_exists(__NAMESPACE__ . '\\multiply')) { + function multiply(...$matrixValues): Matrix + { + if (count($matrixValues) < 2) { + throw new Exception('Multiplication operation requires at least 2 arguments'); + } + + $matrix = array_shift($matrixValues); + + if (is_array($matrix)) { + $matrix = new Matrix($matrix); + } + if (!$matrix instanceof Matrix) { + throw new Exception('Multiplication arguments must be Matrix or array'); + } + + $result = new Multiplication($matrix); + + foreach ($matrixValues as $matrix) { + $result->execute($matrix); + } + + return $result->result(); + } +} diff --git a/vendor/markbaker/matrix/classes/src/Operations/subtract.php b/vendor/markbaker/matrix/classes/src/Operations/subtract.php new file mode 100644 index 0000000..72759b7 --- /dev/null +++ b/vendor/markbaker/matrix/classes/src/Operations/subtract.php @@ -0,0 +1,46 @@ + $matrixValues The matrices to subtract + * @return Matrix + * @throws Exception + */ +if (!function_exists(__NAMESPACE__ . '\\subtract')) { + function subtract(...$matrixValues): Matrix + { + if (count($matrixValues) < 2) { + throw new Exception('Subtraction operation requires at least 2 arguments'); + } + + $matrix = array_shift($matrixValues); + + if (is_array($matrix)) { + $matrix = new Matrix($matrix); + } + if (!$matrix instanceof Matrix) { + throw new Exception('Subtraction arguments must be Matrix or array'); + } + + $result = new Subtraction($matrix); + + foreach ($matrixValues as $matrix) { + $result->execute($matrix); + } + + return $result->result(); + } +} -- cgit v1.2.3