diff --git a/.php_cs.dist b/.php_cs.dist index 29b85d77..88f7f8bb 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -1,10 +1,11 @@ exclude('vendor') + ->exclude(['vendor', 'tests/data/Calculation']) ->in('samples') ->in('src') - ->in('tests'); + ->in('tests/PhpSpreadsheetTests') + ; return PhpCsFixer\Config::create() ->setRiskyAllowed(true) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31079cbd..baeb4477 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org). ## [Unreleased] +### Added + +- Refactored Matrix Functions to use external Matrix library + + ## [1.5.2] - 2018-11-25 ### Security diff --git a/composer.json b/composer.json index 0fb4650a..d533e3c0 100644 --- a/composer.json +++ b/composer.json @@ -53,11 +53,13 @@ "ext-zip": "*", "ext-zlib": "*", "psr/simple-cache": "^1.0", - "markbaker/complex": "^1.4.1" + "markbaker/complex": "^1.4", + "markbaker/matrix": "^1.1" }, "require-dev": { "tecnickcom/tcpdf": "^6.2", "phpunit/phpunit": "^5.7", + "doctrine/instantiator": "^1.0.0", "dompdf/dompdf": "^0.8.0", "mpdf/mpdf": "^7.0.0", "jpgraph/jpgraph": "^4.0", diff --git a/composer.lock b/composer.lock index 20d4273d..64aae870 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "329d0c155c094a31156a653423fdfd94", + "content-hash": "5e66d1016f24ad7d6495ed4d7a04234d", "packages": [ { "name": "markbaker/complex", @@ -101,6 +101,76 @@ ], "time": "2018-10-13T23:28:42+00:00" }, + { + "name": "markbaker/matrix", + "version": "1.1.4", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPMatrix.git", + "reference": "6ea97472b5baf12119b4f31f802835b820dd6d64" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/6ea97472b5baf12119b4f31f802835b820dd6d64", + "reference": "6ea97472b5baf12119b4f31f802835b820dd6d64", + "shasum": "" + }, + "require": { + "php": "^5.6.0|^7.0.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3", + "phpcompatibility/php-compatibility": "^8.0", + "phpdocumentor/phpdocumentor": "2.*", + "phploc/phploc": "2.*", + "phpmd/phpmd": "2.*", + "phpunit/phpunit": "^4.8.35|^5.4.0", + "sebastian/phpcpd": "2.*", + "squizlabs/php_codesniffer": "^3.3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Matrix\\": "classes/src/" + }, + "files": [ + "classes/src/functions/adjoint.php", + "classes/src/functions/antidiagonal.php", + "classes/src/functions/cofactors.php", + "classes/src/functions/determinant.php", + "classes/src/functions/diagonal.php", + "classes/src/functions/identity.php", + "classes/src/functions/inverse.php", + "classes/src/functions/minors.php", + "classes/src/functions/trace.php", + "classes/src/functions/transpose.php", + "classes/src/operations/add.php", + "classes/src/operations/directsum.php", + "classes/src/operations/subtract.php", + "classes/src/operations/multiply.php", + "classes/src/operations/divideby.php", + "classes/src/operations/divideinto.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@lange.demon.co.uk" + } + ], + "description": "PHP Class for working with matrices", + "homepage": "https://github.com/MarkBaker/PHPMatrix", + "keywords": [ + "mathematics", + "matrix", + "vector" + ], + "time": "2018-11-04T22:12:12+00:00" + }, { "name": "psr/simple-cache", "version": "1.0.1", @@ -3137,4 +3207,4 @@ "ext-zlib": "*" }, "platform-dev": [] -} \ No newline at end of file +} diff --git a/docs/references/function-list-by-category.md b/docs/references/function-list-by-category.md index 185bf4c0..9dcfea1d 100644 --- a/docs/references/function-list-by-category.md +++ b/docs/references/function-list-by-category.md @@ -37,6 +37,7 @@ DATE | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DATE DATEDIF | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DATEDIF DATEVALUE | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DATEVALUE DAY | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DAYOFMONTH +DAYS | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DAYS DAYS360 | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DAYS360 EDATE | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::EDATE EOMONTH | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::EOMONTH @@ -45,6 +46,7 @@ ISOWEEKNUM | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::ISOWEEKNUM MINUTE | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::MINUTE MONTH | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::MONTHOFYEAR NETWORKDAYS | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::NETWORKDAYS +NETWORKDAYS.INTL | **Not yet Implemented** NOW | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DATETIMENOW SECOND | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::SECOND TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::TIME @@ -53,6 +55,7 @@ TODAY | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DATENOW WEEKDAY | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::WEEKDAY WEEKNUM | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::WEEKNUM WORKDAY | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::WORKDAY +WORKDAY.INTL | **Not yet Implemented** YEAR | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::YEAR YEARFRAC | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::YEARFRAC @@ -66,7 +69,12 @@ BESSELK | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BESSELK BESSELY | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BESSELY BIN2DEC | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BINTODEC BIN2HEX | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BINTOHEX -BIN2OCT | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BINTOOCT +BIN2OCT | \PhpOffice\PhpSpreadsheet\Calculation\Engineeri +BITAND | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITAND +BITLSHIFT | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITLSHIFT +BITOR | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITOR +BITRSHIFT | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITRSHIFT +BITXOR | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITXOR COMPLEX | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::COMPLEX CONVERT | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::CONVERTUOM DEC2BIN | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::DECTOBIN diff --git a/docs/references/function-list-by-name.md b/docs/references/function-list-by-name.md index a8caca6c..fb6396e4 100644 --- a/docs/references/function-list-by-name.md +++ b/docs/references/function-list-by-name.md @@ -43,6 +43,11 @@ BIN2DEC | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet BIN2HEX | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BINTOHEX BIN2OCT | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BINTOOCT BINOMDIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::BINOMDIST +BITAND | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITAND +BITLSHIFT | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITLSHIFT +BITOR | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITOR +BITRSHIFT | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITRSHIFT +BITXOR | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITXOR ## C @@ -104,6 +109,7 @@ DATEDIF | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet DATEVALUE | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DATEVALUE DAVERAGE | CATEGORY_DATABASE | \PhpOffice\PhpSpreadsheet\Calculation\Database::DAVERAGE DAY | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DAYOFMONTH +DAYS | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DAYS DAYS360 | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DAYS360 DB | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::DB DCOUNT | CATEGORY_DATABASE | \PhpOffice\PhpSpreadsheet\Calculation\Database::DCOUNT @@ -317,6 +323,7 @@ N | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet NA | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::NA NEGBINOMDIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NEGBINOMDIST NETWORKDAYS | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::NETWORKDAYS +NETWORKDAYS.INTL | CATEGORY_DATE_AND_TIME | **Not yet Implemented** NOMINAL | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::NOMINAL NORMDIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NORMDIST NORMINV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NORMINV @@ -494,6 +501,7 @@ WEEKDAY | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet WEEKNUM | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::WEEKNUM WEIBULL | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::WEIBULL WORKDAY | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::WORKDAY +WORKDAY.INTL | CATEGORY_DATE_AND_TIME | **Not yet Implemented** ## X diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php index 666ca798..9170196b 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -2,8 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; -use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; -use PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix; +use Matrix\Exception as MatrixException; +use Matrix\Matrix; class MathTrig { @@ -498,7 +498,7 @@ class MathTrig if ((is_string($matrixCell)) || ($matrixCell === null)) { return Functions::VALUE(); } - $matrixData[$column][$row] = $matrixCell; + $matrixData[$row][$column] = $matrixCell; ++$column; } if ($column > $maxColumn) { @@ -506,15 +506,15 @@ class MathTrig } ++$row; } - if ($row != $maxColumn) { + + $matrix = new Matrix($matrixData); + if (!$matrix->isSquare()) { return Functions::VALUE(); } try { - $matrix = new Matrix($matrixData); - - return $matrix->det(); - } catch (PhpSpreadsheetException $ex) { + return $matrix->determinant(); + } catch (MatrixException $ex) { return Functions::VALUE(); } } @@ -550,7 +550,7 @@ class MathTrig if ((is_string($matrixCell)) || ($matrixCell === null)) { return Functions::VALUE(); } - $matrixData[$column][$row] = $matrixCell; + $matrixData[$row][$column] = $matrixCell; ++$column; } if ($column > $maxColumn) { @@ -558,17 +558,19 @@ class MathTrig } ++$row; } - foreach ($matrixValues as $matrixRow) { - if (count($matrixRow) != $maxColumn) { - return Functions::VALUE(); - } + + $matrix = new Matrix($matrixData); + if (!$matrix->isSquare()) { + return Functions::VALUE(); + } + + if ($matrix->determinant() == 0.0) { + return Functions::NAN(); } try { - $matrix = new Matrix($matrixData); - - return $matrix->inverse()->getArray(); - } catch (PhpSpreadsheetException $ex) { + return $matrix->inverse()->toArray(); + } catch (MatrixException $ex) { return Functions::VALUE(); } } @@ -629,8 +631,8 @@ class MathTrig return Functions::VALUE(); } - return $matrixA->times($matrixB)->getArray(); - } catch (PhpSpreadsheetException $ex) { + return $matrixA->multiply($matrixB)->toArray(); + } catch (MatrixException $ex) { return Functions::VALUE(); } } diff --git a/tests/PhpSpreadsheetTests/Calculation/MathTrigTest.php b/tests/PhpSpreadsheetTests/Calculation/MathTrigTest.php index 8179c367..5b7e1f01 100644 --- a/tests/PhpSpreadsheetTests/Calculation/MathTrigTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/MathTrigTest.php @@ -281,10 +281,8 @@ class MathTrigTest extends TestCase */ public function testMINVERSE($expectedResult, ...$args) { - $this->markTestIncomplete('TODO: This test should be fixed'); - $result = MathTrig::MINVERSE(...$args); - self::assertEquals($expectedResult, $result, null, 1E-12); + self::assertEquals($expectedResult, $result, null, 1E-8); } public function providerMINVERSE() @@ -299,10 +297,8 @@ class MathTrigTest extends TestCase */ public function testMMULT($expectedResult, ...$args) { - $this->markTestIncomplete('TODO: This test should be fixed'); - $result = MathTrig::MMULT(...$args); - self::assertEquals($expectedResult, $result, null, 1E-12); + self::assertEquals($expectedResult, $result, null, 1E-8); } public function providerMMULT() diff --git a/tests/data/Calculation/MathTrig/MDETERM.php b/tests/data/Calculation/MathTrig/MDETERM.php index 10a3d806..a490b618 100644 --- a/tests/data/Calculation/MathTrig/MDETERM.php +++ b/tests/data/Calculation/MathTrig/MDETERM.php @@ -4,259 +4,109 @@ return [ [ 0, [ - [ - 1, - 2, - 3, - ], - [ - 4, - 5, - 6, - ], - [ - 7, - 8, - 9, - ], + [ 1, 2, 3 ], + [ 4, 5, 6 ], + [ 7, 8, 9 ], ], ], [ 0, [ - [ - 1.1, - 2.2, - 3.3, - ], - [ - 4.4, - 5.5, - 6.6, - ], - [ - 7.7, - 8.8, - 9.9, - ], + [ 1.1, 2.2, 3.3 ], + [ 4.4, 5.5, 6.6 ], + [ 7.7, 8.8, 9.9 ], ], ], [ 0, [ - [ - 10, - 20, - 30, - ], - [ - 40, - 50, - 60, - ], - [ - 70, - 80, - 90, - ], + [ 10, 20, 30 ], + [ 40, 50, 60 ], + [ 70, 80, 90 ], ], ], [ -360.0, [ - [ - 8, - 1, - 6, - ], - [ - 3, - 5, - 7, - ], - [ - 4, - 9, - 2, - ], + [ 8, 1, 6 ], + [ 3, 5, 7 ], + [ 4, 9, 2 ], ], ], [ -9, [ - [ - 5, - 2, - ], - [ - 7, - 1, - ], + [ 5, 2 ], + [ 7, 1 ], ], ], [ 40, [ - [ - 6, - 4, - 2, - ], - [ - 3, - 5, - 3, - ], - [ - 2, - 3, - 4, - ], + [ 6, 4, 2 ], + [ 3, 5, 3 ], + [ 2, 3, 4 ], ], ], [ 1.81, [ - [ - 0.2, - 1, - ], - [ - 0.35, - 10.8, - ], - ], - ], - [ - '#VALUE!', - [ - [ - 0.2, - 1, - -0.9, - ], - [ - 0.35, - 10.8, - 4, - ], - [ - -3.15, - 5, - null, - ], + [ 0.20, 1.0 ], + [ 0.35, 10.8 ], ], ], [ -2, [ - [ - 1, - 2, - ], - [ - 3, - 4, - ], + [ 1, 2 ], + [ 3, 4 ], ], ], [ -3, [ - [ - 1, - 2, - 1, - ], - [ - 3, - 4, - 2, - ], - [ - 1, - 1, - 2, - ], + [ 1, 2, 1 ], + [ 3, 4, 2 ], + [ 1, 1, 2 ], ], ], [ 88, [ - [ - 1, - 3, - 8, - 5, - ], - [ - 1, - 3, - 6, - 1, - ], - [ - 1, - 1, - 1, - 0, - ], - [ - 7, - 3, - 10, - 2, - ], + [ 1, 3, 8, 5 ], + [ 1, 3, 6, 1 ], + [ 1, 1, 1, 0 ], + [ 7, 3, 10, 2 ], ], ], [ 1, [ - [ - 3, - 6, - 1, - ], - [ - 1, - 1, - 0, - ], - [ - 3, - 10, - 2, - ], + [ 3, 6, 1 ], + [ 1, 1, 0 ], + [ 3, 10, 2 ], ], ], [ -3, [ - [ - 3, - 6, - ], - [ - 1, - 1, - ], + [ 3, 6 ], + [ 1, 1 ], ], ], [ '#VALUE!', [ - [ - 1, - 3, - 8, - 5, - ], - [ - 1, - 3, - 6, - 1, - ], + [ 0.20, 1.00, -0.90 ], + [ 0.35, 10.80, 4.00 ], + [ -3.15, 5.00, null ], + ], + ], + [ + '#VALUE!', + [ + [ 1, 3, 8, 5 ], + [ 1, 3, 6, 1 ], ], ], ]; diff --git a/tests/data/Calculation/MathTrig/MINVERSE.php b/tests/data/Calculation/MathTrig/MINVERSE.php index 15c05bb3..ea490d9b 100644 --- a/tests/data/Calculation/MathTrig/MINVERSE.php +++ b/tests/data/Calculation/MathTrig/MINVERSE.php @@ -3,409 +3,112 @@ return [ [ [ - [ - 1, - 2, - 3, - ], - [ - 4, - 5, - 6, - ], - [ - 7, - 8, - 9, - ], + [ 0.147222222222222, -0.14444444444444399, 0.063888888888888898 ], + [ -0.061111111111111102, 0.022222222222222199, 0.105555555555556 ], + [ -0.0194444444444444, 0.18888888888888899, -0.102777777777778 ], ], [ - [ - -4503599627370500.0, - 9007199254740990.0, - -4503599627370500.0, - ], - [ - 9007199254741000.0, - -18014398509482000.0, - 9007199254740990.0, - ], - [ - -4503599627370500.0, - 9007199254740990.0, - -4503599627370500.0, - ], + [ 8, 1, 6 ], + [ 3, 5, 7 ], + [ 4, 9, 2 ], ], ], [ [ - [ - 10, - 20, - 30, - ], - [ - 40, - 50, - 60, - ], - [ - 70, - 80, - 90, - ], + [ 4, -1 ], + [ 2, 0 ], ], [ - [ - 70368744177663.898, - -140737488355328.0, - 70368744177664.0, - ], - [ - -140737488355328.0, - 281474976710656.0, - -140737488355328.0, - ], - [ - 70368744177664.094, - -140737488355328.0, - 70368744177664.0, - ], + [ 0.0, 0.5 ], + [ -1.0, 2.0 ], ], ], [ [ - [ - 8, - 1, - 6, - ], - [ - 3, - 5, - 7, - ], - [ - 4, - 9, - 2, - ], + [ 1, 2, 1 ], + [ 3, 4, -1 ], + [ 0, 2, 0 ], ], [ - [ - 0.147222222222222, - -0.14444444444444399, - 0.063888888888888898, - ], - [ - -0.061111111111111102, - 0.022222222222222199, - 0.105555555555556, - ], - [ - -0.0194444444444444, - 0.18888888888888899, - -0.102777777777778, - ], + [ 0.25, 0.25, -0.75 ], + [ 0.00, 0.00, 0.50 ], + [ 0.75, -0.25, -0.25 ], ], ], [ [ - [ - 4, - -1, - ], - [ - 2, - 0, - ], + [ -0.4545454545455, 1.8181818181818, 0.2727272727273, -0.4545454545455 ], + [ -0.4545454545455, 1.8181818181818, -0.7272727272727, -0.4545454545455 ], + [ 0.9090909090909, 1.3636363636364, 0.4545454545455, 0.9090909090909 ], + [ 2.2727272727273, 0.9090909090909, 5.6363636363636, 3.2727272727273 ], ], [ - [ - 0, - 0.5, - ], - [ - -1, - 2, - ], + [ 3.2, -4.8, 2.8, -1.0 ], + [ 0.2, 0.2, 0.2, 0.0 ], + [ 1.0, -1.0, 0.0, 0.0 ], + [ -4.0, 5.0, -2.0, 1.0 ], ], ], [ [ - [ - 1, - 2, - 1, - ], - [ - 3, - 4, - -1, - ], - [ - 0, - 2, - 0, - ], + [ 1, 2 ], + [ 3, 4 ], ], [ - [ - 0.25, - 0.25, - -0.75, - ], - [ - 0, - 0, - 0.5, - ], - [ - 0.75, - -0.25, - -0.25, - ], + [ -2.0, 1.0 ], + [ 1.5, -0.5 ], ], ], [ [ - [ - 1, - 4, - 1, - 1, - ], - [ - 1, - 4, - 0, - 1, - ], - [ - 2, - 3, - 1, - 2, - ], - [ - 3, - 2, - 6, - 4, - ], + [ 1, 2, 1 ], + [ 3, 4, 2 ], + [ 1, 1, 2 ], ], [ - [ - 3.2000000000000002, - -4.7999999999999998, - 2.7999999999999998, - -1, - ], - [ - 0.20000000000000001, - 0.20000000000000001, - 0.20000000000000001, - 0, - ], - [ - 1, - -1, - 0, - 0, - ], - [ - -4, - 5, - -2, - 1, - ], + [ -2, 1, 0 ], + [ 1.3333333333333299, -0.33333333333332998, -0.33333333333332998 ], + [ 0.33333333333332998, -0.33333333333332998, 0.66666666666666996 ], ], ], [ [ - [ - 0.20000000000000001, - 1, - ], - [ - 0.34999999999999998, - 10.800000000000001, - ], + [ 2, 3 ], + [ 4, 5 ], ], [ - [ - 5.9668508287292799, - -0.55248618784530001, - ], - [ - -0.19337016574586, - 0.11049723756906001, - ], + [ -2.5, 1.5 ], + [ 2.0, -1.0 ], ], ], [ [ - [ - 0.20000000000000001, - 1, - -0.90000000000000002, - ], - [ - 0.34999999999999998, - 10.800000000000001, - 4, - ], - [ - -3.1499999999999999, - 5, - ], - ], - '#VALUE!', - ], - [ - [ - [ - 1, - 2, - ], - [ - 3, - 4, - ], + [ 5, 8 ], + [ 7, 9 ], ], [ - [ - -2, - 1, - ], - [ - 1.5, - -0.5, - ], + [ -0.81818181818181801, 0.72727272727272696 ], + [ 0.63636363636363602, -0.45454545454545497 ], ], ], [ [ - [ - 1, - 2, - 1, - ], - [ - 3, - 4, - 2, - ], - [ - 1, - 1, - 2, - ], + [ 45, 78 ], + [ 17, 50 ], ], [ - [ - -2, - 1, - 0, - ], - [ - 1.3333333333333299, - -0.33333333333332998, - -0.33333333333332998, - ], - [ - 0.33333333333332998, - -0.33333333333332998, - 0.66666666666666996, - ], + [ 0.054112554112554001, -0.084415584415584 ], + [ -0.018398268398268001, 0.048701298701299002 ], ], ], [ [ - [ - 2, - 3, - ], - [ - 4, - 5, - ], + [ 2, 2 ], + [ 2, 1 ], ], [ - [ - -2.5, - 1.5, - ], - [ - 2, - -1, - ], - ], - ], - [ - [ - [ - 5, - 8, - ], - [ - 7, - 9, - ], - ], - [ - [ - -0.81818181818181801, - 0.72727272727272696, - ], - [ - 0.63636363636363602, - -0.45454545454545497, - ], - ], - ], - [ - [ - [ - 45, - 78, - ], - [ - 17, - 50, - ], - ], - [ - [ - 0.054112554112554001, - -0.084415584415584, - ], - [ - -0.018398268398268001, - 0.048701298701299002, - ], - ], - ], - [ - [ - [ - 2, - 2, - ], - [ - 2, - 1, - ], - ], - [ - [ - -0.5, - 1.0, - ], - [ - 1, - -1, - ], + [ -0.5, 1.0 ], + [ 1.0, -1.0 ], ], ], ]; diff --git a/tests/data/Calculation/MathTrig/MMULT.php b/tests/data/Calculation/MathTrig/MMULT.php index 102534e7..b4246926 100644 --- a/tests/data/Calculation/MathTrig/MMULT.php +++ b/tests/data/Calculation/MathTrig/MMULT.php @@ -3,303 +3,113 @@ return [ [ [ - [ - 1, - 2, - ], - [ - 3, - 4, - ], + [ 7, 10 ], + [ 15, 22 ], ], [ - [ - 1, - 2, - ], - [ - 3, - 4, - ], + [ 1, 2 ], + [ 3, 4 ], ], [ - [ - 7, - 10, - ], - [ - 15, - 22, - ], + [ 1, 2 ], + [ 3, 4 ], ], ], [ [ - [ - 1, - 2, - 3, - ], - [ - 4, - 5, - 6, - ], - [ - 7, - 8, - 9, - ], + [ 30, 36, 42 ], + [ 66, 81, 96 ], + [ 102, 126, 150 ], ], [ - [ - 1, - 2, - 3, - ], - [ - 4, - 5, - 6, - ], - [ - 7, - 8, - 9, - ], + [ 1, 2, 3 ], + [ 4, 5, 6 ], + [ 7, 8, 9 ], ], [ - [ - 30, - 36, - 42, - ], - [ - 66, - 81, - 96, - ], - [ - 102, - 126, - 150, - ], + [ 1, 2, 3 ], + [ 4, 5, 6 ], + [ 7, 8, 9 ], ], ], - // Mismatched dimensions [ [ - [ - 1, - 2, - ], - [ - 3, - 4, - ], + [ 10.08, 14.40 ], + [ 21.60, 31.68 ], ], - 2, + [ + [ 1.2, 2.4 ], + [ 3.6, 4.8 ], + ], + [ + [ 1.2, 2.4 ], + [ 3.6, 4.8 ], + ], + ], + [ + [ + [ 20.48, 30.60 ], + [ 50.40, 79.88 ], + ], + [ + [ 1.2, 3.4 ], + [ 5.6, 7.8 ], + ], + [ + [ 1.2, 3.4 ], + [ 5.6, 7.8 ], + ], + ], + [ + [ + [ 62.00, 49.46 ], + [ 176.40, 144.50 ], + ], + [ + [ 1.2, 2.3, 3.4, 4.5 ], + [ 5.6, 6.7, 7.8, 8.9 ], + ], + [ + [ 9.8, 8.7 ], + [ 7.6, 6.5 ], + [ 5.4, 4.3 ], + [ 3.2, 2.1 ], + ], + ], + [ + [ + [ 17 ], + [ 39 ], + ], + [ + [ 1, 2 ], + [ 3, 4 ], + ], + [ + [ 5 ], + [ 6 ], + ] + ], + // Mismatched dimensions (2x2) and (1x1) + [ '#VALUE!', - ], - // Mismatched dimensions - [ [ - [ - 1, - 2, - ], - [ - 3, - 4, - ], + [ 1, 2 ], + [ 3, 4 ], + ], + [ + [ 2 ] + ], + ], + // Mismatched dimensions (2x2) and individual cell + [ + '#VALUE!', + [ + [ 1, 2 ], + [ 3, 4 ], ], [ 2, ], - '#VALUE!', - ], - [ - [ - 1.2, - 2.3999999999999999, - ], - [ - [ - 3.6000000000000001, - 4.5, - ], - ], - [ - [ - 14.43, - 14.43, - ], - [ - 14.43, - 14.43, - ], - ], - ], - // Mismatched dimensions - [ - 2, - [ - [ - 1, - 2, - ], - [ - 3, - 4, - ], - ], - '#VALUE!', - ], - // Mismatched dimensions - [ - [ - 2, - ], - [ - [ - 1, - 2, - ], - [ - 3, - 4, - ], - ], - '#VALUE!', - ], - [ - [ - [ - 1, - 2, - ], - [ - 3, - 4, - ], - ], - [ - [ - 2, - 4, - ], - ], - '#VALUE!', - ], - [ - [ - [ - 1, - 2, - ], - [ - 3, - 4, - ], - ], - [ - 2, - 4, - ], - [ - [ - 10, - ], - [ - 22, - ], - ], - ], - [ - [ - [ - 2, - 4, - ], - ], - [ - [ - 1, - 2, - ], - [ - 3, - 4, - ], - ], - [ - [ - 14, - 20, - ], - ], - ], - // Mismatched dimensions - [ - [ - 2, - 4, - ], - [ - [ - 1, - 2, - ], - [ - 3, - 4, - ], - ], - '#VALUE!', - ], - [ - [ - [ - 1, - 2, - ], - [ - 3, - 4, - ], - [ - 5, - 6, - ], - ], - [ - [ - 1, - 2, - 3, - ], - [ - 4, - 5, - 6, - ], - ], - [ - [ - 9, - 12, - 15, - ], - [ - 19, - 26, - 33, - ], - [ - 29, - 40, - 51, - ], - ], ], ];