Version Description
- 2021-02-16
Download this release
Release Info
Developer | codeinwp |
Plugin | WordPress Charts and Graphs Lite |
Version | 3.4.11 |
Comparing to | |
See all releases |
Code changes from version 3.4.10 to 3.4.11
- CHANGELOG.md +8 -0
- classes/Visualizer/Plugin.php +1 -1
- css/media.css +1 -1
- index.php +3 -1
- readme.md +6 -1
- readme.txt +6 -1
- themeisle-hash.json +1 -1
- vendor/autoload.php +1 -1
- vendor/composer/autoload_files.php +16 -16
- vendor/composer/autoload_real.php +5 -5
- vendor/composer/installed.json +22 -22
- vendor/markbaker/matrix/README.md +85 -43
- vendor/markbaker/matrix/classes/Autoloader.php +0 -53
- vendor/markbaker/matrix/classes/Bootstrap.php +0 -38
- vendor/markbaker/matrix/classes/src/Decomposition/Decomposition.php +27 -0
- vendor/markbaker/matrix/classes/src/Decomposition/LU.php +260 -0
- vendor/markbaker/matrix/classes/src/Decomposition/QR.php +194 -0
- vendor/markbaker/matrix/classes/src/{functions → Functions}/adjoint.php +0 -0
- vendor/markbaker/matrix/classes/src/{functions → Functions}/antidiagonal.php +0 -0
- vendor/markbaker/matrix/classes/src/{functions → Functions}/cofactors.php +0 -0
- vendor/markbaker/matrix/classes/src/{functions → Functions}/determinant.php +0 -0
- vendor/markbaker/matrix/classes/src/{functions → Functions}/diagonal.php +0 -0
- vendor/markbaker/matrix/classes/src/{functions → Functions}/identity.php +0 -0
- vendor/markbaker/matrix/classes/src/{functions → Functions}/inverse.php +0 -0
- vendor/markbaker/matrix/classes/src/{functions → Functions}/minors.php +0 -0
- vendor/markbaker/matrix/classes/src/{functions → Functions}/trace.php +0 -0
- vendor/markbaker/matrix/classes/src/{functions → Functions}/transpose.php +0 -0
- vendor/markbaker/matrix/classes/src/Matrix.php +27 -4
- vendor/markbaker/matrix/classes/src/{operations → Operations}/add.php +0 -0
- vendor/markbaker/matrix/classes/src/{operations → Operations}/directsum.php +0 -0
- vendor/markbaker/matrix/classes/src/{operations → Operations}/divideby.php +0 -0
- vendor/markbaker/matrix/classes/src/{operations → Operations}/divideinto.php +2 -1
- vendor/markbaker/matrix/classes/src/{operations → Operations}/multiply.php +0 -0
- vendor/markbaker/matrix/classes/src/{operations → Operations}/subtract.php +0 -0
- vendor/markbaker/matrix/examples/test.php +1 -1
CHANGELOG.md
CHANGED
@@ -1,4 +1,12 @@
|
|
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
### v3.4.10 - 2020-12-09
|
3 |
**Changes:**
|
4 |
* [Fix] Compatibility with Composer 2.0
|
1 |
|
2 |
+
### v3.4.11 - 2021-02-17
|
3 |
+
**Changes:**
|
4 |
+
* [Fix] Fix changelog format
|
5 |
+
|
6 |
+
### v3.4.11 - 2021-02-16
|
7 |
+
**Changes:**
|
8 |
+
* Development
|
9 |
+
|
10 |
### v3.4.10 - 2020-12-09
|
11 |
**Changes:**
|
12 |
* [Fix] Compatibility with Composer 2.0
|
classes/Visualizer/Plugin.php
CHANGED
@@ -28,7 +28,7 @@
|
|
28 |
class Visualizer_Plugin {
|
29 |
|
30 |
const NAME = 'visualizer';
|
31 |
-
const VERSION = '3.4.
|
32 |
|
33 |
// custom post types
|
34 |
const CPT_VISUALIZER = 'visualizer';
|
28 |
class Visualizer_Plugin {
|
29 |
|
30 |
const NAME = 'visualizer';
|
31 |
+
const VERSION = '3.4.11';
|
32 |
|
33 |
// custom post types
|
34 |
const CPT_VISUALIZER = 'visualizer';
|
css/media.css
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/*
|
2 |
-
Version: 3.4.
|
3 |
*/
|
4 |
#visualizer-library-view {
|
5 |
padding: 30px 10px 10px 30px;
|
1 |
/*
|
2 |
+
Version: 3.4.11
|
3 |
*/
|
4 |
#visualizer-library-view {
|
5 |
padding: 30px 10px 10px 30px;
|
index.php
CHANGED
@@ -4,9 +4,11 @@
|
|
4 |
Plugin Name: Visualizer: Tables and Charts for WordPress
|
5 |
Plugin URI: https://themeisle.com/plugins/visualizer-charts-and-graphs-lite/
|
6 |
Description: A simple, easy to use and quite powerful tool to create, manage and embed interactive charts into your WordPress posts and pages. The plugin uses Google Visualization API to render charts, which supports cross-browser compatibility (adopting VML for older IE versions) and cross-platform portability to iOS and new Android releases.
|
7 |
-
Version: 3.4.
|
8 |
Author: Themeisle
|
9 |
Author URI: http://themeisle.com
|
|
|
|
|
10 |
License: GPL v2.0 or later
|
11 |
WordPress Available: yes
|
12 |
Requires License: no
|
4 |
Plugin Name: Visualizer: Tables and Charts for WordPress
|
5 |
Plugin URI: https://themeisle.com/plugins/visualizer-charts-and-graphs-lite/
|
6 |
Description: A simple, easy to use and quite powerful tool to create, manage and embed interactive charts into your WordPress posts and pages. The plugin uses Google Visualization API to render charts, which supports cross-browser compatibility (adopting VML for older IE versions) and cross-platform portability to iOS and new Android releases.
|
7 |
+
Version: 3.4.11
|
8 |
Author: Themeisle
|
9 |
Author URI: http://themeisle.com
|
10 |
+
Requires at least: 3.5
|
11 |
+
Tested up to: 5.6
|
12 |
License: GPL v2.0 or later
|
13 |
WordPress Available: yes
|
14 |
Requires License: no
|
readme.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
**Contributors:** [codeinwp](https://profiles.wordpress.org/codeinwp), [themeisle](https://profiles.wordpress.org/themeisle), [marius2012](https://profiles.wordpress.org/marius2012), [marius_codeinwp](https://profiles.wordpress.org/marius_codeinwp), [hardeepasrani](https://profiles.wordpress.org/hardeepasrani), [rozroz](https://profiles.wordpress.org/rozroz), [Madalin_ThemeIsle](https://profiles.wordpress.org/Madalin_ThemeIsle)
|
3 |
**Tags:** tables, charts, pie, visualization, graphs
|
4 |
**Requires at least:** 3.5
|
5 |
-
**Tested up to:** 5.
|
6 |
**Requires PHP:** 5.6
|
7 |
**Stable tag:** trunk
|
8 |
**License:** GPL v2.0 or later
|
@@ -162,6 +162,11 @@ Pay attention that to turn your shortcodes into graphs, your theme has to have `
|
|
162 |
13. Bar chart
|
163 |
|
164 |
## Changelog ##
|
|
|
|
|
|
|
|
|
|
|
165 |
### 3.4.10 - 2020-12-09 ###
|
166 |
|
167 |
* [Fix] Compatibility with Composer 2.0
|
2 |
**Contributors:** [codeinwp](https://profiles.wordpress.org/codeinwp), [themeisle](https://profiles.wordpress.org/themeisle), [marius2012](https://profiles.wordpress.org/marius2012), [marius_codeinwp](https://profiles.wordpress.org/marius_codeinwp), [hardeepasrani](https://profiles.wordpress.org/hardeepasrani), [rozroz](https://profiles.wordpress.org/rozroz), [Madalin_ThemeIsle](https://profiles.wordpress.org/Madalin_ThemeIsle)
|
3 |
**Tags:** tables, charts, pie, visualization, graphs
|
4 |
**Requires at least:** 3.5
|
5 |
+
**Tested up to:** 5.6
|
6 |
**Requires PHP:** 5.6
|
7 |
**Stable tag:** trunk
|
8 |
**License:** GPL v2.0 or later
|
162 |
13. Bar chart
|
163 |
|
164 |
## Changelog ##
|
165 |
+
### 3.4.11 - 2021-02-16 ###
|
166 |
+
|
167 |
+
[Feat] Tested up to WP 5.6
|
168 |
+
|
169 |
+
|
170 |
### 3.4.10 - 2020-12-09 ###
|
171 |
|
172 |
* [Fix] Compatibility with Composer 2.0
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: codeinwp,themeisle,marius2012,marius_codeinwp,hardeepasrani,rozroz,Madalin_ThemeIsle
|
3 |
Tags: tables, charts, pie, visualization, graphs
|
4 |
Requires at least: 3.5
|
5 |
-
Tested up to: 5.
|
6 |
Requires PHP: 5.6
|
7 |
Stable tag: trunk
|
8 |
License: GPL v2.0 or later
|
@@ -162,6 +162,11 @@ Pay attention that to turn your shortcodes into graphs, your theme has to have `
|
|
162 |
13. Bar chart
|
163 |
|
164 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
165 |
= 3.4.10 - 2020-12-09 =
|
166 |
|
167 |
* [Fix] Compatibility with Composer 2.0
|
2 |
Contributors: codeinwp,themeisle,marius2012,marius_codeinwp,hardeepasrani,rozroz,Madalin_ThemeIsle
|
3 |
Tags: tables, charts, pie, visualization, graphs
|
4 |
Requires at least: 3.5
|
5 |
+
Tested up to: 5.6
|
6 |
Requires PHP: 5.6
|
7 |
Stable tag: trunk
|
8 |
License: GPL v2.0 or later
|
162 |
13. Bar chart
|
163 |
|
164 |
== Changelog ==
|
165 |
+
= 3.4.11 - 2021-02-16 =
|
166 |
+
|
167 |
+
[Feat] Tested up to WP 5.6
|
168 |
+
|
169 |
+
|
170 |
= 3.4.10 - 2020-12-09 =
|
171 |
|
172 |
* [Fix] Compatibility with Composer 2.0
|
themeisle-hash.json
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"index.php":"
|
1 |
+
{"index.php":"879eda10f97272ee071019bcb5f1393c"}
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInitc926675fe338ad95091f044f06030553::getLoader();
|
vendor/composer/autoload_files.php
CHANGED
@@ -6,22 +6,22 @@ $vendorDir = dirname(dirname(__FILE__));
|
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
9 |
-
'
|
10 |
-
'
|
11 |
-
'
|
12 |
-
'
|
13 |
-
'
|
14 |
-
'
|
15 |
-
'
|
16 |
-
'
|
17 |
-
'
|
18 |
-
'
|
19 |
-
'
|
20 |
-
'
|
21 |
-
'
|
22 |
-
'
|
23 |
-
'
|
24 |
-
'
|
25 |
'abede361264e2ae69ec1eee813a101af' => $vendorDir . '/markbaker/complex/classes/src/functions/abs.php',
|
26 |
'21a5860fbef5be28db5ddfbc3cca67c4' => $vendorDir . '/markbaker/complex/classes/src/functions/acos.php',
|
27 |
'1546e3f9d127f2a9bb2d1b6c31c26ef1' => $vendorDir . '/markbaker/complex/classes/src/functions/acosh.php',
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
9 |
+
'3af723442581d6c310bf44543f9f5c60' => $vendorDir . '/markbaker/matrix/classes/src/Functions/adjoint.php',
|
10 |
+
'd803221834c8b57fec95debb5406a797' => $vendorDir . '/markbaker/matrix/classes/src/Functions/antidiagonal.php',
|
11 |
+
'4714cafbd3be4c72c274a25eae9396bb' => $vendorDir . '/markbaker/matrix/classes/src/Functions/cofactors.php',
|
12 |
+
'89719dc7c77436609d1c1c31f0797b8f' => $vendorDir . '/markbaker/matrix/classes/src/Functions/determinant.php',
|
13 |
+
'c28af79ec7730859d83f2d4310b8dd0b' => $vendorDir . '/markbaker/matrix/classes/src/Functions/diagonal.php',
|
14 |
+
'c5d82bf1ac485e445f911e55789ab4e6' => $vendorDir . '/markbaker/matrix/classes/src/Functions/identity.php',
|
15 |
+
'0d2d594de24a247f7a33499e933aa21e' => $vendorDir . '/markbaker/matrix/classes/src/Functions/inverse.php',
|
16 |
+
'f37c25880804a014ef40c8bffbab1b10' => $vendorDir . '/markbaker/matrix/classes/src/Functions/minors.php',
|
17 |
+
'd6e4e42171df0dbea253b3067fefda38' => $vendorDir . '/markbaker/matrix/classes/src/Functions/trace.php',
|
18 |
+
'2c9b19fa954fd3e6fcc7e7a1383caddd' => $vendorDir . '/markbaker/matrix/classes/src/Functions/transpose.php',
|
19 |
+
'0a538fc9b897450ec362480ebbebe94f' => $vendorDir . '/markbaker/matrix/classes/src/Operations/add.php',
|
20 |
+
'f0843f7f4089ec2343c7445544356385' => $vendorDir . '/markbaker/matrix/classes/src/Operations/directsum.php',
|
21 |
+
'ad3e8c29aa16d134661a414265677b61' => $vendorDir . '/markbaker/matrix/classes/src/Operations/subtract.php',
|
22 |
+
'8d37dad4703fab45bfec9dd0bbf3278e' => $vendorDir . '/markbaker/matrix/classes/src/Operations/multiply.php',
|
23 |
+
'4888a6f58c08148ebe17682f9ce9b2a8' => $vendorDir . '/markbaker/matrix/classes/src/Operations/divideby.php',
|
24 |
+
'eef6fa3879d3efa347cd24d5eb348f85' => $vendorDir . '/markbaker/matrix/classes/src/Operations/divideinto.php',
|
25 |
'abede361264e2ae69ec1eee813a101af' => $vendorDir . '/markbaker/complex/classes/src/functions/abs.php',
|
26 |
'21a5860fbef5be28db5ddfbc3cca67c4' => $vendorDir . '/markbaker/complex/classes/src/functions/acos.php',
|
27 |
'1546e3f9d127f2a9bb2d1b6c31c26ef1' => $vendorDir . '/markbaker/complex/classes/src/functions/acosh.php',
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -19,9 +19,9 @@ class ComposerAutoloaderInitbe639497d83f6aff5a2fcf2226b61588
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
27 |
foreach ($map as $namespace => $path) {
|
@@ -42,14 +42,14 @@ class ComposerAutoloaderInitbe639497d83f6aff5a2fcf2226b61588
|
|
42 |
|
43 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
44 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
45 |
-
|
46 |
}
|
47 |
|
48 |
return $loader;
|
49 |
}
|
50 |
}
|
51 |
|
52 |
-
function
|
53 |
{
|
54 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
55 |
require $file;
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInitc926675fe338ad95091f044f06030553
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInitc926675fe338ad95091f044f06030553', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInitc926675fe338ad95091f044f06030553', 'loadClassLoader'));
|
25 |
|
26 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
27 |
foreach ($map as $namespace => $path) {
|
42 |
|
43 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
44 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
45 |
+
composerRequirec926675fe338ad95091f044f06030553($fileIdentifier, $file);
|
46 |
}
|
47 |
|
48 |
return $loader;
|
49 |
}
|
50 |
}
|
51 |
|
52 |
+
function composerRequirec926675fe338ad95091f044f06030553($fileIdentifier, $file)
|
53 |
{
|
54 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
55 |
require $file;
|
vendor/composer/installed.json
CHANGED
@@ -43,17 +43,17 @@
|
|
43 |
},
|
44 |
{
|
45 |
"name": "markbaker/matrix",
|
46 |
-
"version": "1.2.
|
47 |
-
"version_normalized": "1.2.
|
48 |
"source": {
|
49 |
"type": "git",
|
50 |
"url": "https://github.com/MarkBaker/PHPMatrix.git",
|
51 |
-
"reference": "
|
52 |
},
|
53 |
"dist": {
|
54 |
"type": "zip",
|
55 |
-
"url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/
|
56 |
-
"reference": "
|
57 |
"shasum": ""
|
58 |
},
|
59 |
"require": {
|
@@ -68,7 +68,7 @@
|
|
68 |
"sebastian/phpcpd": "^3.0",
|
69 |
"squizlabs/php_codesniffer": "^3.0@dev"
|
70 |
},
|
71 |
-
"time": "
|
72 |
"type": "library",
|
73 |
"installation-source": "dist",
|
74 |
"autoload": {
|
@@ -76,22 +76,22 @@
|
|
76 |
"Matrix\\": "classes/src/"
|
77 |
},
|
78 |
"files": [
|
79 |
-
"classes/src/
|
80 |
-
"classes/src/
|
81 |
-
"classes/src/
|
82 |
-
"classes/src/
|
83 |
-
"classes/src/
|
84 |
-
"classes/src/
|
85 |
-
"classes/src/
|
86 |
-
"classes/src/
|
87 |
-
"classes/src/
|
88 |
-
"classes/src/
|
89 |
-
"classes/src/
|
90 |
-
"classes/src/
|
91 |
-
"classes/src/
|
92 |
-
"classes/src/
|
93 |
-
"classes/src/
|
94 |
-
"classes/src/
|
95 |
]
|
96 |
},
|
97 |
"notification-url": "https://packagist.org/downloads/",
|
43 |
},
|
44 |
{
|
45 |
"name": "markbaker/matrix",
|
46 |
+
"version": "1.2.3",
|
47 |
+
"version_normalized": "1.2.3.0",
|
48 |
"source": {
|
49 |
"type": "git",
|
50 |
"url": "https://github.com/MarkBaker/PHPMatrix.git",
|
51 |
+
"reference": "44bb1ab01811116f01fe216ab37d921dccc6c10d"
|
52 |
},
|
53 |
"dist": {
|
54 |
"type": "zip",
|
55 |
+
"url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/44bb1ab01811116f01fe216ab37d921dccc6c10d",
|
56 |
+
"reference": "44bb1ab01811116f01fe216ab37d921dccc6c10d",
|
57 |
"shasum": ""
|
58 |
},
|
59 |
"require": {
|
68 |
"sebastian/phpcpd": "^3.0",
|
69 |
"squizlabs/php_codesniffer": "^3.0@dev"
|
70 |
},
|
71 |
+
"time": "2021-01-26 14:36:01",
|
72 |
"type": "library",
|
73 |
"installation-source": "dist",
|
74 |
"autoload": {
|
76 |
"Matrix\\": "classes/src/"
|
77 |
},
|
78 |
"files": [
|
79 |
+
"classes/src/Functions/adjoint.php",
|
80 |
+
"classes/src/Functions/antidiagonal.php",
|
81 |
+
"classes/src/Functions/cofactors.php",
|
82 |
+
"classes/src/Functions/determinant.php",
|
83 |
+
"classes/src/Functions/diagonal.php",
|
84 |
+
"classes/src/Functions/identity.php",
|
85 |
+
"classes/src/Functions/inverse.php",
|
86 |
+
"classes/src/Functions/minors.php",
|
87 |
+
"classes/src/Functions/trace.php",
|
88 |
+
"classes/src/Functions/transpose.php",
|
89 |
+
"classes/src/Operations/add.php",
|
90 |
+
"classes/src/Operations/directsum.php",
|
91 |
+
"classes/src/Operations/subtract.php",
|
92 |
+
"classes/src/Operations/multiply.php",
|
93 |
+
"classes/src/Operations/divideby.php",
|
94 |
+
"classes/src/Operations/divideinto.php"
|
95 |
]
|
96 |
},
|
97 |
"notification-url": "https://packagist.org/downloads/",
|
vendor/markbaker/matrix/README.md
CHANGED
@@ -5,9 +5,7 @@ PHPMatrix
|
|
5 |
|
6 |
PHP Class for handling Matrices
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
Develop: [![Build Status](https://travis-ci.org/MarkBaker/PHPMatrix.png?branch=develop)](http://travis-ci.org/MarkBaker/PHPMatrix)
|
11 |
|
12 |
[![Matrix Transform](https://imgs.xkcd.com/comics/matrix_transform.png)](https://xkcd.com/184/)
|
13 |
|
@@ -17,34 +15,48 @@ Matrix Transform
|
|
17 |
|
18 |
This library currently provides the following operations:
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
- cofactors
|
33 |
-
- determinant
|
34 |
-
- diagonal
|
35 |
-
- identity
|
36 |
-
- inverse
|
37 |
-
- minors
|
38 |
-
- trace
|
39 |
-
- transpose
|
40 |
|
|
|
|
|
|
|
|
|
41 |
|
42 |
## TO DO
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
48 |
|
49 |
---
|
50 |
|
@@ -52,7 +64,7 @@ together with functions for
|
|
52 |
|
53 |
To create a new Matrix object, provide an array as the constructor argument
|
54 |
|
55 |
-
```
|
56 |
$grid = [
|
57 |
[16, 3, 2, 13],
|
58 |
[ 5, 10, 11, 8],
|
@@ -63,12 +75,12 @@ $grid = [
|
|
63 |
$matrix = new Matrix\Matrix($grid);
|
64 |
```
|
65 |
The `Builder` class provides helper methods for creating specific matrices, specifically an identity matrix of a specified size; or a matrix of a specified dimensions, with every cell containing a set value.
|
66 |
-
```
|
67 |
-
$matrix =
|
68 |
```
|
69 |
Will create a matrix of 5 rows and 3 columns, filled with a `1` in every cell; while
|
70 |
-
```
|
71 |
-
$matrix =
|
72 |
```
|
73 |
will create a 3x3 identity matrix.
|
74 |
|
@@ -79,34 +91,34 @@ Matrix objects are immutable: whenever you call a method or pass a grid to a fun
|
|
79 |
|
80 |
To perform mathematical operations with Matrices, you can call the appropriate method against a matrix value, passing other values as arguments
|
81 |
|
82 |
-
```
|
83 |
-
$matrix1 = new Matrix([
|
84 |
[2, 7, 6],
|
85 |
[9, 5, 1],
|
86 |
[4, 3, 8],
|
87 |
]);
|
88 |
-
$matrix2 = new Matrix([
|
89 |
[1, 2, 3],
|
90 |
[4, 5, 6],
|
91 |
[7, 8, 9],
|
92 |
]);
|
93 |
|
94 |
-
|
95 |
```
|
96 |
or pass all values to the appropriate function
|
97 |
-
```
|
98 |
-
$matrix1 = new Matrix([
|
99 |
[2, 7, 6],
|
100 |
[9, 5, 1],
|
101 |
[4, 3, 8],
|
102 |
]);
|
103 |
-
$matrix2 = new Matrix([
|
104 |
[1, 2, 3],
|
105 |
[4, 5, 6],
|
106 |
[7, 8, 9],
|
107 |
]);
|
108 |
|
109 |
-
|
110 |
```
|
111 |
You can pass in the arguments as Matrix objects, or as arrays.
|
112 |
|
@@ -115,7 +127,7 @@ If you want to perform the same operation against multiple values (e.g. to add t
|
|
115 |
## Using functions
|
116 |
|
117 |
When calling any of the available functions for a matrix value, you can either call the relevant method for the Matrix object
|
118 |
-
```
|
119 |
$grid = [
|
120 |
[16, 3, 2, 13],
|
121 |
[ 5, 10, 11, 8],
|
@@ -127,8 +139,8 @@ $matrix = new Matrix\Matrix($grid);
|
|
127 |
|
128 |
echo $matrix->trace();
|
129 |
```
|
130 |
-
or you can call the function as you would in procedural code, passing the Matrix object as an argument
|
131 |
-
```
|
132 |
$grid = [
|
133 |
[16, 3, 2, 13],
|
134 |
[ 5, 10, 11, 8],
|
@@ -140,7 +152,7 @@ $matrix = new Matrix\Matrix($grid);
|
|
140 |
echo Matrix\trace($matrix);
|
141 |
```
|
142 |
When called procedurally using the function, you can pass in the argument as a Matrix object, or as an array.
|
143 |
-
```
|
144 |
$grid = [
|
145 |
[16, 3, 2, 13],
|
146 |
[ 5, 10, 11, 8],
|
@@ -151,7 +163,7 @@ $grid = [
|
|
151 |
echo Matrix\trace($grid);
|
152 |
```
|
153 |
As an alternative, it is also possible to call the method directly from the `Functions` class.
|
154 |
-
```
|
155 |
$grid = [
|
156 |
[16, 3, 2, 13],
|
157 |
[ 5, 10, 11, 8],
|
@@ -163,3 +175,33 @@ $matrix = new Matrix\Matrix($grid);
|
|
163 |
echo Matrix\Functions::trace($matrix);
|
164 |
```
|
165 |
Used this way, methods must be called statically, and the argument must be the Matrix object, and cannot be an array.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
PHP Class for handling Matrices
|
7 |
|
8 |
+
[![Build Status](https://travis-ci.org/MarkBaker/PHPMatrix.png?branch=1.2)](http://travis-ci.org/MarkBaker/PHPMatrix)
|
|
|
|
|
9 |
|
10 |
[![Matrix Transform](https://imgs.xkcd.com/comics/matrix_transform.png)](https://xkcd.com/184/)
|
11 |
|
15 |
|
16 |
This library currently provides the following operations:
|
17 |
|
18 |
+
- addition
|
19 |
+
- direct sum
|
20 |
+
- subtraction
|
21 |
+
- multiplication
|
22 |
+
- division (using [A].[B]<sup>-1</sup>)
|
23 |
+
- division by
|
24 |
+
- division into
|
25 |
+
|
26 |
+
together with functions for
|
27 |
+
|
28 |
+
- adjoint
|
29 |
+
- antidiagonal
|
30 |
+
- cofactors
|
31 |
+
- determinant
|
32 |
+
- diagonal
|
33 |
+
- identity
|
34 |
+
- inverse
|
35 |
+
- minors
|
36 |
+
- trace
|
37 |
+
- transpose
|
38 |
+
- solve
|
39 |
+
|
40 |
+
Given Matrices A and B, calculate X for A.X = B
|
41 |
|
42 |
+
and classes for
|
43 |
|
44 |
+
- Decomposition
|
45 |
+
- LU Decomposition with partial row pivoting,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
+
such that [P].[A] = [L].[U] and [A] = [P]<sup>|</sup>.[L].[U]
|
48 |
+
- QR Decomposition
|
49 |
+
|
50 |
+
such that [A] = [Q].[R]
|
51 |
|
52 |
## TO DO
|
53 |
|
54 |
+
- power() function
|
55 |
+
- Decomposition
|
56 |
+
- Cholesky Decomposition
|
57 |
+
- EigenValue Decomposition
|
58 |
+
- EigenValues
|
59 |
+
- EigenVectors
|
60 |
|
61 |
---
|
62 |
|
64 |
|
65 |
To create a new Matrix object, provide an array as the constructor argument
|
66 |
|
67 |
+
```php
|
68 |
$grid = [
|
69 |
[16, 3, 2, 13],
|
70 |
[ 5, 10, 11, 8],
|
75 |
$matrix = new Matrix\Matrix($grid);
|
76 |
```
|
77 |
The `Builder` class provides helper methods for creating specific matrices, specifically an identity matrix of a specified size; or a matrix of a specified dimensions, with every cell containing a set value.
|
78 |
+
```php
|
79 |
+
$matrix = Matrix\Builder::createFilledMatrix(1, 5, 3);
|
80 |
```
|
81 |
Will create a matrix of 5 rows and 3 columns, filled with a `1` in every cell; while
|
82 |
+
```php
|
83 |
+
$matrix = Matrix\Builder::createIdentityMatrix(3);
|
84 |
```
|
85 |
will create a 3x3 identity matrix.
|
86 |
|
91 |
|
92 |
To perform mathematical operations with Matrices, you can call the appropriate method against a matrix value, passing other values as arguments
|
93 |
|
94 |
+
```php
|
95 |
+
$matrix1 = new Matrix\Matrix([
|
96 |
[2, 7, 6],
|
97 |
[9, 5, 1],
|
98 |
[4, 3, 8],
|
99 |
]);
|
100 |
+
$matrix2 = new Matrix\Matrix([
|
101 |
[1, 2, 3],
|
102 |
[4, 5, 6],
|
103 |
[7, 8, 9],
|
104 |
]);
|
105 |
|
106 |
+
var_dump($matrix1->multiply($matrix2)->toArray());
|
107 |
```
|
108 |
or pass all values to the appropriate function
|
109 |
+
```php
|
110 |
+
$matrix1 = new Matrix\Matrix([
|
111 |
[2, 7, 6],
|
112 |
[9, 5, 1],
|
113 |
[4, 3, 8],
|
114 |
]);
|
115 |
+
$matrix2 = new Matrix\Matrix([
|
116 |
[1, 2, 3],
|
117 |
[4, 5, 6],
|
118 |
[7, 8, 9],
|
119 |
]);
|
120 |
|
121 |
+
var_dump(Matrix\multiply($matrix1, $matrix2)->toArray());
|
122 |
```
|
123 |
You can pass in the arguments as Matrix objects, or as arrays.
|
124 |
|
127 |
## Using functions
|
128 |
|
129 |
When calling any of the available functions for a matrix value, you can either call the relevant method for the Matrix object
|
130 |
+
```php
|
131 |
$grid = [
|
132 |
[16, 3, 2, 13],
|
133 |
[ 5, 10, 11, 8],
|
139 |
|
140 |
echo $matrix->trace();
|
141 |
```
|
142 |
+
or you can call the function as you would in procedural code, passing the Matrix object as an argument
|
143 |
+
```php
|
144 |
$grid = [
|
145 |
[16, 3, 2, 13],
|
146 |
[ 5, 10, 11, 8],
|
152 |
echo Matrix\trace($matrix);
|
153 |
```
|
154 |
When called procedurally using the function, you can pass in the argument as a Matrix object, or as an array.
|
155 |
+
```php
|
156 |
$grid = [
|
157 |
[16, 3, 2, 13],
|
158 |
[ 5, 10, 11, 8],
|
163 |
echo Matrix\trace($grid);
|
164 |
```
|
165 |
As an alternative, it is also possible to call the method directly from the `Functions` class.
|
166 |
+
```php
|
167 |
$grid = [
|
168 |
[16, 3, 2, 13],
|
169 |
[ 5, 10, 11, 8],
|
175 |
echo Matrix\Functions::trace($matrix);
|
176 |
```
|
177 |
Used this way, methods must be called statically, and the argument must be the Matrix object, and cannot be an array.
|
178 |
+
|
179 |
+
## Decomposition
|
180 |
+
|
181 |
+
The library also provides classes for matrix decomposition. You can access these using
|
182 |
+
```php
|
183 |
+
$grid = [
|
184 |
+
[1, 2],
|
185 |
+
[3, 4],
|
186 |
+
];
|
187 |
+
|
188 |
+
$matrix = new Matrix\Matrix($grid);
|
189 |
+
|
190 |
+
$decomposition = new Matrix\Decomposition\QR($matrix);
|
191 |
+
$Q = $decomposition->getQ();
|
192 |
+
$R = $decomposition->getR();
|
193 |
+
```
|
194 |
+
|
195 |
+
or alternatively us the `Decomposition` factory, identifying which form of decomposition you want to use
|
196 |
+
```php
|
197 |
+
$grid = [
|
198 |
+
[1, 2],
|
199 |
+
[3, 4],
|
200 |
+
];
|
201 |
+
|
202 |
+
$matrix = new Matrix\Matrix($grid);
|
203 |
+
|
204 |
+
$decomposition = Matrix\Decomposition\Decomposition::decomposition(Matrix\Decomposition\Decomposition::QR, $matrix);
|
205 |
+
$Q = $decomposition->getQ();
|
206 |
+
$R = $decomposition->getR();
|
207 |
+
```
|
vendor/markbaker/matrix/classes/Autoloader.php
DELETED
@@ -1,53 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Matrix;
|
4 |
-
|
5 |
-
/**
|
6 |
-
*
|
7 |
-
* Autoloader for Matrix classes
|
8 |
-
*
|
9 |
-
* @package Matrix
|
10 |
-
* @copyright Copyright (c) 2014 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
11 |
-
* @license https://opensource.org/licenses/MIT MIT
|
12 |
-
*/
|
13 |
-
class Autoloader
|
14 |
-
{
|
15 |
-
/**
|
16 |
-
* Register the Autoloader with SPL
|
17 |
-
*
|
18 |
-
*/
|
19 |
-
public static function Register()
|
20 |
-
{
|
21 |
-
if (function_exists('__autoload')) {
|
22 |
-
// Register any existing autoloader function with SPL, so we don't get any clashes
|
23 |
-
spl_autoload_register('__autoload');
|
24 |
-
}
|
25 |
-
// Register ourselves with SPL
|
26 |
-
return spl_autoload_register(['Matrix\\Autoloader', 'Load']);
|
27 |
-
}
|
28 |
-
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Autoload a class identified by name
|
32 |
-
*
|
33 |
-
* @param string $pClassName Name of the object to load
|
34 |
-
*/
|
35 |
-
public static function Load($pClassName)
|
36 |
-
{
|
37 |
-
if ((class_exists($pClassName, false)) || (strpos($pClassName, 'Matrix\\') !== 0)) {
|
38 |
-
// Either already loaded, or not a Matrix class request
|
39 |
-
return false;
|
40 |
-
}
|
41 |
-
|
42 |
-
$pClassFilePath = __DIR__ . DIRECTORY_SEPARATOR .
|
43 |
-
'src' . DIRECTORY_SEPARATOR .
|
44 |
-
str_replace(['Matrix\\', '\\'], ['', '/'], $pClassName) .
|
45 |
-
'.php';
|
46 |
-
|
47 |
-
if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
|
48 |
-
// Can't load
|
49 |
-
return false;
|
50 |
-
}
|
51 |
-
require($pClassFilePath);
|
52 |
-
}
|
53 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/markbaker/matrix/classes/Bootstrap.php
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
include_once __DIR__ . '/Autoloader.php';
|
4 |
-
|
5 |
-
\Matrix\Autoloader::Register();
|
6 |
-
|
7 |
-
|
8 |
-
abstract class FilesystemRegexFilter extends RecursiveRegexIterator
|
9 |
-
{
|
10 |
-
protected $regex;
|
11 |
-
public function __construct(RecursiveIterator $it, $regex)
|
12 |
-
{
|
13 |
-
$this->regex = $regex;
|
14 |
-
parent::__construct($it, $regex);
|
15 |
-
}
|
16 |
-
}
|
17 |
-
|
18 |
-
class FilenameFilter extends FilesystemRegexFilter
|
19 |
-
{
|
20 |
-
// Filter files against the regex
|
21 |
-
public function accept()
|
22 |
-
{
|
23 |
-
return (!$this->isFile() || preg_match($this->regex, $this->getFilename()));
|
24 |
-
}
|
25 |
-
}
|
26 |
-
|
27 |
-
|
28 |
-
$srcFolder = __DIR__ . DIRECTORY_SEPARATOR . 'src';
|
29 |
-
$srcDirectory = new RecursiveDirectoryIterator($srcFolder);
|
30 |
-
|
31 |
-
$filteredFileList = new FilenameFilter($srcDirectory, '/(?:php)$/i');
|
32 |
-
$filteredFileList = new FilenameFilter($filteredFileList, '/^(?!.*(Matrix|Exception)\.php).*$/i');
|
33 |
-
|
34 |
-
foreach (new RecursiveIteratorIterator($filteredFileList) as $file) {
|
35 |
-
if ($file->isFile()) {
|
36 |
-
include_once $file;
|
37 |
-
}
|
38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/markbaker/matrix/classes/src/Decomposition/Decomposition.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Matrix\Decomposition;
|
4 |
+
|
5 |
+
use Matrix\Exception;
|
6 |
+
use Matrix\Matrix;
|
7 |
+
|
8 |
+
class Decomposition
|
9 |
+
{
|
10 |
+
const LU = 'LU';
|
11 |
+
const QR = 'QR';
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @throws Exception
|
15 |
+
*/
|
16 |
+
public static function decomposition($type, Matrix $matrix)
|
17 |
+
{
|
18 |
+
switch (strtoupper($type)) {
|
19 |
+
case self::LU:
|
20 |
+
return new LU($matrix);
|
21 |
+
case self::QR:
|
22 |
+
return new QR($matrix);
|
23 |
+
default:
|
24 |
+
throw new Exception('Invalid Decomposition');
|
25 |
+
}
|
26 |
+
}
|
27 |
+
}
|
vendor/markbaker/matrix/classes/src/Decomposition/LU.php
ADDED
@@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Matrix\Decomposition;
|
4 |
+
|
5 |
+
use Matrix\Exception;
|
6 |
+
use Matrix\Matrix;
|
7 |
+
|
8 |
+
class LU
|
9 |
+
{
|
10 |
+
private $luMatrix;
|
11 |
+
private $rows;
|
12 |
+
private $columns;
|
13 |
+
|
14 |
+
private $pivot = [];
|
15 |
+
|
16 |
+
public function __construct(Matrix $matrix)
|
17 |
+
{
|
18 |
+
$this->luMatrix = $matrix->toArray();
|
19 |
+
$this->rows = $matrix->rows;
|
20 |
+
$this->columns = $matrix->columns;
|
21 |
+
|
22 |
+
$this->buildPivot();
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Get lower triangular factor.
|
27 |
+
*
|
28 |
+
* @return Matrix Lower triangular factor
|
29 |
+
*/
|
30 |
+
public function getL()
|
31 |
+
{
|
32 |
+
$lower = [];
|
33 |
+
|
34 |
+
$columns = min($this->rows, $this->columns);
|
35 |
+
for ($row = 0; $row < $this->rows; ++$row) {
|
36 |
+
for ($column = 0; $column < $columns; ++$column) {
|
37 |
+
if ($row > $column) {
|
38 |
+
$lower[$row][$column] = $this->luMatrix[$row][$column];
|
39 |
+
} elseif ($row === $column) {
|
40 |
+
$lower[$row][$column] = 1.0;
|
41 |
+
} else {
|
42 |
+
$lower[$row][$column] = 0.0;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
return new Matrix($lower);
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Get upper triangular factor.
|
52 |
+
*
|
53 |
+
* @return Matrix Upper triangular factor
|
54 |
+
*/
|
55 |
+
public function getU()
|
56 |
+
{
|
57 |
+
$upper = [];
|
58 |
+
|
59 |
+
$rows = min($this->rows, $this->columns);
|
60 |
+
for ($row = 0; $row < $rows; ++$row) {
|
61 |
+
for ($column = 0; $column < $this->columns; ++$column) {
|
62 |
+
if ($row <= $column) {
|
63 |
+
$upper[$row][$column] = $this->luMatrix[$row][$column];
|
64 |
+
} else {
|
65 |
+
$upper[$row][$column] = 0.0;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
return new Matrix($upper);
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Return pivot permutation vector.
|
75 |
+
*
|
76 |
+
* @return Matrix Pivot matrix
|
77 |
+
*/
|
78 |
+
public function getP()
|
79 |
+
{
|
80 |
+
$pMatrix = [];
|
81 |
+
|
82 |
+
$pivots = $this->pivot;
|
83 |
+
$pivotCount = count($pivots);
|
84 |
+
foreach ($pivots as $row => $pivot) {
|
85 |
+
$pMatrix[$row] = array_fill(0, $pivotCount, 0);
|
86 |
+
$pMatrix[$row][$pivot] = 1;
|
87 |
+
}
|
88 |
+
|
89 |
+
return new Matrix($pMatrix);
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Return pivot permutation vector.
|
94 |
+
*
|
95 |
+
* @return array Pivot vector
|
96 |
+
*/
|
97 |
+
public function getPivot()
|
98 |
+
{
|
99 |
+
return $this->pivot;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Is the matrix nonsingular?
|
104 |
+
*
|
105 |
+
* @return bool true if U, and hence A, is nonsingular
|
106 |
+
*/
|
107 |
+
public function isNonsingular()
|
108 |
+
{
|
109 |
+
for ($diagonal = 0; $diagonal < $this->columns; ++$diagonal) {
|
110 |
+
if ($this->luMatrix[$diagonal][$diagonal] === 0.0) {
|
111 |
+
return false;
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
return true;
|
116 |
+
}
|
117 |
+
|
118 |
+
private function buildPivot()
|
119 |
+
{
|
120 |
+
for ($row = 0; $row < $this->rows; ++$row) {
|
121 |
+
$this->pivot[$row] = $row;
|
122 |
+
}
|
123 |
+
|
124 |
+
for ($column = 0; $column < $this->columns; ++$column) {
|
125 |
+
$luColumn = $this->localisedReferenceColumn($column);
|
126 |
+
|
127 |
+
$this->applyTransformations($column, $luColumn);
|
128 |
+
|
129 |
+
$pivot = $this->findPivot($column, $luColumn);
|
130 |
+
if ($pivot !== $column) {
|
131 |
+
$this->pivotExchange($pivot, $column);
|
132 |
+
}
|
133 |
+
|
134 |
+
$this->computeMultipliers($column);
|
135 |
+
|
136 |
+
unset($luColumn);
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
private function localisedReferenceColumn($column)
|
141 |
+
{
|
142 |
+
$luColumn = [];
|
143 |
+
|
144 |
+
for ($row = 0; $row < $this->rows; ++$row) {
|
145 |
+
$luColumn[$row] = &$this->luMatrix[$row][$column];
|
146 |
+
}
|
147 |
+
|
148 |
+
return $luColumn;
|
149 |
+
}
|
150 |
+
|
151 |
+
private function applyTransformations($column, array $luColumn)
|
152 |
+
{
|
153 |
+
for ($row = 0; $row < $this->rows; ++$row) {
|
154 |
+
$luRow = $this->luMatrix[$row];
|
155 |
+
// Most of the time is spent in the following dot product.
|
156 |
+
$kmax = min($row, $column);
|
157 |
+
$sValue = 0.0;
|
158 |
+
for ($kValue = 0; $kValue < $kmax; ++$kValue) {
|
159 |
+
$sValue += $luRow[$kValue] * $luColumn[$kValue];
|
160 |
+
}
|
161 |
+
$luRow[$column] = $luColumn[$row] -= $sValue;
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
private function findPivot($column, array $luColumn)
|
166 |
+
{
|
167 |
+
$pivot = $column;
|
168 |
+
for ($row = $column + 1; $row < $this->rows; ++$row) {
|
169 |
+
if (abs($luColumn[$row]) > abs($luColumn[$pivot])) {
|
170 |
+
$pivot = $row;
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
return $pivot;
|
175 |
+
}
|
176 |
+
|
177 |
+
private function pivotExchange($pivot, $column)
|
178 |
+
{
|
179 |
+
for ($kValue = 0; $kValue < $this->columns; ++$kValue) {
|
180 |
+
$tValue = $this->luMatrix[$pivot][$kValue];
|
181 |
+
$this->luMatrix[$pivot][$kValue] = $this->luMatrix[$column][$kValue];
|
182 |
+
$this->luMatrix[$column][$kValue] = $tValue;
|
183 |
+
}
|
184 |
+
|
185 |
+
$lValue = $this->pivot[$pivot];
|
186 |
+
$this->pivot[$pivot] = $this->pivot[$column];
|
187 |
+
$this->pivot[$column] = $lValue;
|
188 |
+
}
|
189 |
+
|
190 |
+
private function computeMultipliers($diagonal)
|
191 |
+
{
|
192 |
+
if (($diagonal < $this->rows) && ($this->luMatrix[$diagonal][$diagonal] != 0.0)) {
|
193 |
+
for ($row = $diagonal + 1; $row < $this->rows; ++$row) {
|
194 |
+
$this->luMatrix[$row][$diagonal] /= $this->luMatrix[$diagonal][$diagonal];
|
195 |
+
}
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
+
private function pivotB(Matrix $B)
|
200 |
+
{
|
201 |
+
$X = [];
|
202 |
+
foreach ($this->pivot as $rowId) {
|
203 |
+
$row = $B->getRows($rowId + 1)->toArray();
|
204 |
+
$X[] = array_pop($row);
|
205 |
+
}
|
206 |
+
|
207 |
+
return $X;
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Solve A*X = B.
|
212 |
+
*
|
213 |
+
* @param Matrix $B a Matrix with as many rows as A and any number of columns
|
214 |
+
*
|
215 |
+
* @throws Exception
|
216 |
+
*
|
217 |
+
* @return Matrix X so that L*U*X = B(piv,:)
|
218 |
+
*/
|
219 |
+
public function solve(Matrix $B)
|
220 |
+
{
|
221 |
+
if ($B->rows !== $this->rows) {
|
222 |
+
throw new Exception('Matrix row dimensions are not equal');
|
223 |
+
}
|
224 |
+
|
225 |
+
if ($this->rows !== $this->columns) {
|
226 |
+
throw new Exception('LU solve() only works on square matrices');
|
227 |
+
}
|
228 |
+
|
229 |
+
if (!$this->isNonsingular()) {
|
230 |
+
throw new Exception('Can only perform operation on singular matrix');
|
231 |
+
}
|
232 |
+
|
233 |
+
// Copy right hand side with pivoting
|
234 |
+
$nx = $B->columns;
|
235 |
+
$X = $this->pivotB($B);
|
236 |
+
|
237 |
+
// Solve L*Y = B(piv,:)
|
238 |
+
for ($k = 0; $k < $this->columns; ++$k) {
|
239 |
+
for ($i = $k + 1; $i < $this->columns; ++$i) {
|
240 |
+
for ($j = 0; $j < $nx; ++$j) {
|
241 |
+
$X[$i][$j] -= $X[$k][$j] * $this->luMatrix[$i][$k];
|
242 |
+
}
|
243 |
+
}
|
244 |
+
}
|
245 |
+
|
246 |
+
// Solve U*X = Y;
|
247 |
+
for ($k = $this->columns - 1; $k >= 0; --$k) {
|
248 |
+
for ($j = 0; $j < $nx; ++$j) {
|
249 |
+
$X[$k][$j] /= $this->luMatrix[$k][$k];
|
250 |
+
}
|
251 |
+
for ($i = 0; $i < $k; ++$i) {
|
252 |
+
for ($j = 0; $j < $nx; ++$j) {
|
253 |
+
$X[$i][$j] -= $X[$k][$j] * $this->luMatrix[$i][$k];
|
254 |
+
}
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
return new Matrix($X);
|
259 |
+
}
|
260 |
+
}
|
vendor/markbaker/matrix/classes/src/Decomposition/QR.php
ADDED
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Matrix\Decomposition;
|
4 |
+
|
5 |
+
use Matrix\Exception;
|
6 |
+
use Matrix\Matrix;
|
7 |
+
|
8 |
+
class QR
|
9 |
+
{
|
10 |
+
private $qrMatrix;
|
11 |
+
private $rows;
|
12 |
+
private $columns;
|
13 |
+
|
14 |
+
private $rDiagonal = [];
|
15 |
+
|
16 |
+
public function __construct(Matrix $matrix)
|
17 |
+
{
|
18 |
+
$this->qrMatrix = $matrix->toArray();
|
19 |
+
$this->rows = $matrix->rows;
|
20 |
+
$this->columns = $matrix->columns;
|
21 |
+
|
22 |
+
$this->decompose();
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getHouseholdVectors()
|
26 |
+
{
|
27 |
+
$householdVectors = [];
|
28 |
+
for ($row = 0; $row < $this->rows; ++$row) {
|
29 |
+
for ($column = 0; $column < $this->columns; ++$column) {
|
30 |
+
if ($row >= $column) {
|
31 |
+
$householdVectors[$row][$column] = $this->qrMatrix[$row][$column];
|
32 |
+
} else {
|
33 |
+
$householdVectors[$row][$column] = 0.0;
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
return new Matrix($householdVectors);
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getQ()
|
42 |
+
{
|
43 |
+
$qGrid = [];
|
44 |
+
|
45 |
+
$rowCount = $this->rows;
|
46 |
+
for ($k = $this->columns - 1; $k >= 0; --$k) {
|
47 |
+
for ($i = 0; $i < $this->rows; ++$i) {
|
48 |
+
$qGrid[$i][$k] = 0.0;
|
49 |
+
}
|
50 |
+
$qGrid[$k][$k] = 1.0;
|
51 |
+
if ($this->columns > $this->rows) {
|
52 |
+
$qGrid = array_slice($qGrid, 0, $this->rows);
|
53 |
+
}
|
54 |
+
|
55 |
+
for ($j = $k; $j < $this->columns; ++$j) {
|
56 |
+
if (isset($this->qrMatrix[$k], $this->qrMatrix[$k][$k]) && $this->qrMatrix[$k][$k] != 0.0) {
|
57 |
+
$s = 0.0;
|
58 |
+
for ($i = $k; $i < $this->rows; ++$i) {
|
59 |
+
$s += $this->qrMatrix[$i][$k] * $qGrid[$i][$j];
|
60 |
+
}
|
61 |
+
$s = -$s / $this->qrMatrix[$k][$k];
|
62 |
+
for ($i = $k; $i < $this->rows; ++$i) {
|
63 |
+
$qGrid[$i][$j] += $s * $this->qrMatrix[$i][$k];
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
array_walk(
|
70 |
+
$qGrid,
|
71 |
+
function (&$row) use ($rowCount) {
|
72 |
+
$row = array_reverse($row);
|
73 |
+
$row = array_slice($row, 0, $rowCount);
|
74 |
+
}
|
75 |
+
);
|
76 |
+
|
77 |
+
return new Matrix($qGrid);
|
78 |
+
}
|
79 |
+
|
80 |
+
public function getR()
|
81 |
+
{
|
82 |
+
$rGrid = [];
|
83 |
+
|
84 |
+
for ($row = 0; $row < $this->columns; ++$row) {
|
85 |
+
for ($column = 0; $column < $this->columns; ++$column) {
|
86 |
+
if ($row < $column) {
|
87 |
+
$rGrid[$row][$column] = isset($this->qrMatrix[$row][$column]) ? $this->qrMatrix[$row][$column] : 0.0;
|
88 |
+
} elseif ($row === $column) {
|
89 |
+
$rGrid[$row][$column] = isset($this->rDiagonal[$row]) ? $this->rDiagonal[$row] : 0.0;
|
90 |
+
} else {
|
91 |
+
$rGrid[$row][$column] = 0.0;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
if ($this->columns > $this->rows) {
|
97 |
+
$rGrid = array_slice($rGrid, 0, $this->rows);
|
98 |
+
}
|
99 |
+
|
100 |
+
return new Matrix($rGrid);
|
101 |
+
}
|
102 |
+
|
103 |
+
private function hypo($a, $b)
|
104 |
+
{
|
105 |
+
if (abs($a) > abs($b)) {
|
106 |
+
$r = $b / $a;
|
107 |
+
$r = abs($a) * sqrt(1 + $r * $r);
|
108 |
+
} elseif ($b != 0.0) {
|
109 |
+
$r = $a / $b;
|
110 |
+
$r = abs($b) * sqrt(1 + $r * $r);
|
111 |
+
} else {
|
112 |
+
$r = 0.0;
|
113 |
+
}
|
114 |
+
|
115 |
+
return $r;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* QR Decomposition computed by Householder reflections.
|
120 |
+
*/
|
121 |
+
private function decompose()
|
122 |
+
{
|
123 |
+
for ($k = 0; $k < $this->columns; ++$k) {
|
124 |
+
// Compute 2-norm of k-th column without under/overflow.
|
125 |
+
$norm = 0.0;
|
126 |
+
for ($i = $k; $i < $this->rows; ++$i) {
|
127 |
+
$norm = $this->hypo($norm, $this->qrMatrix[$i][$k]);
|
128 |
+
}
|
129 |
+
if ($norm != 0.0) {
|
130 |
+
// Form k-th Householder vector.
|
131 |
+
if ($this->qrMatrix[$k][$k] < 0.0) {
|
132 |
+
$norm = -$norm;
|
133 |
+
}
|
134 |
+
for ($i = $k; $i < $this->rows; ++$i) {
|
135 |
+
$this->qrMatrix[$i][$k] /= $norm;
|
136 |
+
}
|
137 |
+
$this->qrMatrix[$k][$k] += 1.0;
|
138 |
+
// Apply transformation to remaining columns.
|
139 |
+
for ($j = $k + 1; $j < $this->columns; ++$j) {
|
140 |
+
$s = 0.0;
|
141 |
+
for ($i = $k; $i < $this->rows; ++$i) {
|
142 |
+
$s += $this->qrMatrix[$i][$k] * $this->qrMatrix[$i][$j];
|
143 |
+
}
|
144 |
+
$s = -$s / $this->qrMatrix[$k][$k];
|
145 |
+
for ($i = $k; $i < $this->rows; ++$i) {
|
146 |
+
$this->qrMatrix[$i][$j] += $s * $this->qrMatrix[$i][$k];
|
147 |
+
}
|
148 |
+
}
|
149 |
+
}
|
150 |
+
$this->rDiagonal[$k] = -$norm;
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* @return bool
|
156 |
+
*/
|
157 |
+
public function isFullRank()
|
158 |
+
{
|
159 |
+
for ($j = 0; $j < $this->columns; ++$j) {
|
160 |
+
if ($this->rDiagonal[$j] == 0.0) {
|
161 |
+
return false;
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
return true;
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Least squares solution of A*X = B.
|
170 |
+
*
|
171 |
+
* @param Matrix $B a Matrix with as many rows as A and any number of columns
|
172 |
+
*
|
173 |
+
* @throws Exception
|
174 |
+
*
|
175 |
+
* @return Matrix matrix that minimizes the two norm of Q*R*X-B
|
176 |
+
*/
|
177 |
+
public function solve(Matrix $B)
|
178 |
+
{
|
179 |
+
if ($B->rows !== $this->rows) {
|
180 |
+
throw new Exception('Matrix row dimensions are not equal');
|
181 |
+
}
|
182 |
+
|
183 |
+
if (!$this->isFullRank()) {
|
184 |
+
throw new Exception('Can only perform this operation on a full-rank matrix');
|
185 |
+
}
|
186 |
+
|
187 |
+
// Compute Y = transpose(Q)*B
|
188 |
+
$Y = $this->getQ()->transpose()
|
189 |
+
->multiply($B);
|
190 |
+
// Solve R*X = Y;
|
191 |
+
return $this->getR()->inverse()
|
192 |
+
->multiply($Y);
|
193 |
+
}
|
194 |
+
}
|
vendor/markbaker/matrix/classes/src/{functions → Functions}/adjoint.php
RENAMED
File without changes
|
vendor/markbaker/matrix/classes/src/{functions → Functions}/antidiagonal.php
RENAMED
File without changes
|
vendor/markbaker/matrix/classes/src/{functions → Functions}/cofactors.php
RENAMED
File without changes
|
vendor/markbaker/matrix/classes/src/{functions → Functions}/determinant.php
RENAMED
File without changes
|
vendor/markbaker/matrix/classes/src/{functions → Functions}/diagonal.php
RENAMED
File without changes
|
vendor/markbaker/matrix/classes/src/{functions → Functions}/identity.php
RENAMED
File without changes
|
vendor/markbaker/matrix/classes/src/{functions → Functions}/inverse.php
RENAMED
File without changes
|
vendor/markbaker/matrix/classes/src/{functions → Functions}/minors.php
RENAMED
File without changes
|
vendor/markbaker/matrix/classes/src/{functions → Functions}/trace.php
RENAMED
File without changes
|
vendor/markbaker/matrix/classes/src/{functions → Functions}/transpose.php
RENAMED
File without changes
|
vendor/markbaker/matrix/classes/src/Matrix.php
CHANGED
@@ -10,6 +10,10 @@
|
|
10 |
|
11 |
namespace Matrix;
|
12 |
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Matrix object.
|
15 |
*
|
@@ -33,6 +37,7 @@ namespace Matrix;
|
|
33 |
* @method Matrix multiply(...$matrices)
|
34 |
* @method Matrix divideby(...$matrices)
|
35 |
* @method Matrix divideinto(...$matrices)
|
|
|
36 |
*/
|
37 |
class Matrix
|
38 |
{
|
@@ -270,9 +275,9 @@ class Matrix
|
|
270 |
|
271 |
/**
|
272 |
* Returns a Generator that will yield each row of the matrix in turn as a vector matrix
|
273 |
-
* or the value of each cell if the matrix is a vector
|
274 |
*
|
275 |
-
* @return
|
276 |
*/
|
277 |
public function rows()
|
278 |
{
|
@@ -285,9 +290,9 @@ class Matrix
|
|
285 |
|
286 |
/**
|
287 |
* Returns a Generator that will yield each column of the matrix in turn as a vector matrix
|
288 |
-
* or the value of each cell if the matrix is a vector
|
289 |
*
|
290 |
-
* @return
|
291 |
*/
|
292 |
public function columns()
|
293 |
{
|
@@ -330,6 +335,24 @@ class Matrix
|
|
330 |
return $this->grid;
|
331 |
}
|
332 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
333 |
protected static $getters = [
|
334 |
'rows',
|
335 |
'columns',
|
10 |
|
11 |
namespace Matrix;
|
12 |
|
13 |
+
use Generator;
|
14 |
+
use Matrix\Decomposition\LU;
|
15 |
+
use Matrix\Decomposition\QR;
|
16 |
+
|
17 |
/**
|
18 |
* Matrix object.
|
19 |
*
|
37 |
* @method Matrix multiply(...$matrices)
|
38 |
* @method Matrix divideby(...$matrices)
|
39 |
* @method Matrix divideinto(...$matrices)
|
40 |
+
* @method Matrix directsum(...$matrices)
|
41 |
*/
|
42 |
class Matrix
|
43 |
{
|
275 |
|
276 |
/**
|
277 |
* Returns a Generator that will yield each row of the matrix in turn as a vector matrix
|
278 |
+
* or the value of each cell if the matrix is a column vector
|
279 |
*
|
280 |
+
* @return Generator|Matrix[]|mixed[]
|
281 |
*/
|
282 |
public function rows()
|
283 |
{
|
290 |
|
291 |
/**
|
292 |
* Returns a Generator that will yield each column of the matrix in turn as a vector matrix
|
293 |
+
* or the value of each cell if the matrix is a row vector
|
294 |
*
|
295 |
+
* @return Generator|Matrix[]|mixed[]
|
296 |
*/
|
297 |
public function columns()
|
298 |
{
|
335 |
return $this->grid;
|
336 |
}
|
337 |
|
338 |
+
/**
|
339 |
+
* Solve A*X = B.
|
340 |
+
*
|
341 |
+
* @param Matrix $B Right hand side
|
342 |
+
*
|
343 |
+
* @throws Exception
|
344 |
+
*
|
345 |
+
* @return Matrix ... Solution if A is square, least squares solution otherwise
|
346 |
+
*/
|
347 |
+
public function solve(Matrix $B)
|
348 |
+
{
|
349 |
+
if ($this->columns === $this->rows) {
|
350 |
+
return (new LU($this))->solve($B);
|
351 |
+
}
|
352 |
+
|
353 |
+
return (new QR($this))->solve($B);
|
354 |
+
}
|
355 |
+
|
356 |
protected static $getters = [
|
357 |
'rows',
|
358 |
'columns',
|
vendor/markbaker/matrix/classes/src/{operations → Operations}/add.php
RENAMED
File without changes
|
vendor/markbaker/matrix/classes/src/{operations → Operations}/directsum.php
RENAMED
File without changes
|
vendor/markbaker/matrix/classes/src/{operations → Operations}/divideby.php
RENAMED
File without changes
|
vendor/markbaker/matrix/classes/src/{operations → Operations}/divideinto.php
RENAMED
@@ -25,7 +25,8 @@ function divideinto(...$matrixValues)
|
|
25 |
throw new Exception('Division operation requires at least 2 arguments');
|
26 |
}
|
27 |
|
28 |
-
$matrix =
|
|
|
29 |
|
30 |
if (is_array($matrix)) {
|
31 |
$matrix = new Matrix($matrix);
|
25 |
throw new Exception('Division operation requires at least 2 arguments');
|
26 |
}
|
27 |
|
28 |
+
$matrix = array_pop($matrixValues);
|
29 |
+
$matrixValues = array_reverse($matrixValues);
|
30 |
|
31 |
if (is_array($matrix)) {
|
32 |
$matrix = new Matrix($matrix);
|
vendor/markbaker/matrix/classes/src/{operations → Operations}/multiply.php
RENAMED
File without changes
|
vendor/markbaker/matrix/classes/src/{operations → Operations}/subtract.php
RENAMED
File without changes
|
vendor/markbaker/matrix/examples/test.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
include __DIR__ . '/../
|
4 |
|
5 |
$grid1 = [
|
6 |
[1, 3, 2],
|
1 |
<?php
|
2 |
|
3 |
+
include __DIR__ . '/../vendor/autoload.php';
|
4 |
|
5 |
$grid1 = [
|
6 |
[1, 3, 2],
|