prep for 2023. Fixed many bugs. Added pdf guide
This commit is contained in:
parent
7f97a60334
commit
e6025e3be1
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
// Database configuration stuff
|
||||
return [
|
||||
'admin' => 'lars.kermode@caribana.chx',
|
||||
'host' => 'accred-db',
|
||||
'name' => 'accred19',
|
||||
'name' => 'accred22',
|
||||
'user' => 'accred',
|
||||
'pass' => 'accred19',
|
||||
'year' => '2019',
|
||||
'editmode' => '0' // Allow edit by normal users, set to 0 to disable
|
||||
'pass' => 'accred22',
|
||||
'year' => '2023',
|
||||
'editmode' => '1' // Allow edit by normal users, set to 0 to disable
|
||||
];
|
||||
?>
|
||||
|
||||
|
||||
@ -3,14 +3,21 @@ require_once 'vendor/autoload.php';
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('display_startup_errors', 0);
|
||||
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_WARNING );
|
||||
include '../inc/auth.php';
|
||||
$Auth = new modAuth();
|
||||
// Load the graph class so we can get user info
|
||||
include '../inc/graph.php';
|
||||
$Graph = new modGraph();
|
||||
$uInfo = $Graph->getProfile();
|
||||
|
||||
session_start();
|
||||
$userid = $_SESSION['uid'];
|
||||
$cfg = include('accred_config.php');
|
||||
$userid = $uInfo->id;
|
||||
openlog('ACCRED', LOG_PID, LOG_LOCAL0);
|
||||
// Should we preload with data ?
|
||||
$aid = $_GET['aid'];
|
||||
$isAdmin = $_SESSION['admin']==1;
|
||||
|
||||
$isAdmin = $uInfo->userPrincipalName==$cfg['admin'] ? 1: 0;
|
||||
$isEditable = $cfg['editmode']==1;
|
||||
if(!$userid) {
|
||||
syslog(LOG_ERR, "Unauthorized access to form page aid:$aid from : {$_SERVER['REMOTE_ADDR']} ({$_SERVER['HTTP_USER_AGENT']})");
|
||||
@ -23,7 +30,6 @@ require_once 'vendor/autoload.php';
|
||||
die();
|
||||
}
|
||||
|
||||
$cfg = include('accred_config.php');
|
||||
|
||||
$uname = $_SESSION['name'];
|
||||
if($_POST['btncancel']) {
|
||||
@ -31,12 +37,12 @@ require_once 'vendor/autoload.php';
|
||||
die();
|
||||
}
|
||||
$prices = array(
|
||||
// 'mar' => array('nor' => 60, 'vip' => 40, 'label' => 'Mardi 4 juin'),
|
||||
'mer' => array('nor' => 60, 'vip' => 40, 'label' => 'Mercredi 5 juin'),
|
||||
'jeu' => array('nor' => 60, 'vip' => 40, 'label' => 'Jeudi 6 juin'),
|
||||
'ven' => array('nor' => 60, 'vip' => 40, 'label' => 'Vendredi 7 juin'),
|
||||
'sam' => array('nor' => 60, 'vip' => 40, 'label' => 'Samedi 8 juin'),
|
||||
'dim' => array('nor' => 60, 'vip' => 40, 'label' => 'Dimanche 9 juin')
|
||||
// 'mar' => array('nor' => 60, 'vip' => 40, 'label' => 'Mardi 15 juin'),
|
||||
'mer' => array('nor' => 60, 'vip' => 40, 'label' => 'Mercredi 7 juin'),
|
||||
'jeu' => array('nor' => 60, 'vip' => 40, 'label' => 'Jeudi 8 juin'),
|
||||
'ven' => array('nor' => 60, 'vip' => 40, 'label' => 'Vendredi 9 juin'),
|
||||
'sam' => array('nor' => 60, 'vip' => 40, 'label' => 'Samedi 10 juin')
|
||||
// , 'dim' => array('nor' => 60, 'vip' => 40, 'label' => 'Dimanche 19 juin')
|
||||
|
||||
);
|
||||
?>
|
||||
@ -86,14 +92,15 @@ global $aid;
|
||||
global $userid;
|
||||
global $isAdmin;
|
||||
global $uname;
|
||||
global $uInfo;
|
||||
|
||||
$username = $_SESSION['name'];
|
||||
$username = $uInfo->displayName;
|
||||
$status = '1';
|
||||
$updateStatus = false;
|
||||
if($_POST['btndelete']) {
|
||||
$query = "DELETE FROM submissions WHERE id=$aid";
|
||||
if(!$isAdmin) {
|
||||
$query .= " AND uid=$userid";
|
||||
$query .= " AND uid='$userid'";
|
||||
}
|
||||
syslog(LOG_INFO, "Delete entry for aid:$aid by uid: $userid / $uname from: {$_SERVER['REMOTE_ADDR']} ({$_SERVER['HTTP_USER_AGENT']})");
|
||||
if (!$mysqli->query($query) ) {
|
||||
@ -122,7 +129,7 @@ if( $reqName == '') {
|
||||
// Escape string, mostly in case of quotes
|
||||
$d = $mysqli->real_escape_string(serialize($_POST));
|
||||
if(!$aid) {
|
||||
// New entry. If no demande_pour provided in form, make current user owner
|
||||
// New entry. If no demande_pour provided in form, make current user owner
|
||||
if($demPour=='') {
|
||||
$reqName = $username;
|
||||
}
|
||||
@ -133,33 +140,54 @@ if(!$aid) {
|
||||
syslog(LOG_INFO, "Create entry by uid: $userid / $uname from: {$_SERVER['REMOTE_ADDR']} ({$_SERVER['HTTP_USER_AGENT']})");
|
||||
}
|
||||
else {
|
||||
// Modifying existint record
|
||||
if($demPour=='') {
|
||||
// Could have had a value before or already be empty
|
||||
// regardless, set reqName to same as name (This is NOT username or logged in user)
|
||||
// Was a prior bug
|
||||
// Since we don't have the DB values here, we need a different query
|
||||
$query = "UPDATE submissions set reqname=name,modifieduid=$userid,formdata='".$d."'";
|
||||
// Modifying existing record
|
||||
if(!$isAdmin) {
|
||||
$query = "UPDATE submissions set modifieduid='$userid',formdata='".$d."'";
|
||||
}
|
||||
else {
|
||||
// Value for demande_pour non blank, use that for reqName
|
||||
$query = "UPDATE submissions set reqname='".$demPour."',modifieduid=$userid,formdata='".$d."'";
|
||||
if($demPour=='') {
|
||||
// Could have had a value before or already be empty
|
||||
// regardless, set reqName to same as name (This is NOT username or logged in user)
|
||||
// Was a prior bug
|
||||
// Since we don't have the DB values here, we need a different query
|
||||
// Only admins can set request for. Prevent setting to blank on update byy regular user
|
||||
$query = "UPDATE submissions set reqname=name,modifieduid='$userid',formdata='".$d."'";
|
||||
}
|
||||
else {
|
||||
// Value for demande_pour non blank, use that for reqName
|
||||
$query = "UPDATE submissions set reqname='".$demPour."',modifieduid='$userid',formdata='".$d."'";
|
||||
}
|
||||
}
|
||||
if($updateStatus) {
|
||||
$query .= ",status=$status ";
|
||||
}
|
||||
$query .= " WHERE id=$aid";
|
||||
if(!$isAdmin) {
|
||||
$query .= " AND uid=$userid";
|
||||
$query .= " AND uid='$userid'";
|
||||
}
|
||||
syslog(LOG_INFO, "Update entry aid:$aid by uid: $userid / $uname from: {$_SERVER['REMOTE_ADDR']} ({$_SERVER['HTTP_USER_AGENT']})");
|
||||
$logquery = "INSERT INTO log (uid,aid,name,isadmin,operation,new,prev) SELECT '$userid',$aid,'$username', $isAdmin, 'update','".$d."', formdata FROM submissions WHERE ID=$aid";
|
||||
$stmt = $mysqli->stmt_init();
|
||||
$st = "INSERT INTO log (uid,aid,name,isadmin,operation,new,prev) VALUES('$userid',$aid,'$username',$isAdmin,'update','$d',?)";
|
||||
$stmt = $mysqli->prepare($st);
|
||||
$quer = "SELECT formdata FROM submissions WHERE ID=$aid";
|
||||
if(!$mysqli->query($quer)) {
|
||||
echo "Line 167x; Table insert failed: (" . $mysqli->errno . ") " . $mysqli->error. " / " . $mysqli->sqlstate;
|
||||
var_dump($quer);
|
||||
die("Argh<");
|
||||
}
|
||||
if($result = $mysqli->query($quer)) {
|
||||
$row = $result->fetch_assoc();
|
||||
$fd = $row['formdata'];
|
||||
$stmt->bind_param("b",$fd);
|
||||
$stmt->execute();
|
||||
}
|
||||
}
|
||||
$mysqli->query($logquery);
|
||||
if (!$mysqli->query($query) ) {
|
||||
echo "Table creation failed: (" . $mysqli->errno . ") " . $mysqli->error;
|
||||
die("Argh");
|
||||
}
|
||||
echo "Table update failed on 179: (" . $mysqli->errno . ") " . $mysqli->error;
|
||||
var_dump($query);
|
||||
die("Argh");
|
||||
}
|
||||
echo "<script type='text/javascript'> document.location = 'accred_list'; </script>";
|
||||
die();
|
||||
}
|
||||
@ -168,7 +196,7 @@ die();
|
||||
if($aid) {
|
||||
$query = "SELECT * from submissions WHERE ID=$aid";
|
||||
if(!$isAdmin) {
|
||||
$query .= " AND UID=$userid";
|
||||
$query .= " AND UID='$userid'";
|
||||
}
|
||||
if (!$result = $mysqli->query($query) ) {
|
||||
echo "Table read failed: (" . $mysqli->errno . ") " . $mysqli->error;
|
||||
@ -201,7 +229,8 @@ die();
|
||||
}
|
||||
else {
|
||||
$ti = 'Commande par '.$reqName. ', créée le '.$row['created'];
|
||||
$forWho = $ar['demande_pour'];
|
||||
$forWho = $ar['demande_pour'];
|
||||
$forWho = $row['reqname'];
|
||||
}
|
||||
if($isAdmin) {
|
||||
$form->add('label','label_demande_pour','','Demandeur');
|
||||
|
||||
@ -3,21 +3,25 @@
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL & ~E_NOTICE );
|
||||
$cfg = include('accred_config.php');
|
||||
// start session
|
||||
if (session_status() == PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
$cfg = include('accred_config.php');
|
||||
//
|
||||
// Load the auth module, this will redirect us to login if we aren't already logged in.
|
||||
include '../inc/auth.php';
|
||||
$Auth = new modAuth();
|
||||
// Load the graph class so we can get user info
|
||||
include '../inc/graph.php';
|
||||
$Graph = new modGraph();
|
||||
$uInfo = $Graph->getProfile();
|
||||
//
|
||||
// var_dump($uInfo);
|
||||
// die("tztz");r_dump($uInfo);
|
||||
$userid = $uInfo->id;
|
||||
$givenName = $uInfo->givenName;//
|
||||
// CSRF Counter-measure
|
||||
$token = md5(uniqid(rand(), TRUE));
|
||||
$_SESSION['state'] = $token;
|
||||
$userid = $_SESSION['uid'];
|
||||
$isAdmin = $_SESSION['admin']==1;
|
||||
$isAdmin = $uInfo->userPrincipalName==$cfg['admin'];
|
||||
$isEditable = $cfg['editmode']==1;
|
||||
// Bail out if not logged in
|
||||
if($userid=='') {
|
||||
header("location: index?");
|
||||
}
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
@ -145,9 +149,9 @@ foreach (range('A','E') as $col) {
|
||||
// Add totals
|
||||
//
|
||||
$highestRow = $spreadsheet->getActiveSheet()->getHighestRow();
|
||||
$coord = 'O' . ($highestRow+2);
|
||||
$coord = 'N' . ($highestRow+2);
|
||||
$spreadsheet->getActiveSheet()->setCellValue($coord, 'TOTAL');
|
||||
foreach(range('P','Z') as $col) {
|
||||
foreach(range('O','Z') as $col) {
|
||||
$spreadsheet->getActiveSheet()->setCellValue($col.($highestRow+2), '=SUM('.$col.'2:'.$col.($highestRow).')');
|
||||
}
|
||||
foreach(range('A','B') as $col) {
|
||||
@ -319,7 +323,6 @@ exit();
|
||||
</head>
|
||||
<?php
|
||||
|
||||
|
||||
$mysqli = new mysqli($cfg['host'], $cfg['user'],$cfg['pass'], $cfg['name']);
|
||||
if ($mysqli->connect_errno) {
|
||||
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
|
||||
@ -327,13 +330,15 @@ if ($mysqli->connect_errno) {
|
||||
?>
|
||||
|
||||
<body <?php if($isAdmin) echo 'class="admin" '; else echo 'class="user" '; ?>>
|
||||
<div class="right-blob"><span id="identification">Bienvenue <?php echo $_SESSION['name']; if($isAdmin) echo ", tu es admin";?></span><br>
|
||||
<div class="right-blob"><span id="identification">Bienvenue <?php echo $givenName; if($isAdmin) echo ", tu es admin";?></span><br>
|
||||
<?php if($isEditable) { ?>
|
||||
|
||||
<span class="identification">Le formulaire est ouvert, les utilisateurs peuvent modifier ou ajouter des demandes</span><br>
|
||||
<?php } else { ?>
|
||||
<span class="identification">Le formulaire est fermé, les utilisateurs ne peuvent plus modifier ou ajouter des demandes</span><br>
|
||||
<?php } ?>
|
||||
<br>
|
||||
<span class="identification"><a href="guide-accred-v1.pdf" target="_blank">Guide d'utilisation</a></span>
|
||||
<div id="uid" style="display:none"><?php echo $userid;?></div></div>
|
||||
<h1>Commande</h1>
|
||||
<div id="tblContent">
|
||||
@ -526,21 +531,7 @@ table.page( 5 ).draw( false );
|
||||
<div class="g-signin2" data-onsuccess="onSignIn" style="display:none"></div>
|
||||
|
||||
<br>
|
||||
<a href="#" onclick="signOut();">Déconnexion</a>
|
||||
<script>
|
||||
function signOut() {
|
||||
var auth2 = gapi.auth2.getAuthInstance();
|
||||
auth2.signOut().then(function () {
|
||||
console.log('User signed out.');
|
||||
$.post('tokensignin',
|
||||
{ mode: "logout" }, // data
|
||||
function(data) { // callback function
|
||||
location.href="./index?";
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<a href="/?action=logout">Déconnexion</a>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -5,6 +5,9 @@ body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
h1, h2, h3 {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
#logo {
|
||||
color: #e50350;
|
||||
}
|
||||
|
||||
@ -1,10 +1,20 @@
|
||||
<?php
|
||||
// Load the auth module, this will redirect us to login if we aren't already logged in.
|
||||
include '../../../inc/auth.php';
|
||||
$Auth = new modAuth();
|
||||
// Load the graph class so we can get user info
|
||||
include '../../../inc/graph.php';
|
||||
$Graph = new modGraph();
|
||||
$uInfo = $Graph->getProfile();
|
||||
|
||||
session_start();
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('display_startup_errors', 0);
|
||||
error_reporting(E_ALL & ~E_NOTICE );
|
||||
// Returns data to display list of entries to authenticated user
|
||||
|
||||
$uid = $_SESSION['uid'];
|
||||
$uid = $uInfo->id;
|
||||
// if(!$uid) {
|
||||
// die("User not authenticated!");
|
||||
// }
|
||||
@ -15,7 +25,8 @@
|
||||
die("Unable to load configuration file!");
|
||||
}
|
||||
$aid = $_GET['aid'];
|
||||
$isAdmin = $_SESSION['admin']==1;
|
||||
$isAdmin = $uInfo->userPrincipalName==$cfg['admin'];
|
||||
|
||||
|
||||
$mysqli = new mysqli($cfg['host'], $cfg['user'],$cfg['pass'], $cfg['name']);
|
||||
if ($mysqli->connect_errno) {
|
||||
@ -38,6 +49,7 @@
|
||||
$query = substr($query, 0, -5);
|
||||
}
|
||||
$query .= ' ORDER BY ID';
|
||||
// file_put_contents('/tmp/zut',$query);
|
||||
if ($result = $mysqli->query($query)) {
|
||||
|
||||
/* fetch associative array */
|
||||
@ -54,8 +66,8 @@
|
||||
$one[$key] = $val;
|
||||
}
|
||||
$one['name'] = $row["name"];
|
||||
if($one['demande_pour'] != $row["name"]) {
|
||||
$one['name'] .= ' / ' . $one['demande_pour'];
|
||||
if($one['name'] != $row["reqname"]) {
|
||||
$one['name'] .= ' / ' . $row['reqname'];
|
||||
}
|
||||
$obj['data'][] = $one;
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
"require": {
|
||||
"google/apiclient": "^2.1",
|
||||
"stefangabos/zebra_form": "^2.9",
|
||||
"phpoffice/phpexcel": "^1.8"
|
||||
"phpoffice/phpexcel": "^1.8",
|
||||
"phpoffice/phpspreadsheet": "^1.6"
|
||||
}
|
||||
}
|
||||
|
||||
309
composer.lock
generated
309
composer.lock
generated
@ -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": "90b442b74cfbb9deb4c2e60e01b68f98",
|
||||
"content-hash": "3ac0140687a9a5f3cb7ff764ee60e29c",
|
||||
"packages": [
|
||||
{
|
||||
"name": "firebase/php-jwt",
|
||||
@ -378,6 +378,171 @@
|
||||
],
|
||||
"time": "2018-12-04T20:46:45+00:00"
|
||||
},
|
||||
{
|
||||
"name": "markbaker/complex",
|
||||
"version": "1.4.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/MarkBaker/PHPComplex.git",
|
||||
"reference": "1ea674a8308baf547cbcbd30c5fcd6d301b7c000"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/1ea674a8308baf547cbcbd30c5fcd6d301b7c000",
|
||||
"reference": "1ea674a8308baf547cbcbd30c5fcd6d301b7c000",
|
||||
"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": {
|
||||
"Complex\\": "classes/src/"
|
||||
},
|
||||
"files": [
|
||||
"classes/src/functions/abs.php",
|
||||
"classes/src/functions/acos.php",
|
||||
"classes/src/functions/acosh.php",
|
||||
"classes/src/functions/acot.php",
|
||||
"classes/src/functions/acoth.php",
|
||||
"classes/src/functions/acsc.php",
|
||||
"classes/src/functions/acsch.php",
|
||||
"classes/src/functions/argument.php",
|
||||
"classes/src/functions/asec.php",
|
||||
"classes/src/functions/asech.php",
|
||||
"classes/src/functions/asin.php",
|
||||
"classes/src/functions/asinh.php",
|
||||
"classes/src/functions/atan.php",
|
||||
"classes/src/functions/atanh.php",
|
||||
"classes/src/functions/conjugate.php",
|
||||
"classes/src/functions/cos.php",
|
||||
"classes/src/functions/cosh.php",
|
||||
"classes/src/functions/cot.php",
|
||||
"classes/src/functions/coth.php",
|
||||
"classes/src/functions/csc.php",
|
||||
"classes/src/functions/csch.php",
|
||||
"classes/src/functions/exp.php",
|
||||
"classes/src/functions/inverse.php",
|
||||
"classes/src/functions/ln.php",
|
||||
"classes/src/functions/log2.php",
|
||||
"classes/src/functions/log10.php",
|
||||
"classes/src/functions/negative.php",
|
||||
"classes/src/functions/pow.php",
|
||||
"classes/src/functions/rho.php",
|
||||
"classes/src/functions/sec.php",
|
||||
"classes/src/functions/sech.php",
|
||||
"classes/src/functions/sin.php",
|
||||
"classes/src/functions/sinh.php",
|
||||
"classes/src/functions/sqrt.php",
|
||||
"classes/src/functions/tan.php",
|
||||
"classes/src/functions/tanh.php",
|
||||
"classes/src/functions/theta.php",
|
||||
"classes/src/operations/add.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 complex numbers",
|
||||
"homepage": "https://github.com/MarkBaker/PHPComplex",
|
||||
"keywords": [
|
||||
"complex",
|
||||
"mathematics"
|
||||
],
|
||||
"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": "monolog/monolog",
|
||||
"version": "1.24.0",
|
||||
@ -519,6 +684,100 @@
|
||||
"abandoned": "phpoffice/phpspreadsheet",
|
||||
"time": "2018-11-22T23:07:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpoffice/phpspreadsheet",
|
||||
"version": "1.6.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
|
||||
"reference": "bf00f0cc5f55c354018f9a9ef15e6e3e1a229051"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/bf00f0cc5f55c354018f9a9ef15e6e3e1a229051",
|
||||
"reference": "bf00f0cc5f55c354018f9a9ef15e6e3e1a229051",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-ctype": "*",
|
||||
"ext-dom": "*",
|
||||
"ext-fileinfo": "*",
|
||||
"ext-gd": "*",
|
||||
"ext-iconv": "*",
|
||||
"ext-libxml": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-simplexml": "*",
|
||||
"ext-xml": "*",
|
||||
"ext-xmlreader": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"ext-zip": "*",
|
||||
"ext-zlib": "*",
|
||||
"markbaker/complex": "^1.4",
|
||||
"markbaker/matrix": "^1.1",
|
||||
"php": "^5.6|^7.0",
|
||||
"psr/simple-cache": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/instantiator": "^1.0.0",
|
||||
"dompdf/dompdf": "^0.8.0",
|
||||
"friendsofphp/php-cs-fixer": "@stable",
|
||||
"jpgraph/jpgraph": "^4.0",
|
||||
"mpdf/mpdf": "^7.0.0",
|
||||
"phpcompatibility/php-compatibility": "^8.0",
|
||||
"phpunit/phpunit": "^5.7",
|
||||
"squizlabs/php_codesniffer": "^3.3",
|
||||
"tecnickcom/tcpdf": "^6.2"
|
||||
},
|
||||
"suggest": {
|
||||
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
|
||||
"jpgraph/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
|
||||
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
|
||||
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPL-2.1-or-later"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Erik Tilt"
|
||||
},
|
||||
{
|
||||
"name": "Adrien Crivelli"
|
||||
},
|
||||
{
|
||||
"name": "Maarten Balliauw",
|
||||
"homepage": "https://blog.maartenballiauw.be"
|
||||
},
|
||||
{
|
||||
"name": "Mark Baker",
|
||||
"homepage": "https://markbakeruk.net"
|
||||
},
|
||||
{
|
||||
"name": "Franck Lefevre",
|
||||
"homepage": "https://rootslabs.net"
|
||||
}
|
||||
],
|
||||
"description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
|
||||
"homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
|
||||
"keywords": [
|
||||
"OpenXML",
|
||||
"excel",
|
||||
"gnumeric",
|
||||
"ods",
|
||||
"php",
|
||||
"spreadsheet",
|
||||
"xls",
|
||||
"xlsx"
|
||||
],
|
||||
"time": "2019-01-02T04:42:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpseclib/phpseclib",
|
||||
"version": "2.0.15",
|
||||
@ -754,6 +1013,54 @@
|
||||
],
|
||||
"time": "2018-11-20T15:27:04+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/simple-cache",
|
||||
"version": "1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/simple-cache.git",
|
||||
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
|
||||
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\SimpleCache\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interfaces for simple caching",
|
||||
"keywords": [
|
||||
"cache",
|
||||
"caching",
|
||||
"psr",
|
||||
"psr-16",
|
||||
"simple-cache"
|
||||
],
|
||||
"time": "2017-10-23T01:57:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "ralouphie/getallheaders",
|
||||
"version": "2.0.5",
|
||||
|
||||
BIN
guide-accred-v1.pdf
Normal file
BIN
guide-accred-v1.pdf
Normal file
Binary file not shown.
88
index.php
88
index.php
@ -1,78 +1,16 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL & ~E_NOTICE );
|
||||
// start session
|
||||
$cfg = include('accred_config.php');
|
||||
if (session_status() == PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
$userid = $_SESSION['uid'];
|
||||
}
|
||||
// If we are logged-in, redirect to the list page.
|
||||
if($userid) {
|
||||
header("location: accred_list");
|
||||
die();
|
||||
}
|
||||
?>
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL & ~E_NOTICE );
|
||||
$cfg = include('accred_config.php');
|
||||
//
|
||||
// Load the auth module, this will redirect us to login if we aren't already logged in.
|
||||
include '../inc/auth.php';
|
||||
$Auth = new modAuth();
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="google-signin-client_id" content="538635499162-g21v86gk87qm863u03er6vnm3q15bl82.apps.googleusercontent.com">
|
||||
<script src="https://apis.google.com/js/platform.js" async defer></script>
|
||||
|
||||
<title>Carbana Accréditations</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="accred_style.css">
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="signin">
|
||||
<span id="logo">
|
||||
<img class="loginlogo" src="Caribana_2019_logo_hor.png"/></span>
|
||||
|
||||
<h2>Identification</h2><br>
|
||||
<h2> Saisis ton nom d'utilisateur et mot de passe gmail pour t'identifier et accéder aux demandes d'accréditation en utilisant le bouton ci-dessous.</h2>
|
||||
<h3>Le mot de passe n'est pas transmis à Caribana.</h3>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<div class="g-signin2" data-onsuccess="onSignIn"></div>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
function onSignIn(googleUser) {
|
||||
var profile = googleUser.getBasicProfile();
|
||||
var id_token = googleUser.getAuthResponse().id_token;
|
||||
console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
|
||||
console.log('Name: ' + profile.getName());
|
||||
console.log('Image URL: ' + profile.getImageUrl());
|
||||
console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
|
||||
console.log('Token: ' + id_token);
|
||||
console.log("Preparing to call tokensignin");
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open('POST', 'https://accred.caribana-festival.ch/tokensignin');
|
||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
xhr.onload = function() {
|
||||
console.log('Signed in as: ' + xhr.responseText);
|
||||
self.location = 'accred_list';
|
||||
};
|
||||
xhr.onerror = function() {
|
||||
console.log("ERROR");
|
||||
alert("Error");
|
||||
};
|
||||
console.log(xhr);
|
||||
xhr.send('idtoken=' + id_token);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
// We get here if authenticated
|
||||
// If we are logged-in, redirect to the list page.
|
||||
header("location: accred_list");
|
||||
die();
|
||||
//
|
||||
|
||||
51
oauth.php
Normal file
51
oauth.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/* oauth.php Azure AD oAuth web callback script
|
||||
*
|
||||
* Katy Nicholson, last updated 17/11/2021
|
||||
*
|
||||
* https://github.com/CoasterKaty
|
||||
* https://katytech.blog/
|
||||
* https://twitter.com/coaster_katy
|
||||
*
|
||||
*/
|
||||
require_once '../inc/mysql.php';
|
||||
require_once '../inc/oauth.php';
|
||||
|
||||
|
||||
session_start();
|
||||
$modDB = new modDB();
|
||||
$oAuth = new modOAuth();
|
||||
if ($_GET['error']) {
|
||||
echo $oAuth->errorMessage($_GET['error_description']);
|
||||
exit;
|
||||
}
|
||||
//retrieve session data from database
|
||||
$sessionData = $modDB->QuerySingle('SELECT * FROM tblAuthSessions WHERE txtSessionKey=\'' . $modDB->Escape($_SESSION['sessionkey']) . '\'');
|
||||
|
||||
if ($sessionData) {
|
||||
// Request token from Azure AD
|
||||
$oauthRequest = $oAuth->generateRequest('grant_type=authorization_code&client_id=' . _OAUTH_CLIENTID . '&redirect_uri=' . urlencode(_URL . '/oauth.php') . '&code=' . $_GET['code'] . '&code_verifier=' . $sessionData['txtCodeVerifier']);
|
||||
|
||||
$response = $oAuth->postRequest('token', $oauthRequest);
|
||||
|
||||
// Decode response from Azure AD. Extract JWT data from supplied access_token and id_token and update database.
|
||||
if (!$response) {
|
||||
echo $oAuth->errorMessage('Unknown error acquiring token');
|
||||
exit;
|
||||
}
|
||||
$reply = json_decode($response);
|
||||
if ($reply->error) {
|
||||
echo $oAuth->errorMessage($reply->error_description);
|
||||
exit;
|
||||
}
|
||||
|
||||
$idToken = base64_decode(explode('.', $reply->id_token)[1]);
|
||||
|
||||
$modDB->Update('tblAuthSessions', array('txtToken' => $reply->access_token, 'txtRefreshToken' => $reply->refresh_token, 'txtIDToken' => $idToken, 'txtRedir' => '', 'dtExpires' => date('Y-m-d H:i:s', strtotime('+' . $reply->expires_in . ' seconds'))), array('intAuthID' => $sessionData['intAuthID']));
|
||||
// Redirect user back to where they came from.
|
||||
header('Location: ' . $sessionData['txtRedir']);
|
||||
} else {
|
||||
header('Location: /');
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,67 +0,0 @@
|
||||
<?php
|
||||
require_once 'vendor/autoload.php';
|
||||
$cfg = include('accred_config.php');
|
||||
session_start();
|
||||
$mode = $_POST['mode'];
|
||||
|
||||
openlog('ACCRED', LOG_PID, LOG_LOCAL0);
|
||||
if($mode=='logout') {
|
||||
|
||||
$mysqli = new mysqli($cfg['host'], $cfg['user'],$cfg['pass'], $cfg['name']);
|
||||
if ($mysqli->connect_errno) {
|
||||
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
|
||||
}
|
||||
$query = "INSERT INTO log (uid,name,isadmin,operation) values('".$_SESSION['uid']."','".$_SESSION['name']."',". $_SESSION['admin'].", 'logout')";
|
||||
$mysqli->query($query);
|
||||
syslog(LOG_INFO, "Logout ".$_SESSION['uid']." / ". $_SESSION['name']. " from : {$_SERVER['REMOTE_ADDR']} ({$_SERVER['HTTP_USER_AGENT']})");
|
||||
$_SESSION['uid']='';
|
||||
$_SESSION['admin']='';
|
||||
$_SESSION['name']='';
|
||||
$_SESSION['allowedit'] = '';
|
||||
|
||||
closelog();
|
||||
die();
|
||||
|
||||
}
|
||||
$id_token = $_POST['idtoken'];
|
||||
|
||||
$admins = array('106388451999977183087' => 'Y', // Jess
|
||||
'113391142723644034553' => 'Y' // Lars
|
||||
|
||||
);
|
||||
$client = new Google_Client(['client_id' => '538635499162-g21v86gk87qm863u03er6vnm3q15bl82.apps.googleusercontent.com']);
|
||||
$payload = $client->verifyIdToken($id_token);
|
||||
if ($payload) {
|
||||
$userid = $payload['sub'];
|
||||
// If request specified a G Suite domain:
|
||||
$domain = $payload['hd'];
|
||||
|
||||
if($domain=='caribana.ch') {
|
||||
// Associate user info to session si we can use it later
|
||||
$_SESSION['uid'] = $userid;
|
||||
$_SESSION['dom'] = $domain;
|
||||
$_SESSION['email'] = $payload['email'];
|
||||
$_SESSION['name'] = $payload['name'];
|
||||
// Is this user admin
|
||||
$_SESSION['admin'] = '';
|
||||
// Set to 1 to allow normal users to add new entries en edit existing
|
||||
$_SESSION['allowedit'] = 1;
|
||||
if( array_key_exists($userid, $admins)) {
|
||||
$_SESSION['admin'] = 1;
|
||||
}
|
||||
echo "SUCCESS: $userid / DOMAIN: $domain";
|
||||
syslog(LOG_INFO, "Authorized login $userid / ". $payload['name']. ",domain: $domain from : {$_SERVER['REMOTE_ADDR']} ({$_SERVER['HTTP_USER_AGENT']})");
|
||||
}
|
||||
else {
|
||||
syslog(LOG_ERR, "Failed login ". $payload['name']. " from : {$_SERVER['REMOTE_ADDR']} ({$_SERVER['HTTP_USER_AGENT']}), incorrect domain: $domain");
|
||||
echo "FAIL";
|
||||
}
|
||||
} else {
|
||||
// Invalid ID token
|
||||
syslog(LOG_ERR, "Failed login ". $payload['name']. " from : {$_SERVER['REMOTE_ADDR']} ({$_SERVER['HTTP_USER_AGENT']})");
|
||||
closelog();
|
||||
echo "FAIL";
|
||||
}
|
||||
closelog();
|
||||
|
||||
?>
|
||||
58
vendor/composer/autoload_files.php
vendored
58
vendor/composer/autoload_files.php
vendored
@ -10,5 +10,63 @@ return array(
|
||||
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
|
||||
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
|
||||
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
|
||||
'abede361264e2ae69ec1eee813a101af' => $vendorDir . '/markbaker/complex/classes/src/functions/abs.php',
|
||||
'21a5860fbef5be28db5ddfbc3cca67c4' => $vendorDir . '/markbaker/complex/classes/src/functions/acos.php',
|
||||
'1546e3f9d127f2a9bb2d1b6c31c26ef1' => $vendorDir . '/markbaker/complex/classes/src/functions/acosh.php',
|
||||
'd2516f7f4fba5ea5905f494b4a8262e0' => $vendorDir . '/markbaker/complex/classes/src/functions/acot.php',
|
||||
'4511163d560956219b96882c0980b65e' => $vendorDir . '/markbaker/complex/classes/src/functions/acoth.php',
|
||||
'c361f5616dc2a8da4fa3e137077cd4ea' => $vendorDir . '/markbaker/complex/classes/src/functions/acsc.php',
|
||||
'02d68920fc98da71991ce569c91df0f6' => $vendorDir . '/markbaker/complex/classes/src/functions/acsch.php',
|
||||
'88e19525eae308b4a6aa3419364875d3' => $vendorDir . '/markbaker/complex/classes/src/functions/argument.php',
|
||||
'60e8e2d0827b58bfc904f13957e51849' => $vendorDir . '/markbaker/complex/classes/src/functions/asec.php',
|
||||
'13d2f040713999eab66c359b4d79871d' => $vendorDir . '/markbaker/complex/classes/src/functions/asech.php',
|
||||
'838ab38beb32c68a79d3cd2c007d5a04' => $vendorDir . '/markbaker/complex/classes/src/functions/asin.php',
|
||||
'bb28eccd0f8f008333a1b3c163d604ac' => $vendorDir . '/markbaker/complex/classes/src/functions/asinh.php',
|
||||
'9e483de83558c98f7d3feaa402c78cb3' => $vendorDir . '/markbaker/complex/classes/src/functions/atan.php',
|
||||
'36b74b5b765ded91ee58c8ee3c0e85e3' => $vendorDir . '/markbaker/complex/classes/src/functions/atanh.php',
|
||||
'05c15ee9510da7fd6bf6136f436500c0' => $vendorDir . '/markbaker/complex/classes/src/functions/conjugate.php',
|
||||
'd3208dfbce2505e370788f9f22f6785f' => $vendorDir . '/markbaker/complex/classes/src/functions/cos.php',
|
||||
'141cf1fb3a3046f8b64534b0ebab33ca' => $vendorDir . '/markbaker/complex/classes/src/functions/cosh.php',
|
||||
'be660df75fd0dbe7fa7c03b7434b3294' => $vendorDir . '/markbaker/complex/classes/src/functions/cot.php',
|
||||
'01e31ea298a51bc9e91517e3ce6b9e76' => $vendorDir . '/markbaker/complex/classes/src/functions/coth.php',
|
||||
'803ddd97f7b1da68982a7b087c3476f6' => $vendorDir . '/markbaker/complex/classes/src/functions/csc.php',
|
||||
'3001cdfd101ec3c32da34ee43c2e149b' => $vendorDir . '/markbaker/complex/classes/src/functions/csch.php',
|
||||
'77b2d7629ef2a93fabb8c56754a91051' => $vendorDir . '/markbaker/complex/classes/src/functions/exp.php',
|
||||
'4a4471296dec796c21d4f4b6552396a9' => $vendorDir . '/markbaker/complex/classes/src/functions/inverse.php',
|
||||
'c3e9897e1744b88deb56fcdc39d34d85' => $vendorDir . '/markbaker/complex/classes/src/functions/ln.php',
|
||||
'a83cacf2de942cff288de15a83afd26d' => $vendorDir . '/markbaker/complex/classes/src/functions/log2.php',
|
||||
'6a861dacc9ee2f3061241d4c7772fa21' => $vendorDir . '/markbaker/complex/classes/src/functions/log10.php',
|
||||
'4d2522d968c8ba78d6c13548a1b4200e' => $vendorDir . '/markbaker/complex/classes/src/functions/negative.php',
|
||||
'fd587ca933fc0447fa5ab4843bdd97f7' => $vendorDir . '/markbaker/complex/classes/src/functions/pow.php',
|
||||
'383ef01c62028fc78cd4388082fce3c2' => $vendorDir . '/markbaker/complex/classes/src/functions/rho.php',
|
||||
'150fbd1b95029dc47292da97ecab9375' => $vendorDir . '/markbaker/complex/classes/src/functions/sec.php',
|
||||
'549abd9bae174286d660bdaa07407c68' => $vendorDir . '/markbaker/complex/classes/src/functions/sech.php',
|
||||
'6bfbf5eaea6b17a0ed85cb21ba80370c' => $vendorDir . '/markbaker/complex/classes/src/functions/sin.php',
|
||||
'22efe13f1a497b8e199540ae2d9dc59c' => $vendorDir . '/markbaker/complex/classes/src/functions/sinh.php',
|
||||
'e90135ab8e787795a509ed7147de207d' => $vendorDir . '/markbaker/complex/classes/src/functions/sqrt.php',
|
||||
'bb0a7923ffc6a90919cd64ec54ff06bc' => $vendorDir . '/markbaker/complex/classes/src/functions/tan.php',
|
||||
'2d302f32ce0fd4e433dd91c5bb404a28' => $vendorDir . '/markbaker/complex/classes/src/functions/tanh.php',
|
||||
'24dd4658a952171a4ee79218c4f9fd06' => $vendorDir . '/markbaker/complex/classes/src/functions/theta.php',
|
||||
'e49b7876281d6f5bc39536dde96d1f4a' => $vendorDir . '/markbaker/complex/classes/src/operations/add.php',
|
||||
'47596e02b43cd6da7700134fd08f88cf' => $vendorDir . '/markbaker/complex/classes/src/operations/subtract.php',
|
||||
'883af48563631547925fa4c3b48ead07' => $vendorDir . '/markbaker/complex/classes/src/operations/multiply.php',
|
||||
'f190e3308e6ca23234a2875edc985c03' => $vendorDir . '/markbaker/complex/classes/src/operations/divideby.php',
|
||||
'ac9e33ce6841aa5bf5d16d465a2f03a7' => $vendorDir . '/markbaker/complex/classes/src/operations/divideinto.php',
|
||||
'9d8e013a5160a09477beb8e44f8ae97b' => $vendorDir . '/markbaker/matrix/classes/src/functions/adjoint.php',
|
||||
'6e78d1bdea6248d6aa117229efae50f2' => $vendorDir . '/markbaker/matrix/classes/src/functions/antidiagonal.php',
|
||||
'4623d87924d94f5412fe5afbf1cef31d' => $vendorDir . '/markbaker/matrix/classes/src/functions/cofactors.php',
|
||||
'901fd1f6950a637ca85f66b701a45e13' => $vendorDir . '/markbaker/matrix/classes/src/functions/determinant.php',
|
||||
'83057abc0e4acc99ba80154ee5d02a49' => $vendorDir . '/markbaker/matrix/classes/src/functions/diagonal.php',
|
||||
'07b7fd7a434451149b4fd477fca0ce06' => $vendorDir . '/markbaker/matrix/classes/src/functions/identity.php',
|
||||
'c8d43b340583e07ae89f2a3baef2cf89' => $vendorDir . '/markbaker/matrix/classes/src/functions/inverse.php',
|
||||
'499bb10ed7a3aee2ba4c09a31a85e8d1' => $vendorDir . '/markbaker/matrix/classes/src/functions/minors.php',
|
||||
'1cad2e6414d652e8b1c64e8967f6f37d' => $vendorDir . '/markbaker/matrix/classes/src/functions/trace.php',
|
||||
'95a7f134ac17161d07def442b3b737e8' => $vendorDir . '/markbaker/matrix/classes/src/functions/transpose.php',
|
||||
'b3a6bc628377118d4b4b8ba08d1eb949' => $vendorDir . '/markbaker/matrix/classes/src/operations/add.php',
|
||||
'5fef6d0e407f3f8887266dfa4a6c534c' => $vendorDir . '/markbaker/matrix/classes/src/operations/directsum.php',
|
||||
'684ba247e1385946e3babdaa054119de' => $vendorDir . '/markbaker/matrix/classes/src/operations/subtract.php',
|
||||
'aa53dcba601214d17ad405b7c291b7e8' => $vendorDir . '/markbaker/matrix/classes/src/operations/multiply.php',
|
||||
'75c79eb1b25749b05a47976f32b0d8a2' => $vendorDir . '/markbaker/matrix/classes/src/operations/divideby.php',
|
||||
'6ab8ad87a734f276a6bcd5a0fe1289be' => $vendorDir . '/markbaker/matrix/classes/src/operations/divideinto.php',
|
||||
'decc78cc4436b1292c6c0d151b19445c' => $vendorDir . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
|
||||
);
|
||||
|
||||
4
vendor/composer/autoload_psr4.php
vendored
4
vendor/composer/autoload_psr4.php
vendored
@ -7,13 +7,17 @@ $baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'phpseclib\\' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
|
||||
'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'),
|
||||
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
|
||||
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
|
||||
'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'),
|
||||
'PhpOffice\\PhpSpreadsheet\\' => array($vendorDir . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet'),
|
||||
'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
|
||||
'Matrix\\' => array($vendorDir . '/markbaker/matrix/classes/src'),
|
||||
'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
|
||||
'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'),
|
||||
'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
|
||||
'Google\\Auth\\' => array($vendorDir . '/google/auth/src'),
|
||||
'Firebase\\JWT\\' => array($vendorDir . '/firebase/php-jwt/src'),
|
||||
'Complex\\' => array($vendorDir . '/markbaker/complex/classes/src'),
|
||||
);
|
||||
|
||||
81
vendor/composer/autoload_static.php
vendored
81
vendor/composer/autoload_static.php
vendored
@ -11,6 +11,64 @@ class ComposerStaticInit5e45d0d6c07c4cb7b909eede38ad55d6
|
||||
'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
|
||||
'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
|
||||
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
|
||||
'abede361264e2ae69ec1eee813a101af' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/abs.php',
|
||||
'21a5860fbef5be28db5ddfbc3cca67c4' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/acos.php',
|
||||
'1546e3f9d127f2a9bb2d1b6c31c26ef1' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/acosh.php',
|
||||
'd2516f7f4fba5ea5905f494b4a8262e0' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/acot.php',
|
||||
'4511163d560956219b96882c0980b65e' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/acoth.php',
|
||||
'c361f5616dc2a8da4fa3e137077cd4ea' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/acsc.php',
|
||||
'02d68920fc98da71991ce569c91df0f6' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/acsch.php',
|
||||
'88e19525eae308b4a6aa3419364875d3' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/argument.php',
|
||||
'60e8e2d0827b58bfc904f13957e51849' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/asec.php',
|
||||
'13d2f040713999eab66c359b4d79871d' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/asech.php',
|
||||
'838ab38beb32c68a79d3cd2c007d5a04' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/asin.php',
|
||||
'bb28eccd0f8f008333a1b3c163d604ac' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/asinh.php',
|
||||
'9e483de83558c98f7d3feaa402c78cb3' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/atan.php',
|
||||
'36b74b5b765ded91ee58c8ee3c0e85e3' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/atanh.php',
|
||||
'05c15ee9510da7fd6bf6136f436500c0' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/conjugate.php',
|
||||
'd3208dfbce2505e370788f9f22f6785f' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/cos.php',
|
||||
'141cf1fb3a3046f8b64534b0ebab33ca' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/cosh.php',
|
||||
'be660df75fd0dbe7fa7c03b7434b3294' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/cot.php',
|
||||
'01e31ea298a51bc9e91517e3ce6b9e76' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/coth.php',
|
||||
'803ddd97f7b1da68982a7b087c3476f6' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/csc.php',
|
||||
'3001cdfd101ec3c32da34ee43c2e149b' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/csch.php',
|
||||
'77b2d7629ef2a93fabb8c56754a91051' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/exp.php',
|
||||
'4a4471296dec796c21d4f4b6552396a9' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/inverse.php',
|
||||
'c3e9897e1744b88deb56fcdc39d34d85' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/ln.php',
|
||||
'a83cacf2de942cff288de15a83afd26d' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/log2.php',
|
||||
'6a861dacc9ee2f3061241d4c7772fa21' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/log10.php',
|
||||
'4d2522d968c8ba78d6c13548a1b4200e' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/negative.php',
|
||||
'fd587ca933fc0447fa5ab4843bdd97f7' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/pow.php',
|
||||
'383ef01c62028fc78cd4388082fce3c2' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/rho.php',
|
||||
'150fbd1b95029dc47292da97ecab9375' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/sec.php',
|
||||
'549abd9bae174286d660bdaa07407c68' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/sech.php',
|
||||
'6bfbf5eaea6b17a0ed85cb21ba80370c' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/sin.php',
|
||||
'22efe13f1a497b8e199540ae2d9dc59c' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/sinh.php',
|
||||
'e90135ab8e787795a509ed7147de207d' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/sqrt.php',
|
||||
'bb0a7923ffc6a90919cd64ec54ff06bc' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/tan.php',
|
||||
'2d302f32ce0fd4e433dd91c5bb404a28' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/tanh.php',
|
||||
'24dd4658a952171a4ee79218c4f9fd06' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/theta.php',
|
||||
'e49b7876281d6f5bc39536dde96d1f4a' => __DIR__ . '/..' . '/markbaker/complex/classes/src/operations/add.php',
|
||||
'47596e02b43cd6da7700134fd08f88cf' => __DIR__ . '/..' . '/markbaker/complex/classes/src/operations/subtract.php',
|
||||
'883af48563631547925fa4c3b48ead07' => __DIR__ . '/..' . '/markbaker/complex/classes/src/operations/multiply.php',
|
||||
'f190e3308e6ca23234a2875edc985c03' => __DIR__ . '/..' . '/markbaker/complex/classes/src/operations/divideby.php',
|
||||
'ac9e33ce6841aa5bf5d16d465a2f03a7' => __DIR__ . '/..' . '/markbaker/complex/classes/src/operations/divideinto.php',
|
||||
'9d8e013a5160a09477beb8e44f8ae97b' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/adjoint.php',
|
||||
'6e78d1bdea6248d6aa117229efae50f2' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/antidiagonal.php',
|
||||
'4623d87924d94f5412fe5afbf1cef31d' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/cofactors.php',
|
||||
'901fd1f6950a637ca85f66b701a45e13' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/determinant.php',
|
||||
'83057abc0e4acc99ba80154ee5d02a49' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/diagonal.php',
|
||||
'07b7fd7a434451149b4fd477fca0ce06' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/identity.php',
|
||||
'c8d43b340583e07ae89f2a3baef2cf89' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/inverse.php',
|
||||
'499bb10ed7a3aee2ba4c09a31a85e8d1' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/minors.php',
|
||||
'1cad2e6414d652e8b1c64e8967f6f37d' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/trace.php',
|
||||
'95a7f134ac17161d07def442b3b737e8' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/transpose.php',
|
||||
'b3a6bc628377118d4b4b8ba08d1eb949' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/operations/add.php',
|
||||
'5fef6d0e407f3f8887266dfa4a6c534c' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/operations/directsum.php',
|
||||
'684ba247e1385946e3babdaa054119de' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/operations/subtract.php',
|
||||
'aa53dcba601214d17ad405b7c291b7e8' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/operations/multiply.php',
|
||||
'75c79eb1b25749b05a47976f32b0d8a2' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/operations/divideby.php',
|
||||
'6ab8ad87a734f276a6bcd5a0fe1289be' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/operations/divideinto.php',
|
||||
'decc78cc4436b1292c6c0d151b19445c' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
|
||||
);
|
||||
|
||||
@ -21,13 +79,16 @@ class ComposerStaticInit5e45d0d6c07c4cb7b909eede38ad55d6
|
||||
),
|
||||
'P' =>
|
||||
array (
|
||||
'Psr\\SimpleCache\\' => 16,
|
||||
'Psr\\Log\\' => 8,
|
||||
'Psr\\Http\\Message\\' => 17,
|
||||
'Psr\\Cache\\' => 10,
|
||||
'PhpOffice\\PhpSpreadsheet\\' => 25,
|
||||
),
|
||||
'M' =>
|
||||
array (
|
||||
'Monolog\\' => 8,
|
||||
'Matrix\\' => 7,
|
||||
),
|
||||
'G' =>
|
||||
array (
|
||||
@ -40,6 +101,10 @@ class ComposerStaticInit5e45d0d6c07c4cb7b909eede38ad55d6
|
||||
array (
|
||||
'Firebase\\JWT\\' => 13,
|
||||
),
|
||||
'C' =>
|
||||
array (
|
||||
'Complex\\' => 8,
|
||||
),
|
||||
);
|
||||
|
||||
public static $prefixDirsPsr4 = array (
|
||||
@ -47,6 +112,10 @@ class ComposerStaticInit5e45d0d6c07c4cb7b909eede38ad55d6
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib',
|
||||
),
|
||||
'Psr\\SimpleCache\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/psr/simple-cache/src',
|
||||
),
|
||||
'Psr\\Log\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
|
||||
@ -59,10 +128,18 @@ class ComposerStaticInit5e45d0d6c07c4cb7b909eede38ad55d6
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/psr/cache/src',
|
||||
),
|
||||
'PhpOffice\\PhpSpreadsheet\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet',
|
||||
),
|
||||
'Monolog\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/monolog/monolog/src/Monolog',
|
||||
),
|
||||
'Matrix\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/markbaker/matrix/classes/src',
|
||||
),
|
||||
'GuzzleHttp\\Psr7\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src',
|
||||
@ -83,6 +160,10 @@ class ComposerStaticInit5e45d0d6c07c4cb7b909eede38ad55d6
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/firebase/php-jwt/src',
|
||||
),
|
||||
'Complex\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/markbaker/complex/classes/src',
|
||||
),
|
||||
);
|
||||
|
||||
public static $prefixesPsr0 = array (
|
||||
|
||||
315
vendor/composer/installed.json
vendored
315
vendor/composer/installed.json
vendored
@ -385,6 +385,175 @@
|
||||
"url"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "markbaker/complex",
|
||||
"version": "1.4.7",
|
||||
"version_normalized": "1.4.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/MarkBaker/PHPComplex.git",
|
||||
"reference": "1ea674a8308baf547cbcbd30c5fcd6d301b7c000"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/1ea674a8308baf547cbcbd30c5fcd6d301b7c000",
|
||||
"reference": "1ea674a8308baf547cbcbd30c5fcd6d301b7c000",
|
||||
"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"
|
||||
},
|
||||
"time": "2018-10-13T23:28:42+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Complex\\": "classes/src/"
|
||||
},
|
||||
"files": [
|
||||
"classes/src/functions/abs.php",
|
||||
"classes/src/functions/acos.php",
|
||||
"classes/src/functions/acosh.php",
|
||||
"classes/src/functions/acot.php",
|
||||
"classes/src/functions/acoth.php",
|
||||
"classes/src/functions/acsc.php",
|
||||
"classes/src/functions/acsch.php",
|
||||
"classes/src/functions/argument.php",
|
||||
"classes/src/functions/asec.php",
|
||||
"classes/src/functions/asech.php",
|
||||
"classes/src/functions/asin.php",
|
||||
"classes/src/functions/asinh.php",
|
||||
"classes/src/functions/atan.php",
|
||||
"classes/src/functions/atanh.php",
|
||||
"classes/src/functions/conjugate.php",
|
||||
"classes/src/functions/cos.php",
|
||||
"classes/src/functions/cosh.php",
|
||||
"classes/src/functions/cot.php",
|
||||
"classes/src/functions/coth.php",
|
||||
"classes/src/functions/csc.php",
|
||||
"classes/src/functions/csch.php",
|
||||
"classes/src/functions/exp.php",
|
||||
"classes/src/functions/inverse.php",
|
||||
"classes/src/functions/ln.php",
|
||||
"classes/src/functions/log2.php",
|
||||
"classes/src/functions/log10.php",
|
||||
"classes/src/functions/negative.php",
|
||||
"classes/src/functions/pow.php",
|
||||
"classes/src/functions/rho.php",
|
||||
"classes/src/functions/sec.php",
|
||||
"classes/src/functions/sech.php",
|
||||
"classes/src/functions/sin.php",
|
||||
"classes/src/functions/sinh.php",
|
||||
"classes/src/functions/sqrt.php",
|
||||
"classes/src/functions/tan.php",
|
||||
"classes/src/functions/tanh.php",
|
||||
"classes/src/functions/theta.php",
|
||||
"classes/src/operations/add.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 complex numbers",
|
||||
"homepage": "https://github.com/MarkBaker/PHPComplex",
|
||||
"keywords": [
|
||||
"complex",
|
||||
"mathematics"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "markbaker/matrix",
|
||||
"version": "1.1.4",
|
||||
"version_normalized": "1.1.4.0",
|
||||
"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"
|
||||
},
|
||||
"time": "2018-11-04T22:12:12+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"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"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "monolog/monolog",
|
||||
"version": "1.24.0",
|
||||
@ -530,6 +699,102 @@
|
||||
],
|
||||
"abandoned": "phpoffice/phpspreadsheet"
|
||||
},
|
||||
{
|
||||
"name": "phpoffice/phpspreadsheet",
|
||||
"version": "1.6.0",
|
||||
"version_normalized": "1.6.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
|
||||
"reference": "bf00f0cc5f55c354018f9a9ef15e6e3e1a229051"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/bf00f0cc5f55c354018f9a9ef15e6e3e1a229051",
|
||||
"reference": "bf00f0cc5f55c354018f9a9ef15e6e3e1a229051",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-ctype": "*",
|
||||
"ext-dom": "*",
|
||||
"ext-fileinfo": "*",
|
||||
"ext-gd": "*",
|
||||
"ext-iconv": "*",
|
||||
"ext-libxml": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-simplexml": "*",
|
||||
"ext-xml": "*",
|
||||
"ext-xmlreader": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"ext-zip": "*",
|
||||
"ext-zlib": "*",
|
||||
"markbaker/complex": "^1.4",
|
||||
"markbaker/matrix": "^1.1",
|
||||
"php": "^5.6|^7.0",
|
||||
"psr/simple-cache": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/instantiator": "^1.0.0",
|
||||
"dompdf/dompdf": "^0.8.0",
|
||||
"friendsofphp/php-cs-fixer": "@stable",
|
||||
"jpgraph/jpgraph": "^4.0",
|
||||
"mpdf/mpdf": "^7.0.0",
|
||||
"phpcompatibility/php-compatibility": "^8.0",
|
||||
"phpunit/phpunit": "^5.7",
|
||||
"squizlabs/php_codesniffer": "^3.3",
|
||||
"tecnickcom/tcpdf": "^6.2"
|
||||
},
|
||||
"suggest": {
|
||||
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
|
||||
"jpgraph/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
|
||||
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
|
||||
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
|
||||
},
|
||||
"time": "2019-01-02T04:42:54+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPL-2.1-or-later"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Erik Tilt"
|
||||
},
|
||||
{
|
||||
"name": "Adrien Crivelli"
|
||||
},
|
||||
{
|
||||
"name": "Maarten Balliauw",
|
||||
"homepage": "https://blog.maartenballiauw.be"
|
||||
},
|
||||
{
|
||||
"name": "Mark Baker",
|
||||
"homepage": "https://markbakeruk.net"
|
||||
},
|
||||
{
|
||||
"name": "Franck Lefevre",
|
||||
"homepage": "https://rootslabs.net"
|
||||
}
|
||||
],
|
||||
"description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
|
||||
"homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
|
||||
"keywords": [
|
||||
"OpenXML",
|
||||
"excel",
|
||||
"gnumeric",
|
||||
"ods",
|
||||
"php",
|
||||
"spreadsheet",
|
||||
"xls",
|
||||
"xlsx"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "phpseclib/phpseclib",
|
||||
"version": "2.0.15",
|
||||
@ -773,6 +1038,56 @@
|
||||
"psr-3"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "psr/simple-cache",
|
||||
"version": "1.0.1",
|
||||
"version_normalized": "1.0.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/simple-cache.git",
|
||||
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
|
||||
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"time": "2017-10-23T01:57:42+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\SimpleCache\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interfaces for simple caching",
|
||||
"keywords": [
|
||||
"cache",
|
||||
"caching",
|
||||
"psr",
|
||||
"psr-16",
|
||||
"simple-cache"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ralouphie/getallheaders",
|
||||
"version": "2.0.5",
|
||||
|
||||
156
vendor/markbaker/complex/README.md
vendored
Normal file
156
vendor/markbaker/complex/README.md
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
PHPComplex
|
||||
==========
|
||||
|
||||
---
|
||||
|
||||
PHP Class for handling Complex numbers
|
||||
|
||||
Master: [](http://travis-ci.org/MarkBaker/PHPComplex)
|
||||
|
||||
Develop: [](http://travis-ci.org/MarkBaker/PHPComplex)
|
||||
|
||||
[](https://xkcd.com/2028/)
|
||||
|
||||
---
|
||||
|
||||
The library currently provides the following operations:
|
||||
|
||||
- addition
|
||||
- subtraction
|
||||
- multiplication
|
||||
- division
|
||||
- division by
|
||||
- division into
|
||||
|
||||
together with functions for
|
||||
|
||||
- theta (polar theta angle)
|
||||
- rho (polar distance/radius)
|
||||
- conjugate
|
||||
* negative
|
||||
- inverse (1 / complex)
|
||||
- cos (cosine)
|
||||
- acos (inverse cosine)
|
||||
- cosh (hyperbolic cosine)
|
||||
- acosh (inverse hyperbolic cosine)
|
||||
- sin (sine)
|
||||
- asin (inverse sine)
|
||||
- sinh (hyperbolic sine)
|
||||
- asinh (inverse hyperbolic sine)
|
||||
- sec (secant)
|
||||
- asec (inverse secant)
|
||||
- sech (hyperbolic secant)
|
||||
- asech (inverse hyperbolic secant)
|
||||
- csc (cosecant)
|
||||
- acsc (inverse cosecant)
|
||||
- csch (hyperbolic secant)
|
||||
- acsch (inverse hyperbolic secant)
|
||||
- tan (tangent)
|
||||
- atan (inverse tangent)
|
||||
- tanh (hyperbolic tangent)
|
||||
- atanh (inverse hyperbolic tangent)
|
||||
- cot (cotangent)
|
||||
- acot (inverse cotangent)
|
||||
- coth (hyperbolic cotangent)
|
||||
- acoth (inverse hyperbolic cotangent)
|
||||
- sqrt (square root)
|
||||
- exp (exponential)
|
||||
- ln (natural log)
|
||||
- log10 (base-10 log)
|
||||
- log2 (base-2 log)
|
||||
- pow (raised to the power of a real number)
|
||||
|
||||
|
||||
---
|
||||
|
||||
# Usage
|
||||
|
||||
To create a new complex object, you can provide either the real, imaginary and suffix parts as individual values, or as an array of values passed passed to the constructor; or a string representing the value. e.g
|
||||
|
||||
```
|
||||
$real = 1.23;
|
||||
$imaginary = -4.56;
|
||||
$suffix = 'i';
|
||||
|
||||
$complexObject = new Complex\Complex($real, $imaginary, $suffix);
|
||||
```
|
||||
or
|
||||
```
|
||||
$real = 1.23;
|
||||
$imaginary = -4.56;
|
||||
$suffix = 'i';
|
||||
|
||||
$arguments = [$real, $imaginary, $suffix];
|
||||
|
||||
$complexObject = new Complex\Complex($arguments);
|
||||
```
|
||||
or
|
||||
```
|
||||
$complexString = '1.23-4.56i';
|
||||
|
||||
$complexObject = new Complex\Complex($complexString);
|
||||
```
|
||||
|
||||
Complex objects are immutable: whenever you call a method or pass a complex value to a function that returns a complex value, a new Complex object will be returned, and the original will remain unchanged.
|
||||
This also allows you to chain multiple methods as you would for a fluent interface (as long as they are methods that will return a Complex result).
|
||||
|
||||
## Performing Mathematical Operations
|
||||
|
||||
To perform mathematical operations with Complex values, you can call the appropriate method against a complex value, passing other values as arguments
|
||||
|
||||
```
|
||||
$complexString1 = '1.23-4.56i';
|
||||
$complexString2 = '2.34+5.67i';
|
||||
|
||||
$complexObject = new Complex\Complex($complexString1);
|
||||
echo $complexObject->add($complexString2);
|
||||
```
|
||||
or pass all values to the appropriate function
|
||||
```
|
||||
$complexString1 = '1.23-4.56i';
|
||||
$complexString2 = '2.34+5.67i';
|
||||
|
||||
echo Complex\add($complexString1, $complexString2);
|
||||
```
|
||||
If you want to perform the same operation against multiple values (e.g. to add three or more complex numbers), then you can pass multiple arguments to any of the operations.
|
||||
|
||||
You can pass these arguments as Complex objects, or as an array or string that will parse to a complex object.
|
||||
|
||||
## Using functions
|
||||
|
||||
When calling any of the available functions for a complex value, you can either call the relevant method for the Complex object
|
||||
```
|
||||
$complexString = '1.23-4.56i';
|
||||
|
||||
$complexObject = new Complex\Complex($complexString);
|
||||
echo $complexObject->sinh();
|
||||
```
|
||||
or you can call the function as you would in procedural code, passing the Complex object as an argument
|
||||
```
|
||||
$complexString = '1.23-4.56i';
|
||||
|
||||
$complexObject = new Complex\Complex($complexString);
|
||||
echo Complex\sinh($complexObject);
|
||||
```
|
||||
When called procedurally using the function, you can pass in the argument as a Complex object, or as an array or string that will parse to a complex object.
|
||||
```
|
||||
$complexString = '1.23-4.56i';
|
||||
|
||||
echo Complex\sinh($complexString);
|
||||
```
|
||||
|
||||
In the case of the `pow()` function (the only implemented function that requires an additional argument) you need to pass both arguments when calling the function procedurally
|
||||
|
||||
```
|
||||
$complexString = '1.23-4.56i';
|
||||
|
||||
$complexObject = new Complex\Complex($complexString);
|
||||
echo Complex\pow($complexObject, 2);
|
||||
```
|
||||
or pass the additional argument when calling the method
|
||||
```
|
||||
$complexString = '1.23-4.56i';
|
||||
|
||||
$complexObject = new Complex\Complex($complexString);
|
||||
echo $complexObject->pow(2);
|
||||
```
|
||||
53
vendor/markbaker/complex/classes/Autoloader.php
vendored
Normal file
53
vendor/markbaker/complex/classes/Autoloader.php
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
*
|
||||
* Autoloader for Complex classes
|
||||
*
|
||||
* @package Complex
|
||||
* @copyright Copyright (c) 2014 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class Autoloader
|
||||
{
|
||||
/**
|
||||
* Register the Autoloader with SPL
|
||||
*
|
||||
*/
|
||||
public static function Register()
|
||||
{
|
||||
if (function_exists('__autoload')) {
|
||||
// Register any existing autoloader function with SPL, so we don't get any clashes
|
||||
spl_autoload_register('__autoload');
|
||||
}
|
||||
// Register ourselves with SPL
|
||||
return spl_autoload_register(['Complex\\Autoloader', 'Load']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Autoload a class identified by name
|
||||
*
|
||||
* @param string $pClassName Name of the object to load
|
||||
*/
|
||||
public static function Load($pClassName)
|
||||
{
|
||||
if ((class_exists($pClassName, false)) || (strpos($pClassName, 'Complex\\') !== 0)) {
|
||||
// Either already loaded, or not a Complex class request
|
||||
return false;
|
||||
}
|
||||
|
||||
$pClassFilePath = __DIR__ . DIRECTORY_SEPARATOR .
|
||||
'src' . DIRECTORY_SEPARATOR .
|
||||
str_replace(['Complex\\', '\\'], ['', '/'], $pClassName) .
|
||||
'.php';
|
||||
|
||||
if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
|
||||
// Can't load
|
||||
return false;
|
||||
}
|
||||
require($pClassFilePath);
|
||||
}
|
||||
}
|
||||
38
vendor/markbaker/complex/classes/Bootstrap.php
vendored
Normal file
38
vendor/markbaker/complex/classes/Bootstrap.php
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__ . '/Autoloader.php';
|
||||
|
||||
\Complex\Autoloader::Register();
|
||||
|
||||
|
||||
abstract class FilesystemRegexFilter extends RecursiveRegexIterator
|
||||
{
|
||||
protected $regex;
|
||||
public function __construct(RecursiveIterator $it, $regex)
|
||||
{
|
||||
$this->regex = $regex;
|
||||
parent::__construct($it, $regex);
|
||||
}
|
||||
}
|
||||
|
||||
class FilenameFilter extends FilesystemRegexFilter
|
||||
{
|
||||
// Filter files against the regex
|
||||
public function accept()
|
||||
{
|
||||
return (!$this->isFile() || preg_match($this->regex, $this->getFilename()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$srcFolder = __DIR__ . DIRECTORY_SEPARATOR . 'src';
|
||||
$srcDirectory = new RecursiveDirectoryIterator($srcFolder);
|
||||
|
||||
$filteredFileList = new FilenameFilter($srcDirectory, '/(?:php)$/i');
|
||||
$filteredFileList = new FilenameFilter($filteredFileList, '/^(?!.*(Complex|Exception)\.php).*$/i');
|
||||
|
||||
foreach (new RecursiveIteratorIterator($filteredFileList) as $file) {
|
||||
if ($file->isFile()) {
|
||||
include_once $file;
|
||||
}
|
||||
}
|
||||
387
vendor/markbaker/complex/classes/src/Complex.php
vendored
Normal file
387
vendor/markbaker/complex/classes/src/Complex.php
vendored
Normal file
@ -0,0 +1,387 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Class for the management of Complex numbers
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Complex Number object.
|
||||
*
|
||||
* @package Complex
|
||||
*
|
||||
* @method float abs()
|
||||
* @method Complex acos()
|
||||
* @method Complex acosh()
|
||||
* @method Complex acot()
|
||||
* @method Complex acoth()
|
||||
* @method Complex acsc()
|
||||
* @method Complex acsch()
|
||||
* @method float argument()
|
||||
* @method Complex asec()
|
||||
* @method Complex asech()
|
||||
* @method Complex asin()
|
||||
* @method Complex asinh()
|
||||
* @method Complex atan()
|
||||
* @method Complex atanh()
|
||||
* @method Complex conjugate()
|
||||
* @method Complex cos()
|
||||
* @method Complex cosh()
|
||||
* @method Complex cot()
|
||||
* @method Complex coth()
|
||||
* @method Complex csc()
|
||||
* @method Complex csch()
|
||||
* @method Complex exp()
|
||||
* @method Complex inverse()
|
||||
* @method Complex ln()
|
||||
* @method Complex log2()
|
||||
* @method Complex log10()
|
||||
* @method Complex negative()
|
||||
* @method Complex pow(int|float $power)
|
||||
* @method float rho()
|
||||
* @method Complex sec()
|
||||
* @method Complex sech()
|
||||
* @method Complex sin()
|
||||
* @method Complex sinh()
|
||||
* @method Complex sqrt()
|
||||
* @method Complex tan()
|
||||
* @method Complex tanh()
|
||||
* @method float theta()
|
||||
* @method Complex add(...$complexValues)
|
||||
* @method Complex subtract(...$complexValues)
|
||||
* @method Complex multiply(...$complexValues)
|
||||
* @method Complex divideby(...$complexValues)
|
||||
* @method Complex divideinto(...$complexValues)
|
||||
*/
|
||||
class Complex
|
||||
{
|
||||
/**
|
||||
* @constant Euler's Number.
|
||||
*/
|
||||
const EULER = 2.7182818284590452353602874713526624977572;
|
||||
|
||||
/**
|
||||
* @constant Regexp to split an input string into real and imaginary components and suffix
|
||||
*/
|
||||
const NUMBER_SPLIT_REGEXP =
|
||||
'` ^
|
||||
( # Real part
|
||||
[-+]?(\d+\.?\d*|\d*\.?\d+) # Real value (integer or float)
|
||||
([Ee][-+]?[0-2]?\d{1,3})? # Optional real exponent for scientific format
|
||||
)
|
||||
( # Imaginary part
|
||||
[-+]?(\d+\.?\d*|\d*\.?\d+) # Imaginary value (integer or float)
|
||||
([Ee][-+]?[0-2]?\d{1,3})? # Optional imaginary exponent for scientific format
|
||||
)?
|
||||
( # Imaginary part is optional
|
||||
([-+]?) # Imaginary (implicit 1 or -1) only
|
||||
([ij]?) # Imaginary i or j - depending on whether mathematical or engineering
|
||||
)
|
||||
$`uix';
|
||||
|
||||
/**
|
||||
* @var float $realPart The value of of this complex number on the real plane.
|
||||
*/
|
||||
protected $realPart = 0.0;
|
||||
|
||||
/**
|
||||
* @var float $imaginaryPart The value of of this complex number on the imaginary plane.
|
||||
*/
|
||||
protected $imaginaryPart = 0.0;
|
||||
|
||||
/**
|
||||
* @var string $suffix The suffix for this complex number (i or j).
|
||||
*/
|
||||
protected $suffix;
|
||||
|
||||
|
||||
/**
|
||||
* Validates whether the argument is a valid complex number, converting scalar or array values if possible
|
||||
*
|
||||
* @param mixed $complexNumber The value to parse
|
||||
* @return array
|
||||
* @throws Exception If the argument isn't a Complex number or cannot be converted to one
|
||||
*/
|
||||
private static function parseComplex($complexNumber)
|
||||
{
|
||||
// Test for real number, with no imaginary part
|
||||
if (is_numeric($complexNumber)) {
|
||||
return [$complexNumber, 0, null];
|
||||
}
|
||||
|
||||
// Fix silly human errors
|
||||
$complexNumber = str_replace(
|
||||
['+-', '-+', '++', '--'],
|
||||
['-', '-', '+', '+'],
|
||||
$complexNumber
|
||||
);
|
||||
|
||||
// Basic validation of string, to parse out real and imaginary parts, and any suffix
|
||||
$validComplex = preg_match(
|
||||
self::NUMBER_SPLIT_REGEXP,
|
||||
$complexNumber,
|
||||
$complexParts
|
||||
);
|
||||
|
||||
if (!$validComplex) {
|
||||
// Neither real nor imaginary part, so test to see if we actually have a suffix
|
||||
$validComplex = preg_match('/^([\-\+]?)([ij])$/ui', $complexNumber, $complexParts);
|
||||
if (!$validComplex) {
|
||||
throw new Exception('Invalid complex number');
|
||||
}
|
||||
// We have a suffix, so set the real to 0, the imaginary to either 1 or -1 (as defined by the sign)
|
||||
$imaginary = 1;
|
||||
if ($complexParts[1] === '-') {
|
||||
$imaginary = 0 - $imaginary;
|
||||
}
|
||||
return [0, $imaginary, $complexParts[2]];
|
||||
}
|
||||
|
||||
// If we don't have an imaginary part, identify whether it should be +1 or -1...
|
||||
if (($complexParts[4] === '') && ($complexParts[9] !== '')) {
|
||||
if ($complexParts[7] !== $complexParts[9]) {
|
||||
$complexParts[4] = 1;
|
||||
if ($complexParts[8] === '-') {
|
||||
$complexParts[4] = -1;
|
||||
}
|
||||
} else {
|
||||
// ... or if we have only the real and no imaginary part
|
||||
// (in which case our real should be the imaginary)
|
||||
$complexParts[4] = $complexParts[1];
|
||||
$complexParts[1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Return real and imaginary parts and suffix as an array, and set a default suffix if user input lazily
|
||||
return [
|
||||
$complexParts[1],
|
||||
$complexParts[4],
|
||||
!empty($complexParts[9]) ? $complexParts[9] : 'i'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function __construct($realPart = 0.0, $imaginaryPart = null, $suffix = 'i')
|
||||
{
|
||||
if ($imaginaryPart === null) {
|
||||
if (is_array($realPart)) {
|
||||
// We have an array of (potentially) real and imaginary parts, and any suffix
|
||||
list ($realPart, $imaginaryPart, $suffix) = array_values($realPart) + [0.0, 0.0, 'i'];
|
||||
} elseif ((is_string($realPart)) || (is_numeric($realPart))) {
|
||||
// We've been given a string to parse to extract the real and imaginary parts, and any suffix
|
||||
list($realPart, $imaginaryPart, $suffix) = self::parseComplex($realPart);
|
||||
}
|
||||
}
|
||||
if ($imaginaryPart <> 0.0 && empty($suffix)) {
|
||||
$suffix = 'i';
|
||||
}
|
||||
|
||||
// Set parsed values in our properties
|
||||
$this->realPart = (float) $realPart;
|
||||
$this->imaginaryPart = (float) $imaginaryPart;
|
||||
$this->suffix = strtolower($suffix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the real part of this complex number
|
||||
*
|
||||
* @return Float
|
||||
*/
|
||||
public function getReal()
|
||||
{
|
||||
return $this->realPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the imaginary part of this complex number
|
||||
*
|
||||
* @return Float
|
||||
*/
|
||||
public function getImaginary()
|
||||
{
|
||||
return $this->imaginaryPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the suffix of this complex number
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public function getSuffix()
|
||||
{
|
||||
return $this->suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this is a real value, false if a complex value
|
||||
*
|
||||
* @return Bool
|
||||
*/
|
||||
public function isReal()
|
||||
{
|
||||
return $this->imaginaryPart == 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this is a complex value, false if a real value
|
||||
*
|
||||
* @return Bool
|
||||
*/
|
||||
public function isComplex()
|
||||
{
|
||||
return !$this->isReal();
|
||||
}
|
||||
|
||||
public function format()
|
||||
{
|
||||
$str = "";
|
||||
if ($this->imaginaryPart != 0.0) {
|
||||
if (\abs($this->imaginaryPart) != 1.0) {
|
||||
$str .= $this->imaginaryPart . $this->suffix;
|
||||
} else {
|
||||
$str .= (($this->imaginaryPart < 0.0) ? '-' : '') . $this->suffix;
|
||||
}
|
||||
}
|
||||
if ($this->realPart != 0.0) {
|
||||
if (($str) && ($this->imaginaryPart > 0.0)) {
|
||||
$str = "+" . $str;
|
||||
}
|
||||
$str = $this->realPart . $str;
|
||||
}
|
||||
if (!$str) {
|
||||
$str = "0.0";
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->format();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates whether the argument is a valid complex number, converting scalar or array values if possible
|
||||
*
|
||||
* @param mixed $complex The value to validate
|
||||
* @return Complex
|
||||
* @throws Exception If the argument isn't a Complex number or cannot be converted to one
|
||||
*/
|
||||
public static function validateComplexArgument($complex)
|
||||
{
|
||||
if (is_scalar($complex) || is_array($complex)) {
|
||||
$complex = new Complex($complex);
|
||||
} elseif (!is_object($complex) || !($complex instanceof Complex)) {
|
||||
throw new Exception('Value is not a valid complex number');
|
||||
}
|
||||
|
||||
return $complex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reverse of this complex number
|
||||
*
|
||||
* @return Complex
|
||||
*/
|
||||
public function reverse()
|
||||
{
|
||||
return new Complex(
|
||||
$this->imaginaryPart,
|
||||
$this->realPart,
|
||||
($this->realPart == 0.0) ? null : $this->suffix
|
||||
);
|
||||
}
|
||||
|
||||
public function invertImaginary()
|
||||
{
|
||||
return new Complex(
|
||||
$this->realPart,
|
||||
$this->imaginaryPart * -1,
|
||||
($this->imaginaryPart == 0.0) ? null : $this->suffix
|
||||
);
|
||||
}
|
||||
|
||||
public function invertReal()
|
||||
{
|
||||
return new Complex(
|
||||
$this->realPart * -1,
|
||||
$this->imaginaryPart,
|
||||
($this->imaginaryPart == 0.0) ? null : $this->suffix
|
||||
);
|
||||
}
|
||||
|
||||
protected static $functions = [
|
||||
'abs',
|
||||
'acos',
|
||||
'acosh',
|
||||
'acot',
|
||||
'acoth',
|
||||
'acsc',
|
||||
'acsch',
|
||||
'argument',
|
||||
'asec',
|
||||
'asech',
|
||||
'asin',
|
||||
'asinh',
|
||||
'atan',
|
||||
'atanh',
|
||||
'conjugate',
|
||||
'cos',
|
||||
'cosh',
|
||||
'cot',
|
||||
'coth',
|
||||
'csc',
|
||||
'csch',
|
||||
'exp',
|
||||
'inverse',
|
||||
'ln',
|
||||
'log2',
|
||||
'log10',
|
||||
'negative',
|
||||
'pow',
|
||||
'rho',
|
||||
'sec',
|
||||
'sech',
|
||||
'sin',
|
||||
'sinh',
|
||||
'sqrt',
|
||||
'tan',
|
||||
'tanh',
|
||||
'theta',
|
||||
];
|
||||
|
||||
protected static $operations = [
|
||||
'add',
|
||||
'subtract',
|
||||
'multiply',
|
||||
'divideby',
|
||||
'divideinto',
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns the result of the function call or operation
|
||||
*
|
||||
* @return Complex|float
|
||||
* @throws Exception|\InvalidArgumentException
|
||||
*/
|
||||
public function __call($functionName, $arguments)
|
||||
{
|
||||
$functionName = strtolower(str_replace('_', '', $functionName));
|
||||
|
||||
// Test for function calls
|
||||
if (in_array($functionName, self::$functions)) {
|
||||
$functionName = "\\" . __NAMESPACE__ . "\\{$functionName}";
|
||||
return $functionName($this, ...$arguments);
|
||||
}
|
||||
// Test for operation calls
|
||||
if (in_array($functionName, self::$operations)) {
|
||||
$functionName = "\\" . __NAMESPACE__ . "\\{$functionName}";
|
||||
return $functionName($this, ...$arguments);
|
||||
}
|
||||
throw new Exception('Function or Operation does not exist');
|
||||
}
|
||||
}
|
||||
13
vendor/markbaker/complex/classes/src/Exception.php
vendored
Normal file
13
vendor/markbaker/complex/classes/src/Exception.php
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Exception.
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
class Exception extends \Exception
|
||||
{
|
||||
}
|
||||
29
vendor/markbaker/complex/classes/src/functions/abs.php
vendored
Normal file
29
vendor/markbaker/complex/classes/src/functions/abs.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex abs() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the absolute value (modulus) of a complex number.
|
||||
* Also known as the rho of the complex number, i.e. the distance/radius
|
||||
* from the centrepoint to the representation of the number in polar coordinates.
|
||||
*
|
||||
* This function is a synonym for rho()
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return float The absolute (or rho) value of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
*
|
||||
* @see rho
|
||||
*
|
||||
*/
|
||||
function abs($complex)
|
||||
{
|
||||
return rho($complex);
|
||||
}
|
||||
38
vendor/markbaker/complex/classes/src/functions/acos.php
vendored
Normal file
38
vendor/markbaker/complex/classes/src/functions/acos.php
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex acos() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the inverse cosine of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The inverse cosine of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
*/
|
||||
function acos($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
$square = clone $complex;
|
||||
$square = multiply($square, $complex);
|
||||
$invsqrt = new Complex(1.0);
|
||||
$invsqrt = subtract($invsqrt, $square);
|
||||
$invsqrt = sqrt($invsqrt);
|
||||
$adjust = new Complex(
|
||||
$complex->getReal() - $invsqrt->getImaginary(),
|
||||
$complex->getImaginary() + $invsqrt->getReal()
|
||||
);
|
||||
$log = ln($adjust);
|
||||
|
||||
return new Complex(
|
||||
$log->getImaginary(),
|
||||
-1 * $log->getReal()
|
||||
);
|
||||
}
|
||||
34
vendor/markbaker/complex/classes/src/functions/acosh.php
vendored
Normal file
34
vendor/markbaker/complex/classes/src/functions/acosh.php
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex acosh() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the inverse hyperbolic cosine of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The inverse hyperbolic cosine of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
*/
|
||||
function acosh($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($complex->isReal() && ($complex->getReal() > 1)) {
|
||||
return new Complex(\acosh($complex->getReal()));
|
||||
}
|
||||
|
||||
$acosh = acos($complex)
|
||||
->reverse();
|
||||
if ($acosh->getReal() < 0.0) {
|
||||
$acosh = $acosh->invertReal();
|
||||
}
|
||||
|
||||
return $acosh;
|
||||
}
|
||||
25
vendor/markbaker/complex/classes/src/functions/acot.php
vendored
Normal file
25
vendor/markbaker/complex/classes/src/functions/acot.php
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex acot() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the inverse cotangent of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The inverse cotangent of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
* @throws \InvalidArgumentException If function would result in a division by zero
|
||||
*/
|
||||
function acot($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
return atan(inverse($complex));
|
||||
}
|
||||
25
vendor/markbaker/complex/classes/src/functions/acoth.php
vendored
Normal file
25
vendor/markbaker/complex/classes/src/functions/acoth.php
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex acoth() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the inverse hyperbolic cotangent of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The inverse hyperbolic cotangent of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
* @throws \InvalidArgumentException If function would result in a division by zero
|
||||
*/
|
||||
function acoth($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
return atanh(inverse($complex));
|
||||
}
|
||||
29
vendor/markbaker/complex/classes/src/functions/acsc.php
vendored
Normal file
29
vendor/markbaker/complex/classes/src/functions/acsc.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex acsc() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the inverse cosecant of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The inverse cosecant of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
* @throws \InvalidArgumentException If function would result in a division by zero
|
||||
*/
|
||||
function acsc($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($complex->getReal() == 0.0 && $complex->getImaginary() == 0.0) {
|
||||
return INF;
|
||||
}
|
||||
|
||||
return asin(inverse($complex));
|
||||
}
|
||||
29
vendor/markbaker/complex/classes/src/functions/acsch.php
vendored
Normal file
29
vendor/markbaker/complex/classes/src/functions/acsch.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex acsch() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the inverse hyperbolic cosecant of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The inverse hyperbolic cosecant of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
* @throws \InvalidArgumentException If function would result in a division by zero
|
||||
*/
|
||||
function acsch($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($complex->getReal() == 0.0 && $complex->getImaginary() == 0.0) {
|
||||
return INF;
|
||||
}
|
||||
|
||||
return asinh(inverse($complex));
|
||||
}
|
||||
28
vendor/markbaker/complex/classes/src/functions/argument.php
vendored
Normal file
28
vendor/markbaker/complex/classes/src/functions/argument.php
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex argument() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the argument of a complex number.
|
||||
* Also known as the theta of the complex number, i.e. the angle in radians
|
||||
* from the real axis to the representation of the number in polar coordinates.
|
||||
*
|
||||
* This function is a synonym for theta()
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return float The argument (or theta) value of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
*
|
||||
* @see theta
|
||||
*/
|
||||
function argument($complex)
|
||||
{
|
||||
return theta($complex);
|
||||
}
|
||||
29
vendor/markbaker/complex/classes/src/functions/asec.php
vendored
Normal file
29
vendor/markbaker/complex/classes/src/functions/asec.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex asec() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the inverse secant of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The inverse secant of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
* @throws \InvalidArgumentException If function would result in a division by zero
|
||||
*/
|
||||
function asec($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($complex->getReal() == 0.0 && $complex->getImaginary() == 0.0) {
|
||||
return INF;
|
||||
}
|
||||
|
||||
return acos(inverse($complex));
|
||||
}
|
||||
29
vendor/markbaker/complex/classes/src/functions/asech.php
vendored
Normal file
29
vendor/markbaker/complex/classes/src/functions/asech.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex asech() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the inverse hyperbolic secant of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The inverse hyperbolic secant of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
* @throws \InvalidArgumentException If function would result in a division by zero
|
||||
*/
|
||||
function asech($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($complex->getReal() == 0.0 && $complex->getImaginary() == 0.0) {
|
||||
return INF;
|
||||
}
|
||||
|
||||
return acosh(inverse($complex));
|
||||
}
|
||||
37
vendor/markbaker/complex/classes/src/functions/asin.php
vendored
Normal file
37
vendor/markbaker/complex/classes/src/functions/asin.php
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex asin() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the inverse sine of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The inverse sine of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
*/
|
||||
function asin($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
$square = multiply($complex, $complex);
|
||||
$invsqrt = new Complex(1.0);
|
||||
$invsqrt = subtract($invsqrt, $square);
|
||||
$invsqrt = sqrt($invsqrt);
|
||||
$adjust = new Complex(
|
||||
$invsqrt->getReal() - $complex->getImaginary(),
|
||||
$invsqrt->getImaginary() + $complex->getReal()
|
||||
);
|
||||
$log = ln($adjust);
|
||||
|
||||
return new Complex(
|
||||
$log->getImaginary(),
|
||||
-1 * $log->getReal()
|
||||
);
|
||||
}
|
||||
33
vendor/markbaker/complex/classes/src/functions/asinh.php
vendored
Normal file
33
vendor/markbaker/complex/classes/src/functions/asinh.php
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex asinh() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the inverse hyperbolic sine of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The inverse hyperbolic sine of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
*/
|
||||
function asinh($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($complex->isReal() && ($complex->getReal() > 1)) {
|
||||
return new Complex(\asinh($complex->getReal()));
|
||||
}
|
||||
|
||||
$asinh = clone $complex;
|
||||
$asinh = $asinh->reverse()
|
||||
->invertReal();
|
||||
$asinh = asin($asinh);
|
||||
return $asinh->reverse()
|
||||
->invertImaginary();
|
||||
}
|
||||
45
vendor/markbaker/complex/classes/src/functions/atan.php
vendored
Normal file
45
vendor/markbaker/complex/classes/src/functions/atan.php
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex atan() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
//include_once 'Math/Complex.php';
|
||||
//include_once 'Math/ComplexOp.php';
|
||||
|
||||
/**
|
||||
* Returns the inverse tangent of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The inverse tangent of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
* @throws \InvalidArgumentException If function would result in a division by zero
|
||||
*/
|
||||
function atan($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($complex->isReal()) {
|
||||
return new Complex(\atan($complex->getReal()));
|
||||
}
|
||||
|
||||
$t1Value = new Complex(-1 * $complex->getImaginary(), $complex->getReal());
|
||||
$uValue = new Complex(1, 0);
|
||||
|
||||
$d1Value = clone $uValue;
|
||||
$d1Value = subtract($d1Value, $t1Value);
|
||||
$d2Value = add($t1Value, $uValue);
|
||||
$uResult = $d1Value->divideBy($d2Value);
|
||||
$uResult = ln($uResult);
|
||||
|
||||
return new Complex(
|
||||
(($uResult->getImaginary() == M_PI) ? -M_PI : $uResult->getImaginary()) * -0.5,
|
||||
$uResult->getReal() * 0.5,
|
||||
$complex->getSuffix()
|
||||
);
|
||||
}
|
||||
38
vendor/markbaker/complex/classes/src/functions/atanh.php
vendored
Normal file
38
vendor/markbaker/complex/classes/src/functions/atanh.php
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex atanh() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the inverse hyperbolic tangent of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The inverse hyperbolic tangent of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
*/
|
||||
function atanh($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($complex->isReal()) {
|
||||
$real = $complex->getReal();
|
||||
if ($real >= -1.0 && $real <= 1.0) {
|
||||
return new Complex(\atanh($real));
|
||||
} else {
|
||||
return new Complex(\atanh(1 / $real), (($real < 0.0) ? M_PI_2 : -1 * M_PI_2));
|
||||
}
|
||||
}
|
||||
|
||||
$iComplex = clone $complex;
|
||||
$iComplex = $iComplex->invertImaginary()
|
||||
->reverse();
|
||||
return atan($iComplex)
|
||||
->invertReal()
|
||||
->reverse();
|
||||
}
|
||||
28
vendor/markbaker/complex/classes/src/functions/conjugate.php
vendored
Normal file
28
vendor/markbaker/complex/classes/src/functions/conjugate.php
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex conjugate() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the complex conjugate of a complex number
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The conjugate of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
*/
|
||||
function conjugate($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
return new Complex(
|
||||
$complex->getReal(),
|
||||
-1 * $complex->getImaginary(),
|
||||
$complex->getSuffix()
|
||||
);
|
||||
}
|
||||
34
vendor/markbaker/complex/classes/src/functions/cos.php
vendored
Normal file
34
vendor/markbaker/complex/classes/src/functions/cos.php
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex cos() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the cosine of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The cosine of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
*/
|
||||
function cos($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($complex->isReal()) {
|
||||
return new Complex(\cos($complex->getReal()));
|
||||
}
|
||||
|
||||
return conjugate(
|
||||
new Complex(
|
||||
\cos($complex->getReal()) * \cosh($complex->getImaginary()),
|
||||
\sin($complex->getReal()) * \sinh($complex->getImaginary()),
|
||||
$complex->getSuffix()
|
||||
)
|
||||
);
|
||||
}
|
||||
32
vendor/markbaker/complex/classes/src/functions/cosh.php
vendored
Normal file
32
vendor/markbaker/complex/classes/src/functions/cosh.php
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex cosh() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the hyperbolic cosine of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The hyperbolic cosine of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
*/
|
||||
function cosh($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($complex->isReal()) {
|
||||
return new Complex(\cosh($complex->getReal()));
|
||||
}
|
||||
|
||||
return new Complex(
|
||||
\cosh($complex->getReal()) * \cos($complex->getImaginary()),
|
||||
\sinh($complex->getReal()) * \sin($complex->getImaginary()),
|
||||
$complex->getSuffix()
|
||||
);
|
||||
}
|
||||
29
vendor/markbaker/complex/classes/src/functions/cot.php
vendored
Normal file
29
vendor/markbaker/complex/classes/src/functions/cot.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex cot() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the cotangent of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The cotangent of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
* @throws \InvalidArgumentException If function would result in a division by zero
|
||||
*/
|
||||
function cot($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($complex->getReal() == 0.0 && $complex->getImaginary() == 0.0) {
|
||||
return new Complex(INF);
|
||||
}
|
||||
|
||||
return inverse(tan($complex));
|
||||
}
|
||||
24
vendor/markbaker/complex/classes/src/functions/coth.php
vendored
Normal file
24
vendor/markbaker/complex/classes/src/functions/coth.php
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex coth() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the hyperbolic cotangent of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The hyperbolic cotangent of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
* @throws \InvalidArgumentException If function would result in a division by zero
|
||||
*/
|
||||
function coth($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
return inverse(tanh($complex));
|
||||
}
|
||||
29
vendor/markbaker/complex/classes/src/functions/csc.php
vendored
Normal file
29
vendor/markbaker/complex/classes/src/functions/csc.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex csc() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the cosecant of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The cosecant of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
* @throws \InvalidArgumentException If function would result in a division by zero
|
||||
*/
|
||||
function csc($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($complex->getReal() == 0.0 && $complex->getImaginary() == 0.0) {
|
||||
return INF;
|
||||
}
|
||||
|
||||
return inverse(sin($complex));
|
||||
}
|
||||
29
vendor/markbaker/complex/classes/src/functions/csch.php
vendored
Normal file
29
vendor/markbaker/complex/classes/src/functions/csch.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex csch() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the hyperbolic cosecant of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The hyperbolic cosecant of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
* @throws \InvalidArgumentException If function would result in a division by zero
|
||||
*/
|
||||
function csch($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($complex->getReal() == 0.0 && $complex->getImaginary() == 0.0) {
|
||||
return INF;
|
||||
}
|
||||
|
||||
return inverse(sinh($complex));
|
||||
}
|
||||
34
vendor/markbaker/complex/classes/src/functions/exp.php
vendored
Normal file
34
vendor/markbaker/complex/classes/src/functions/exp.php
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex exp() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the exponential of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The exponential of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
*/
|
||||
function exp($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if (($complex->getReal() == 0.0) && (\abs($complex->getImaginary()) == M_PI)) {
|
||||
return new Complex(-1.0, 0.0);
|
||||
}
|
||||
|
||||
$rho = \exp($complex->getReal());
|
||||
|
||||
return new Complex(
|
||||
$rho * \cos($complex->getImaginary()),
|
||||
$rho * \sin($complex->getImaginary()),
|
||||
$complex->getSuffix()
|
||||
);
|
||||
}
|
||||
29
vendor/markbaker/complex/classes/src/functions/inverse.php
vendored
Normal file
29
vendor/markbaker/complex/classes/src/functions/inverse.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex inverse() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the inverse of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The inverse of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
* @throws \InvalidArgumentException If function would result in a division by zero
|
||||
*/
|
||||
function inverse($complex)
|
||||
{
|
||||
$complex = clone Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($complex->getReal() == 0.0 && $complex->getImaginary() == 0.0) {
|
||||
throw new \InvalidArgumentException('Division by zero');
|
||||
}
|
||||
|
||||
return $complex->divideInto(1.0);
|
||||
}
|
||||
33
vendor/markbaker/complex/classes/src/functions/ln.php
vendored
Normal file
33
vendor/markbaker/complex/classes/src/functions/ln.php
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex ln() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the natural logarithm of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The natural logarithm of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
* @throws \InvalidArgumentException If the real and the imaginary parts are both zero
|
||||
*/
|
||||
function ln($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if (($complex->getReal() == 0.0) && ($complex->getImaginary() == 0.0)) {
|
||||
throw new \InvalidArgumentException();
|
||||
}
|
||||
|
||||
return new Complex(
|
||||
\log(rho($complex)),
|
||||
theta($complex),
|
||||
$complex->getSuffix()
|
||||
);
|
||||
}
|
||||
32
vendor/markbaker/complex/classes/src/functions/log10.php
vendored
Normal file
32
vendor/markbaker/complex/classes/src/functions/log10.php
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex log10() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the common logarithm (base 10) of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The common logarithm (base 10) of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
* @throws \InvalidArgumentException If the real and the imaginary parts are both zero
|
||||
*/
|
||||
function log10($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if (($complex->getReal() == 0.0) && ($complex->getImaginary() == 0.0)) {
|
||||
throw new \InvalidArgumentException();
|
||||
} elseif (($complex->getReal() > 0.0) && ($complex->getImaginary() == 0.0)) {
|
||||
return new Complex(\log10($complex->getReal()), 0.0, $complex->getSuffix());
|
||||
}
|
||||
|
||||
return ln($complex)
|
||||
->multiply(\log10(Complex::EULER));
|
||||
}
|
||||
32
vendor/markbaker/complex/classes/src/functions/log2.php
vendored
Normal file
32
vendor/markbaker/complex/classes/src/functions/log2.php
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex log2() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the base-2 logarithm of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The base-2 logarithm of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
* @throws \InvalidArgumentException If the real and the imaginary parts are both zero
|
||||
*/
|
||||
function log2($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if (($complex->getReal() == 0.0) && ($complex->getImaginary() == 0.0)) {
|
||||
throw new \InvalidArgumentException();
|
||||
} elseif (($complex->getReal() > 0.0) && ($complex->getImaginary() == 0.0)) {
|
||||
return new Complex(\log($complex->getReal(), 2), 0.0, $complex->getSuffix());
|
||||
}
|
||||
|
||||
return ln($complex)
|
||||
->multiply(\log(Complex::EULER, 2));
|
||||
}
|
||||
31
vendor/markbaker/complex/classes/src/functions/negative.php
vendored
Normal file
31
vendor/markbaker/complex/classes/src/functions/negative.php
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex negative() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the negative of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return float The negative value of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
*
|
||||
* @see rho
|
||||
*
|
||||
*/
|
||||
function negative($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
return new Complex(
|
||||
-1 * $complex->getReal(),
|
||||
-1 * $complex->getImaginary(),
|
||||
$complex->getSuffix()
|
||||
);
|
||||
}
|
||||
40
vendor/markbaker/complex/classes/src/functions/pow.php
vendored
Normal file
40
vendor/markbaker/complex/classes/src/functions/pow.php
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex pow() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns a complex number raised to a power.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @param float|integer $power The power to raise this value to
|
||||
* @return Complex The complex argument raised to the real power.
|
||||
* @throws Exception If the power argument isn't a valid real
|
||||
*/
|
||||
function pow($complex, $power)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if (!is_numeric($power)) {
|
||||
throw new Exception('Power argument must be a real number');
|
||||
}
|
||||
|
||||
if ($complex->getImaginary() == 0.0 && $complex->getReal() >= 0.0) {
|
||||
return new Complex(\pow($complex->getReal(), $power));
|
||||
}
|
||||
|
||||
$rValue = \sqrt(($complex->getReal() * $complex->getReal()) + ($complex->getImaginary() * $complex->getImaginary()));
|
||||
$rPower = \pow($rValue, $power);
|
||||
$theta = $complex->argument() * $power;
|
||||
if ($theta == 0) {
|
||||
return new Complex(1);
|
||||
}
|
||||
|
||||
return new Complex($rPower * \cos($theta), $rPower * \sin($theta), $complex->getSuffix());
|
||||
}
|
||||
28
vendor/markbaker/complex/classes/src/functions/rho.php
vendored
Normal file
28
vendor/markbaker/complex/classes/src/functions/rho.php
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex rho() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the rho of a complex number.
|
||||
* This is the distance/radius from the centrepoint to the representation of the number in polar coordinates.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return float The rho value of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
*/
|
||||
function rho($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
return \sqrt(
|
||||
($complex->getReal() * $complex->getReal()) +
|
||||
($complex->getImaginary() * $complex->getImaginary())
|
||||
);
|
||||
}
|
||||
25
vendor/markbaker/complex/classes/src/functions/sec.php
vendored
Normal file
25
vendor/markbaker/complex/classes/src/functions/sec.php
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex sec() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the secant of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The secant of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
* @throws \InvalidArgumentException If function would result in a division by zero
|
||||
*/
|
||||
function sec($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
return inverse(cos($complex));
|
||||
}
|
||||
25
vendor/markbaker/complex/classes/src/functions/sech.php
vendored
Normal file
25
vendor/markbaker/complex/classes/src/functions/sech.php
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex sech() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the hyperbolic secant of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The hyperbolic secant of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
* @throws \InvalidArgumentException If function would result in a division by zero
|
||||
*/
|
||||
function sech($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
return inverse(cosh($complex));
|
||||
}
|
||||
32
vendor/markbaker/complex/classes/src/functions/sin.php
vendored
Normal file
32
vendor/markbaker/complex/classes/src/functions/sin.php
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex sin() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the sine of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The sine of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
*/
|
||||
function sin($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($complex->isReal()) {
|
||||
return new Complex(\sin($complex->getReal()));
|
||||
}
|
||||
|
||||
return new Complex(
|
||||
\sin($complex->getReal()) * \cosh($complex->getImaginary()),
|
||||
\cos($complex->getReal()) * \sinh($complex->getImaginary()),
|
||||
$complex->getSuffix()
|
||||
);
|
||||
}
|
||||
32
vendor/markbaker/complex/classes/src/functions/sinh.php
vendored
Normal file
32
vendor/markbaker/complex/classes/src/functions/sinh.php
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex sinh() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the hyperbolic sine of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The hyperbolic sine of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
*/
|
||||
function sinh($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($complex->isReal()) {
|
||||
return new Complex(\sinh($complex->getReal()));
|
||||
}
|
||||
|
||||
return new Complex(
|
||||
\sinh($complex->getReal()) * \cos($complex->getImaginary()),
|
||||
\cosh($complex->getReal()) * \sin($complex->getImaginary()),
|
||||
$complex->getSuffix()
|
||||
);
|
||||
}
|
||||
29
vendor/markbaker/complex/classes/src/functions/sqrt.php
vendored
Normal file
29
vendor/markbaker/complex/classes/src/functions/sqrt.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex sqrt() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the square root of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The Square root of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
*/
|
||||
function sqrt($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
$theta = theta($complex);
|
||||
$delta1 = \cos($theta / 2);
|
||||
$delta2 = \sin($theta / 2);
|
||||
$rho = \sqrt(rho($complex));
|
||||
|
||||
return new Complex($delta1 * $rho, $delta2 * $rho, $complex->getSuffix());
|
||||
}
|
||||
40
vendor/markbaker/complex/classes/src/functions/tan.php
vendored
Normal file
40
vendor/markbaker/complex/classes/src/functions/tan.php
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex tan() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the tangent of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The tangent of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
* @throws \InvalidArgumentException If function would result in a division by zero
|
||||
*/
|
||||
function tan($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($complex->isReal()) {
|
||||
return new Complex(\tan($complex->getReal()));
|
||||
}
|
||||
|
||||
$real = $complex->getReal();
|
||||
$imaginary = $complex->getImaginary();
|
||||
$divisor = 1 + \pow(\tan($real), 2) * \pow(\tanh($imaginary), 2);
|
||||
if ($divisor == 0.0) {
|
||||
throw new \InvalidArgumentException('Division by zero');
|
||||
}
|
||||
|
||||
return new Complex(
|
||||
\pow(sech($imaginary)->getReal(), 2) * \tan($real) / $divisor,
|
||||
\pow(sec($real)->getReal(), 2) * \tanh($imaginary) / $divisor,
|
||||
$complex->getSuffix()
|
||||
);
|
||||
}
|
||||
35
vendor/markbaker/complex/classes/src/functions/tanh.php
vendored
Normal file
35
vendor/markbaker/complex/classes/src/functions/tanh.php
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex tanh() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the hyperbolic tangent of a complex number.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return Complex The hyperbolic tangent of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
* @throws \InvalidArgumentException If function would result in a division by zero
|
||||
*/
|
||||
function tanh($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
$real = $complex->getReal();
|
||||
$imaginary = $complex->getImaginary();
|
||||
$divisor = \cos($imaginary) * \cos($imaginary) + \sinh($real) * \sinh($real);
|
||||
if ($divisor == 0.0) {
|
||||
throw new \InvalidArgumentException('Division by zero');
|
||||
}
|
||||
|
||||
return new Complex(
|
||||
\sinh($real) * \cosh($real) / $divisor,
|
||||
0.5 * \sin(2 * $imaginary) / $divisor,
|
||||
$complex->getSuffix()
|
||||
);
|
||||
}
|
||||
38
vendor/markbaker/complex/classes/src/functions/theta.php
vendored
Normal file
38
vendor/markbaker/complex/classes/src/functions/theta.php
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex theta() function
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Returns the theta of a complex number.
|
||||
* This is the angle in radians from the real axis to the representation of the number in polar coordinates.
|
||||
*
|
||||
* @param Complex|mixed $complex Complex number or a numeric value.
|
||||
* @return float The theta value of the complex argument.
|
||||
* @throws Exception If argument isn't a valid real or complex number.
|
||||
*/
|
||||
function theta($complex)
|
||||
{
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($complex->getReal() == 0.0) {
|
||||
if ($complex->isReal()) {
|
||||
return 0.0;
|
||||
} elseif ($complex->getImaginary() < 0.0) {
|
||||
return M_PI / -2;
|
||||
}
|
||||
return M_PI / 2;
|
||||
} elseif ($complex->getReal() > 0.0) {
|
||||
return \atan($complex->getImaginary() / $complex->getReal());
|
||||
} elseif ($complex->getImaginary() < 0.0) {
|
||||
return -(M_PI - \atan(\abs($complex->getImaginary()) / \abs($complex->getReal())));
|
||||
}
|
||||
|
||||
return M_PI - \atan($complex->getImaginary() / \abs($complex->getReal()));
|
||||
}
|
||||
46
vendor/markbaker/complex/classes/src/operations/add.php
vendored
Normal file
46
vendor/markbaker/complex/classes/src/operations/add.php
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex addition operation
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Adds two or more complex numbers
|
||||
*
|
||||
* @param array of string|integer|float|Complex $complexValues The numbers to add
|
||||
* @return Complex
|
||||
*/
|
||||
function add(...$complexValues)
|
||||
{
|
||||
if (count($complexValues) < 2) {
|
||||
throw new \Exception('This function requires at least 2 arguments');
|
||||
}
|
||||
|
||||
$base = array_shift($complexValues);
|
||||
$result = clone Complex::validateComplexArgument($base);
|
||||
|
||||
foreach ($complexValues as $complex) {
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($result->isComplex() && $complex->isComplex() &&
|
||||
$result->getSuffix() !== $complex->getSuffix()) {
|
||||
throw new Exception('Suffix Mismatch');
|
||||
}
|
||||
|
||||
$real = $result->getReal() + $complex->getReal();
|
||||
$imaginary = $result->getImaginary() + $complex->getImaginary();
|
||||
|
||||
$result = new Complex(
|
||||
$real,
|
||||
$imaginary,
|
||||
($imaginary == 0.0) ? null : max($result->getSuffix(), $complex->getSuffix())
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
56
vendor/markbaker/complex/classes/src/operations/divideby.php
vendored
Normal file
56
vendor/markbaker/complex/classes/src/operations/divideby.php
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex division operation
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Divides two or more complex numbers
|
||||
*
|
||||
* @param array of string|integer|float|Complex $complexValues The numbers to divide
|
||||
* @return Complex
|
||||
*/
|
||||
function divideby(...$complexValues)
|
||||
{
|
||||
if (count($complexValues) < 2) {
|
||||
throw new \Exception('This function requires at least 2 arguments');
|
||||
}
|
||||
|
||||
$base = array_shift($complexValues);
|
||||
$result = clone Complex::validateComplexArgument($base);
|
||||
|
||||
foreach ($complexValues as $complex) {
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($result->isComplex() && $complex->isComplex() &&
|
||||
$result->getSuffix() !== $complex->getSuffix()) {
|
||||
throw new Exception('Suffix Mismatch');
|
||||
}
|
||||
if ($complex->getReal() == 0.0 && $complex->getImaginary() == 0.0) {
|
||||
throw new \InvalidArgumentException('Division by zero');
|
||||
}
|
||||
|
||||
$delta1 = ($result->getReal() * $complex->getReal()) +
|
||||
($result->getImaginary() * $complex->getImaginary());
|
||||
$delta2 = ($result->getImaginary() * $complex->getReal()) -
|
||||
($result->getReal() * $complex->getImaginary());
|
||||
$delta3 = ($complex->getReal() * $complex->getReal()) +
|
||||
($complex->getImaginary() * $complex->getImaginary());
|
||||
|
||||
$real = $delta1 / $delta3;
|
||||
$imaginary = $delta2 / $delta3;
|
||||
|
||||
$result = new Complex(
|
||||
$real,
|
||||
$imaginary,
|
||||
($imaginary == 0.0) ? null : max($result->getSuffix(), $complex->getSuffix())
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
56
vendor/markbaker/complex/classes/src/operations/divideinto.php
vendored
Normal file
56
vendor/markbaker/complex/classes/src/operations/divideinto.php
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex division operation
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Divides two or more complex numbers
|
||||
*
|
||||
* @param array of string|integer|float|Complex $complexValues The numbers to divide
|
||||
* @return Complex
|
||||
*/
|
||||
function divideinto(...$complexValues)
|
||||
{
|
||||
if (count($complexValues) < 2) {
|
||||
throw new \Exception('This function requires at least 2 arguments');
|
||||
}
|
||||
|
||||
$base = array_shift($complexValues);
|
||||
$result = clone Complex::validateComplexArgument($base);
|
||||
|
||||
foreach ($complexValues as $complex) {
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($result->isComplex() && $complex->isComplex() &&
|
||||
$result->getSuffix() !== $complex->getSuffix()) {
|
||||
throw new Exception('Suffix Mismatch');
|
||||
}
|
||||
if ($result->getReal() == 0.0 && $result->getImaginary() == 0.0) {
|
||||
throw new \InvalidArgumentException('Division by zero');
|
||||
}
|
||||
|
||||
$delta1 = ($complex->getReal() * $result->getReal()) +
|
||||
($complex->getImaginary() * $result->getImaginary());
|
||||
$delta2 = ($complex->getImaginary() * $result->getReal()) -
|
||||
($complex->getReal() * $result->getImaginary());
|
||||
$delta3 = ($result->getReal() * $result->getReal()) +
|
||||
($result->getImaginary() * $result->getImaginary());
|
||||
|
||||
$real = $delta1 / $delta3;
|
||||
$imaginary = $delta2 / $delta3;
|
||||
|
||||
$result = new Complex(
|
||||
$real,
|
||||
$imaginary,
|
||||
($imaginary == 0.0) ? null : max($result->getSuffix(), $complex->getSuffix())
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
48
vendor/markbaker/complex/classes/src/operations/multiply.php
vendored
Normal file
48
vendor/markbaker/complex/classes/src/operations/multiply.php
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex multiplication operation
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Multiplies two or more complex numbers
|
||||
*
|
||||
* @param array of string|integer|float|Complex $complexValues The numbers to multiply
|
||||
* @return Complex
|
||||
*/
|
||||
function multiply(...$complexValues)
|
||||
{
|
||||
if (count($complexValues) < 2) {
|
||||
throw new \Exception('This function requires at least 2 arguments');
|
||||
}
|
||||
|
||||
$base = array_shift($complexValues);
|
||||
$result = clone Complex::validateComplexArgument($base);
|
||||
|
||||
foreach ($complexValues as $complex) {
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($result->isComplex() && $complex->isComplex() &&
|
||||
$result->getSuffix() !== $complex->getSuffix()) {
|
||||
throw new Exception('Suffix Mismatch');
|
||||
}
|
||||
|
||||
$real = ($result->getReal() * $complex->getReal()) -
|
||||
($result->getImaginary() * $complex->getImaginary());
|
||||
$imaginary = ($result->getReal() * $complex->getImaginary()) +
|
||||
($result->getImaginary() * $complex->getReal());
|
||||
|
||||
$result = new Complex(
|
||||
$real,
|
||||
$imaginary,
|
||||
($imaginary == 0.0) ? null : max($result->getSuffix(), $complex->getSuffix())
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
46
vendor/markbaker/complex/classes/src/operations/subtract.php
vendored
Normal file
46
vendor/markbaker/complex/classes/src/operations/subtract.php
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the complex subtraction operation
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Complex;
|
||||
|
||||
/**
|
||||
* Subtracts two or more complex numbers
|
||||
*
|
||||
* @param array of string|integer|float|Complex $complexValues The numbers to subtract
|
||||
* @return Complex
|
||||
*/
|
||||
function subtract(...$complexValues)
|
||||
{
|
||||
if (count($complexValues) < 2) {
|
||||
throw new \Exception('This function requires at least 2 arguments');
|
||||
}
|
||||
|
||||
$base = array_shift($complexValues);
|
||||
$result = clone Complex::validateComplexArgument($base);
|
||||
|
||||
foreach ($complexValues as $complex) {
|
||||
$complex = Complex::validateComplexArgument($complex);
|
||||
|
||||
if ($result->isComplex() && $complex->isComplex() &&
|
||||
$result->getSuffix() !== $complex->getSuffix()) {
|
||||
throw new Exception('Suffix Mismatch');
|
||||
}
|
||||
|
||||
$real = $result->getReal() - $complex->getReal();
|
||||
$imaginary = $result->getImaginary() - $complex->getImaginary();
|
||||
|
||||
$result = new Complex(
|
||||
$real,
|
||||
$imaginary,
|
||||
($imaginary == 0.0) ? null : max($result->getSuffix(), $complex->getSuffix())
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
91
vendor/markbaker/complex/composer.json
vendored
Normal file
91
vendor/markbaker/complex/composer.json
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
{
|
||||
"name": "markbaker/complex",
|
||||
"type": "library",
|
||||
"description": "PHP Class for working with complex numbers",
|
||||
"keywords": ["complex", "mathematics"],
|
||||
"homepage": "https://github.com/MarkBaker/PHPComplex",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Mark Baker",
|
||||
"email": "mark@lange.demon.co.uk"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^5.6.0|^7.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.35|^5.4.0",
|
||||
"phpdocumentor/phpdocumentor":"2.*",
|
||||
"phpmd/phpmd": "2.*",
|
||||
"sebastian/phpcpd": "2.*",
|
||||
"phploc/phploc": "2.*",
|
||||
"squizlabs/php_codesniffer": "^3.3.0",
|
||||
"phpcompatibility/php-compatibility": "^8.0",
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Complex\\": "classes/src/"
|
||||
},
|
||||
"files": [
|
||||
"classes/src/functions/abs.php",
|
||||
"classes/src/functions/acos.php",
|
||||
"classes/src/functions/acosh.php",
|
||||
"classes/src/functions/acot.php",
|
||||
"classes/src/functions/acoth.php",
|
||||
"classes/src/functions/acsc.php",
|
||||
"classes/src/functions/acsch.php",
|
||||
"classes/src/functions/argument.php",
|
||||
"classes/src/functions/asec.php",
|
||||
"classes/src/functions/asech.php",
|
||||
"classes/src/functions/asin.php",
|
||||
"classes/src/functions/asinh.php",
|
||||
"classes/src/functions/atan.php",
|
||||
"classes/src/functions/atanh.php",
|
||||
"classes/src/functions/conjugate.php",
|
||||
"classes/src/functions/cos.php",
|
||||
"classes/src/functions/cosh.php",
|
||||
"classes/src/functions/cot.php",
|
||||
"classes/src/functions/coth.php",
|
||||
"classes/src/functions/csc.php",
|
||||
"classes/src/functions/csch.php",
|
||||
"classes/src/functions/exp.php",
|
||||
"classes/src/functions/inverse.php",
|
||||
"classes/src/functions/ln.php",
|
||||
"classes/src/functions/log2.php",
|
||||
"classes/src/functions/log10.php",
|
||||
"classes/src/functions/negative.php",
|
||||
"classes/src/functions/pow.php",
|
||||
"classes/src/functions/rho.php",
|
||||
"classes/src/functions/sec.php",
|
||||
"classes/src/functions/sech.php",
|
||||
"classes/src/functions/sin.php",
|
||||
"classes/src/functions/sinh.php",
|
||||
"classes/src/functions/sqrt.php",
|
||||
"classes/src/functions/tan.php",
|
||||
"classes/src/functions/tanh.php",
|
||||
"classes/src/functions/theta.php",
|
||||
"classes/src/operations/add.php",
|
||||
"classes/src/operations/subtract.php",
|
||||
"classes/src/operations/multiply.php",
|
||||
"classes/src/operations/divideby.php",
|
||||
"classes/src/operations/divideinto.php"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"style": [
|
||||
"phpcs --report-width=200 --report-summary --report-full classes/src/ --standard=PSR2 -n"
|
||||
],
|
||||
"mess": [
|
||||
"phpmd classes/src/ xml codesize,unusedcode,design,naming -n"
|
||||
],
|
||||
"lines": [
|
||||
"phploc classes/src/ -n"
|
||||
],
|
||||
"cpd": [
|
||||
"phpcpd classes/src/ -n"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
154
vendor/markbaker/complex/examples/complexTest.php
vendored
Normal file
154
vendor/markbaker/complex/examples/complexTest.php
vendored
Normal file
@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
use Complex\Complex as Complex;
|
||||
|
||||
include('../classes/Bootstrap.php');
|
||||
|
||||
echo 'Create', PHP_EOL;
|
||||
|
||||
$x = new Complex(123);
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(123, 456);
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(array(123,456,'j'));
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex('1.23e-4--2.34e-5i');
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
|
||||
echo PHP_EOL, 'Add', PHP_EOL;
|
||||
|
||||
$x = new Complex(123);
|
||||
$x->add(456);
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(123.456);
|
||||
$x->add(789.012);
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(123.456, 78.90);
|
||||
$x->add(new Complex(-987.654, -32.1));
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(123.456, 78.90);
|
||||
$x->add(-987.654);
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(-987.654, -32.1);
|
||||
$x->add(new Complex(0, 1));
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(-987.654, -32.1);
|
||||
$x->add(new Complex(0, -1));
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
|
||||
echo PHP_EOL, 'Subtract', PHP_EOL;
|
||||
|
||||
$x = new Complex(123);
|
||||
$x->subtract(456);
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(123.456);
|
||||
$x->subtract(789.012);
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(123.456, 78.90);
|
||||
$x->subtract(new Complex(-987.654, -32.1));
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(123.456, 78.90);
|
||||
$x->subtract(-987.654);
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(-987.654, -32.1);
|
||||
$x->subtract(new Complex(0, 1));
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(-987.654, -32.1);
|
||||
$x->subtract(new Complex(0, -1));
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
|
||||
echo PHP_EOL, 'Multiply', PHP_EOL;
|
||||
|
||||
$x = new Complex(123);
|
||||
$x->multiply(456);
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(123.456);
|
||||
$x->multiply(789.012);
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(123.456, 78.90);
|
||||
$x->multiply(new Complex(-987.654, -32.1));
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(123.456, 78.90);
|
||||
$x->multiply(-987.654);
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(-987.654, -32.1);
|
||||
$x->multiply(new Complex(0, 1));
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(-987.654, -32.1);
|
||||
$x->multiply(new Complex(0, -1));
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
|
||||
echo PHP_EOL, 'Divide By', PHP_EOL;
|
||||
|
||||
$x = new Complex(123);
|
||||
$x->divideBy(456);
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(123.456);
|
||||
$x->divideBy(789.012);
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(123.456, 78.90);
|
||||
$x->divideBy(new Complex(-987.654, -32.1));
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(123.456, 78.90);
|
||||
$x->divideBy(-987.654);
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(-987.654, -32.1);
|
||||
$x->divideBy(new Complex(0, 1));
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(-987.654, -32.1);
|
||||
$x->divideBy(new Complex(0, -1));
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
|
||||
echo PHP_EOL, 'Divide Into', PHP_EOL;
|
||||
|
||||
$x = new Complex(123);
|
||||
$x->divideInto(456);
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(123.456);
|
||||
$x->divideInto(789.012);
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(123.456, 78.90);
|
||||
$x->divideInto(new Complex(-987.654, -32.1));
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(123.456, 78.90);
|
||||
$x->divideInto(-987.654);
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(-987.654, -32.1);
|
||||
$x->divideInto(new Complex(0, 1));
|
||||
echo $x, PHP_EOL;
|
||||
|
||||
$x = new Complex(-987.654, -32.1);
|
||||
$x->divideInto(new Complex(0, -1));
|
||||
echo $x, PHP_EOL;
|
||||
52
vendor/markbaker/complex/examples/testFunctions.php
vendored
Normal file
52
vendor/markbaker/complex/examples/testFunctions.php
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Complex;
|
||||
|
||||
include('../classes/Bootstrap.php');
|
||||
|
||||
echo 'Function Examples', PHP_EOL;
|
||||
|
||||
$functions = array(
|
||||
'abs',
|
||||
'acos',
|
||||
'acosh',
|
||||
'acsc',
|
||||
'acsch',
|
||||
'argument',
|
||||
'asec',
|
||||
'asech',
|
||||
'asin',
|
||||
'asinh',
|
||||
'conjugate',
|
||||
'cos',
|
||||
'cosh',
|
||||
'csc',
|
||||
'csch',
|
||||
'exp',
|
||||
'inverse',
|
||||
'ln',
|
||||
'log2',
|
||||
'log10',
|
||||
'rho',
|
||||
'sec',
|
||||
'sech',
|
||||
'sin',
|
||||
'sinh',
|
||||
'sqrt',
|
||||
'theta'
|
||||
);
|
||||
|
||||
for ($real = -3.5; $real <= 3.5; $real += 0.5) {
|
||||
for ($imaginary = -3.5; $imaginary <= 3.5; $imaginary += 0.5) {
|
||||
foreach ($functions as $function) {
|
||||
$complexFunction = __NAMESPACE__ . '\\' . $function;
|
||||
$complex = new Complex($real, $imaginary);
|
||||
try {
|
||||
echo $function, '(', $complex, ') = ', $complexFunction($complex), PHP_EOL;
|
||||
} catch (\Exception $e) {
|
||||
echo $function, '(', $complex, ') ERROR: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
}
|
||||
echo PHP_EOL;
|
||||
}
|
||||
}
|
||||
34
vendor/markbaker/complex/examples/testOperations.php
vendored
Normal file
34
vendor/markbaker/complex/examples/testOperations.php
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Complex\Complex as Complex;
|
||||
|
||||
include('../classes/Bootstrap.php');
|
||||
|
||||
$values = [
|
||||
new Complex(123),
|
||||
new Complex(456, 123),
|
||||
new Complex(0.0, 456),
|
||||
];
|
||||
|
||||
foreach ($values as $value) {
|
||||
echo $value, PHP_EOL;
|
||||
}
|
||||
|
||||
echo 'Addition', PHP_EOL;
|
||||
|
||||
$result = \Complex\add(...$values);
|
||||
echo '=> ', $result, PHP_EOL;
|
||||
|
||||
echo PHP_EOL;
|
||||
|
||||
echo 'Subtraction', PHP_EOL;
|
||||
|
||||
$result = \Complex\subtract(...$values);
|
||||
echo '=> ', $result, PHP_EOL;
|
||||
|
||||
echo PHP_EOL;
|
||||
|
||||
echo 'Multiplication', PHP_EOL;
|
||||
|
||||
$result = \Complex\multiply(...$values);
|
||||
echo '=> ', $result, PHP_EOL;
|
||||
25
vendor/markbaker/complex/license.md
vendored
Normal file
25
vendor/markbaker/complex/license.md
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
The MIT License (MIT)
|
||||
=====================
|
||||
|
||||
Copyright © `2017` `Mark Baker`
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the “Software”), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
165
vendor/markbaker/matrix/README.md
vendored
Normal file
165
vendor/markbaker/matrix/README.md
vendored
Normal file
@ -0,0 +1,165 @@
|
||||
PHPMatrix
|
||||
==========
|
||||
|
||||
---
|
||||
|
||||
PHP Class for handling Matrices
|
||||
|
||||
Master: [](http://travis-ci.org/MarkBaker/PHPMatrix)
|
||||
|
||||
Develop: [](http://travis-ci.org/MarkBaker/PHPMatrix)
|
||||
|
||||
[](https://xkcd.com/184/)
|
||||
|
||||
Matrix Transform
|
||||
|
||||
---
|
||||
|
||||
This library currently provides the following operations:
|
||||
|
||||
- addition
|
||||
- direct sum
|
||||
- subtraction
|
||||
- multiplication
|
||||
- division (using [A].[B]<sup>-1</sup>)
|
||||
- division by
|
||||
- division into
|
||||
|
||||
together with functions for
|
||||
|
||||
- adjoint
|
||||
- antidiagonal
|
||||
- cofactors
|
||||
- determinant
|
||||
- diagonal
|
||||
- identity
|
||||
- inverse
|
||||
- minors
|
||||
- trace
|
||||
- transpose
|
||||
|
||||
|
||||
## TO DO
|
||||
|
||||
- power()
|
||||
- EigenValues
|
||||
- EigenVectors
|
||||
- Decomposition
|
||||
|
||||
---
|
||||
|
||||
# Usage
|
||||
|
||||
To create a new Matrix object, provide an array as the constructor argument
|
||||
|
||||
```
|
||||
$grid = [
|
||||
[16, 3, 2, 13],
|
||||
[ 5, 10, 11, 8],
|
||||
[ 9, 6, 7, 12],
|
||||
[ 4, 15, 14, 1],
|
||||
];
|
||||
|
||||
$matrix = new Matrix\Matrix($grid);
|
||||
```
|
||||
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.
|
||||
```
|
||||
$matrix = new Matrix\Builder::createFilledMatrix(1, 5, 3);
|
||||
```
|
||||
Will create a matrix of 5 rows and 3 columns, filled with a `1` in every cell; while
|
||||
```
|
||||
$matrix = new Matrix\Builder::createIdentityMatrix(3);
|
||||
```
|
||||
will create a 3x3 identity matrix.
|
||||
|
||||
|
||||
Matrix objects are immutable: whenever you call a method or pass a grid to a function that returns a matrix value, a new Matrix object will be returned, and the original will remain unchanged. This also allows you to chain multiple methods as you would for a fluent interface (as long as they are methods that will return a Matrix result).
|
||||
|
||||
## Performing Mathematical Operations
|
||||
|
||||
To perform mathematical operations with Matrices, you can call the appropriate method against a matrix value, passing other values as arguments
|
||||
|
||||
```
|
||||
$matrix1 = new Matrix([
|
||||
[2, 7, 6],
|
||||
[9, 5, 1],
|
||||
[4, 3, 8],
|
||||
]);
|
||||
$matrix2 = new Matrix([
|
||||
[1, 2, 3],
|
||||
[4, 5, 6],
|
||||
[7, 8, 9],
|
||||
]);
|
||||
|
||||
echo $matrix1->multiply($matrix2);
|
||||
```
|
||||
or pass all values to the appropriate function
|
||||
```
|
||||
$matrix1 = new Matrix([
|
||||
[2, 7, 6],
|
||||
[9, 5, 1],
|
||||
[4, 3, 8],
|
||||
]);
|
||||
$matrix2 = new Matrix([
|
||||
[1, 2, 3],
|
||||
[4, 5, 6],
|
||||
[7, 8, 9],
|
||||
]);
|
||||
|
||||
echo Matrix\multiply($matrix1, $matrix2);
|
||||
```
|
||||
You can pass in the arguments as Matrix objects, or as arrays.
|
||||
|
||||
If you want to perform the same operation against multiple values (e.g. to add three or more matrices), then you can pass multiple arguments to any of the operations.
|
||||
|
||||
## Using functions
|
||||
|
||||
When calling any of the available functions for a matrix value, you can either call the relevant method for the Matrix object
|
||||
```
|
||||
$grid = [
|
||||
[16, 3, 2, 13],
|
||||
[ 5, 10, 11, 8],
|
||||
[ 9, 6, 7, 12],
|
||||
[ 4, 15, 14, 1],
|
||||
];
|
||||
|
||||
$matrix = new Matrix\Matrix($grid);
|
||||
|
||||
echo $matrix->trace();
|
||||
```
|
||||
or you can call the function as you would in procedural code, passing the Matrix object as an argument
|
||||
```
|
||||
$grid = [
|
||||
[16, 3, 2, 13],
|
||||
[ 5, 10, 11, 8],
|
||||
[ 9, 6, 7, 12],
|
||||
[ 4, 15, 14, 1],
|
||||
];
|
||||
|
||||
$matrix = new Matrix\Matrix($grid);
|
||||
echo Matrix\trace($matrix);
|
||||
```
|
||||
When called procedurally using the function, you can pass in the argument as a Matrix object, or as an array.
|
||||
```
|
||||
$grid = [
|
||||
[16, 3, 2, 13],
|
||||
[ 5, 10, 11, 8],
|
||||
[ 9, 6, 7, 12],
|
||||
[ 4, 15, 14, 1],
|
||||
];
|
||||
|
||||
echo Matrix\trace($grid);
|
||||
```
|
||||
As an alternative, it is also possible to call the method directly from the `Functions` class.
|
||||
```
|
||||
$grid = [
|
||||
[16, 3, 2, 13],
|
||||
[ 5, 10, 11, 8],
|
||||
[ 9, 6, 7, 12],
|
||||
[ 4, 15, 14, 1],
|
||||
];
|
||||
|
||||
$matrix = new Matrix\Matrix($grid);
|
||||
echo Matrix\Functions::trace($matrix);
|
||||
```
|
||||
Used this way, methods must be called statically, and the argument must be the Matrix object, and cannot be an array.
|
||||
62
vendor/markbaker/matrix/buildPhar.php
vendored
Normal file
62
vendor/markbaker/matrix/buildPhar.php
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
# required: PHP 5.3+ and zlib extension
|
||||
|
||||
// ini option check
|
||||
if (ini_get('phar.readonly')) {
|
||||
echo "php.ini: set the 'phar.readonly' option to 0 to enable phar creation\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// output name
|
||||
$pharName = 'Matrix.phar';
|
||||
|
||||
// target folder
|
||||
$sourceDir = __DIR__ . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR;
|
||||
|
||||
// default meta information
|
||||
$metaData = array(
|
||||
'Author' => 'Mark Baker <mark@lange.demon.co.uk>',
|
||||
'Description' => 'PHP Class for working with Matrix numbers',
|
||||
'Copyright' => 'Mark Baker (c) 2013-' . date('Y'),
|
||||
'Timestamp' => time(),
|
||||
'Version' => '0.1.0',
|
||||
'Date' => date('Y-m-d')
|
||||
);
|
||||
|
||||
// cleanup
|
||||
if (file_exists($pharName)) {
|
||||
echo "Removed: {$pharName}\n";
|
||||
unlink($pharName);
|
||||
}
|
||||
|
||||
echo "Building phar file...\n";
|
||||
|
||||
// the phar object
|
||||
$phar = new Phar($pharName, null, 'Matrix');
|
||||
$phar->buildFromDirectory($sourceDir);
|
||||
$phar->setStub(
|
||||
<<<'EOT'
|
||||
<?php
|
||||
spl_autoload_register(function ($className) {
|
||||
include 'phar://' . $className . '.php';
|
||||
});
|
||||
|
||||
try {
|
||||
Phar::mapPhar();
|
||||
} catch (PharException $e) {
|
||||
error_log($e->getMessage());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
include 'phar://functions/sqrt.php';
|
||||
|
||||
__HALT_COMPILER();
|
||||
EOT
|
||||
);
|
||||
$phar->setMetadata($metaData);
|
||||
$phar->compressFiles(Phar::GZ);
|
||||
|
||||
echo "Complete.\n";
|
||||
|
||||
exit();
|
||||
53
vendor/markbaker/matrix/classes/Autoloader.php
vendored
Normal file
53
vendor/markbaker/matrix/classes/Autoloader.php
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Matrix;
|
||||
|
||||
/**
|
||||
*
|
||||
* Autoloader for Matrix classes
|
||||
*
|
||||
* @package Matrix
|
||||
* @copyright Copyright (c) 2014 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class Autoloader
|
||||
{
|
||||
/**
|
||||
* Register the Autoloader with SPL
|
||||
*
|
||||
*/
|
||||
public static function Register()
|
||||
{
|
||||
if (function_exists('__autoload')) {
|
||||
// Register any existing autoloader function with SPL, so we don't get any clashes
|
||||
spl_autoload_register('__autoload');
|
||||
}
|
||||
// Register ourselves with SPL
|
||||
return spl_autoload_register(['Matrix\\Autoloader', 'Load']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Autoload a class identified by name
|
||||
*
|
||||
* @param string $pClassName Name of the object to load
|
||||
*/
|
||||
public static function Load($pClassName)
|
||||
{
|
||||
if ((class_exists($pClassName, false)) || (strpos($pClassName, 'Matrix\\') !== 0)) {
|
||||
// Either already loaded, or not a Matrix class request
|
||||
return false;
|
||||
}
|
||||
|
||||
$pClassFilePath = __DIR__ . DIRECTORY_SEPARATOR .
|
||||
'src' . DIRECTORY_SEPARATOR .
|
||||
str_replace(['Matrix\\', '\\'], ['', '/'], $pClassName) .
|
||||
'.php';
|
||||
|
||||
if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
|
||||
// Can't load
|
||||
return false;
|
||||
}
|
||||
require($pClassFilePath);
|
||||
}
|
||||
}
|
||||
38
vendor/markbaker/matrix/classes/Bootstrap.php
vendored
Normal file
38
vendor/markbaker/matrix/classes/Bootstrap.php
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__ . '/Autoloader.php';
|
||||
|
||||
\Matrix\Autoloader::Register();
|
||||
|
||||
|
||||
abstract class FilesystemRegexFilter extends RecursiveRegexIterator
|
||||
{
|
||||
protected $regex;
|
||||
public function __construct(RecursiveIterator $it, $regex)
|
||||
{
|
||||
$this->regex = $regex;
|
||||
parent::__construct($it, $regex);
|
||||
}
|
||||
}
|
||||
|
||||
class FilenameFilter extends FilesystemRegexFilter
|
||||
{
|
||||
// Filter files against the regex
|
||||
public function accept()
|
||||
{
|
||||
return (!$this->isFile() || preg_match($this->regex, $this->getFilename()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$srcFolder = __DIR__ . DIRECTORY_SEPARATOR . 'src';
|
||||
$srcDirectory = new RecursiveDirectoryIterator($srcFolder);
|
||||
|
||||
$filteredFileList = new FilenameFilter($srcDirectory, '/(?:php)$/i');
|
||||
$filteredFileList = new FilenameFilter($filteredFileList, '/^(?!.*(Matrix|Exception)\.php).*$/i');
|
||||
|
||||
foreach (new RecursiveIteratorIterator($filteredFileList) as $file) {
|
||||
if ($file->isFile()) {
|
||||
include_once $file;
|
||||
}
|
||||
}
|
||||
69
vendor/markbaker/matrix/classes/src/Builder.php
vendored
Normal file
69
vendor/markbaker/matrix/classes/src/Builder.php
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Class for the creating "special" Matrices
|
||||
*
|
||||
* @copyright Copyright (c) 2018 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Matrix;
|
||||
|
||||
/**
|
||||
* Matrix Builder class.
|
||||
*
|
||||
* @package Matrix
|
||||
*/
|
||||
class Builder
|
||||
{
|
||||
/**
|
||||
* Create a new matrix of specified dimensions, and filled with a specified value
|
||||
* If the column argument isn't provided, then a square matrix will be created
|
||||
*
|
||||
* @param $value
|
||||
* @param $rows
|
||||
* @param null $columns
|
||||
* @return Matrix
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function createFilledMatrix($value, $rows, $columns = null)
|
||||
{
|
||||
if ($columns === null) {
|
||||
$columns = $rows;
|
||||
}
|
||||
|
||||
$rows = Matrix::validateRow($rows);
|
||||
$columns = Matrix::validateColumn($columns);
|
||||
|
||||
return new Matrix(
|
||||
array_fill(
|
||||
0,
|
||||
$rows,
|
||||
array_fill(
|
||||
0,
|
||||
$columns,
|
||||
$value
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new identity matrix of specified dimensions
|
||||
* This will always be a square matrix, with the number of rows and columns matching the provided dimension
|
||||
*
|
||||
* @param int $dimensions
|
||||
* @return Matrix
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function createIdentityMatrix($dimensions)
|
||||
{
|
||||
$grid = static::createFilledMatrix(null, $dimensions)->toArray();
|
||||
|
||||
for ($x = 0; $x < $dimensions; ++$x) {
|
||||
$grid[$x][$x] = 1;
|
||||
}
|
||||
|
||||
return new Matrix($grid);
|
||||
}
|
||||
}
|
||||
13
vendor/markbaker/matrix/classes/src/Exception.php
vendored
Normal file
13
vendor/markbaker/matrix/classes/src/Exception.php
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Exception.
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Matrix;
|
||||
|
||||
class Exception extends \Exception
|
||||
{
|
||||
}
|
||||
318
vendor/markbaker/matrix/classes/src/Functions.php
vendored
Normal file
318
vendor/markbaker/matrix/classes/src/Functions.php
vendored
Normal file
@ -0,0 +1,318 @@
|
||||
<?php
|
||||
|
||||
namespace Matrix;
|
||||
|
||||
class Functions
|
||||
{
|
||||
/**
|
||||
* Calculate the adjoint of the matrix
|
||||
*
|
||||
* @param Matrix $matrix The matrix whose adjoint we wish to calculate
|
||||
* @return Matrix
|
||||
**/
|
||||
private static function getAdjoint(Matrix $matrix)
|
||||
{
|
||||
return self::transpose(
|
||||
self::getCofactors($matrix)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the adjoint of this matrix
|
||||
* The adjugate, classical adjoint, or adjunct of a square matrix is the transpose of its cofactor matrix.
|
||||
* The adjugate has sometimes been called the "adjoint", but today the "adjoint" of a matrix normally refers
|
||||
* to its corresponding adjoint operator, which is its conjugate transpose.
|
||||
*
|
||||
* @param Matrix $matrix The matrix whose adjoint we wish to calculate
|
||||
* @return Matrix
|
||||
* @throws Exception
|
||||
**/
|
||||
public static function adjoint(Matrix $matrix)
|
||||
{
|
||||
if (!$matrix->isSquare()) {
|
||||
throw new Exception('Adjoint can only be calculated for a square matrix');
|
||||
}
|
||||
|
||||
return self::getAdjoint($matrix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the cofactors of the matrix
|
||||
*
|
||||
* @param Matrix $matrix The matrix whose cofactors we wish to calculate
|
||||
* @return Matrix
|
||||
**/
|
||||
private static function getCofactors(Matrix $matrix)
|
||||
{
|
||||
$cofactors = self::getMinors($matrix);
|
||||
$dimensions = $matrix->rows;
|
||||
|
||||
$cof = 1;
|
||||
for ($i = 0; $i < $dimensions; ++$i) {
|
||||
$cofs = $cof;
|
||||
for ($j = 0; $j < $dimensions; ++$j) {
|
||||
$cofactors[$i][$j] *= $cofs;
|
||||
$cofs = -$cofs;
|
||||
}
|
||||
$cof = -$cof;
|
||||
}
|
||||
|
||||
return new Matrix($cofactors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cofactors of this matrix
|
||||
*
|
||||
* @param Matrix $matrix The matrix whose cofactors we wish to calculate
|
||||
* @return Matrix
|
||||
* @throws Exception
|
||||
**/
|
||||
public static function cofactors(Matrix $matrix)
|
||||
{
|
||||
if (!$matrix->isSquare()) {
|
||||
throw new Exception('Cofactors can only be calculated for a square matrix');
|
||||
}
|
||||
|
||||
return self::getCofactors($matrix);
|
||||
}
|
||||
|
||||
private static function getDeterminantSegment(Matrix $matrix, $row, $column)
|
||||
{
|
||||
$tmpMatrix = $matrix->toArray();
|
||||
unset($tmpMatrix[$row]);
|
||||
array_walk(
|
||||
$tmpMatrix,
|
||||
function (&$row) use ($column) {
|
||||
unset($row[$column]);
|
||||
}
|
||||
);
|
||||
|
||||
return self::getDeterminant(new Matrix($tmpMatrix));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the determinant of the matrix
|
||||
*
|
||||
* @param Matrix $matrix The matrix whose determinant we wish to calculate
|
||||
* @return float
|
||||
**/
|
||||
private static function getDeterminant(Matrix $matrix)
|
||||
{
|
||||
$dimensions = $matrix->rows;
|
||||
if ($dimensions == 1) {
|
||||
return $matrix->getValue(1, 1);
|
||||
} elseif ($dimensions == 2) {
|
||||
return $matrix->getValue(1, 1) * $matrix->getValue(2, 2) - $matrix->getValue(1, 2) * $matrix->getValue(2, 1);
|
||||
}
|
||||
|
||||
$determinant = 0;
|
||||
for ($i = 1; $i <= $dimensions; ++$i) {
|
||||
$det = $matrix->getValue(1, $i) * self::getDeterminantSegment($matrix, 0, $i-1);
|
||||
if (($i % 2) == 0) {
|
||||
$determinant -= $det;
|
||||
} else {
|
||||
$determinant += $det;
|
||||
}
|
||||
}
|
||||
|
||||
return $determinant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the determinant of this matrix
|
||||
*
|
||||
* @param Matrix $matrix The matrix whose determinant we wish to calculate
|
||||
* @return float
|
||||
* @throws Exception
|
||||
**/
|
||||
public static function determinant(Matrix $matrix)
|
||||
{
|
||||
if (!$matrix->isSquare()) {
|
||||
throw new Exception('Determinant can only be calculated for a square matrix');
|
||||
}
|
||||
|
||||
return self::getDeterminant($matrix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the diagonal of this matrix
|
||||
*
|
||||
* @param Matrix $matrix The matrix whose diagonal we wish to calculate
|
||||
* @return Matrix
|
||||
* @throws Exception
|
||||
**/
|
||||
public static function diagonal(Matrix $matrix)
|
||||
{
|
||||
if (!$matrix->isSquare()) {
|
||||
throw new Exception('Diagonal can only be extracted from a square matrix');
|
||||
}
|
||||
|
||||
$dimensions = $matrix->rows;
|
||||
$grid = Builder::createFilledMatrix(0, $dimensions, $dimensions)
|
||||
->toArray();
|
||||
|
||||
for ($i = 0; $i < $dimensions; ++$i) {
|
||||
$grid[$i][$i] = $matrix->getValue($i + 1, $i + 1);
|
||||
}
|
||||
|
||||
return new Matrix($grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the antidiagonal of this matrix
|
||||
*
|
||||
* @param Matrix $matrix The matrix whose antidiagonal we wish to calculate
|
||||
* @return Matrix
|
||||
* @throws Exception
|
||||
**/
|
||||
public static function antidiagonal(Matrix $matrix)
|
||||
{
|
||||
if (!$matrix->isSquare()) {
|
||||
throw new Exception('Anti-Diagonal can only be extracted from a square matrix');
|
||||
}
|
||||
|
||||
$dimensions = $matrix->rows;
|
||||
$grid = Builder::createFilledMatrix(0, $dimensions, $dimensions)
|
||||
->toArray();
|
||||
|
||||
for ($i = 0; $i < $dimensions; ++$i) {
|
||||
$grid[$i][$dimensions - $i - 1] = $matrix->getValue($i + 1, $dimensions - $i);
|
||||
}
|
||||
|
||||
return new Matrix($grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the identity matrix
|
||||
* The identity matrix, or sometimes ambiguously called a unit matrix, of size n is the n × n square matrix
|
||||
* with ones on the main diagonal and zeros elsewhere
|
||||
*
|
||||
* @param Matrix $matrix The matrix whose identity we wish to calculate
|
||||
* @return Matrix
|
||||
* @throws Exception
|
||||
**/
|
||||
public static function identity(Matrix $matrix)
|
||||
{
|
||||
if (!$matrix->isSquare()) {
|
||||
throw new Exception('Identity can only be created for a square matrix');
|
||||
}
|
||||
|
||||
$dimensions = $matrix->rows;
|
||||
|
||||
return Builder::createIdentityMatrix($dimensions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the inverse of this matrix
|
||||
*
|
||||
* @param Matrix $matrix The matrix whose inverse we wish to calculate
|
||||
* @return Matrix
|
||||
* @throws Exception
|
||||
**/
|
||||
public static function inverse(Matrix $matrix)
|
||||
{
|
||||
if (!$matrix->isSquare()) {
|
||||
throw new Exception('Inverse can only be calculated for a square matrix');
|
||||
}
|
||||
|
||||
$determinant = self::getDeterminant($matrix);
|
||||
if ($determinant == 0.0) {
|
||||
throw new Exception('Inverse can only be calculated for a matrix with a non-zero determinant');
|
||||
}
|
||||
|
||||
if ($matrix->rows == 1) {
|
||||
return new Matrix([[1 / $matrix->getValue(1, 1)]]);
|
||||
}
|
||||
|
||||
return self::getAdjoint($matrix)
|
||||
->multiply(1 / $determinant);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the minors of the matrix
|
||||
*
|
||||
* @param Matrix $matrix The matrix whose minors we wish to calculate
|
||||
* @return array[]
|
||||
**/
|
||||
protected static function getMinors(Matrix $matrix)
|
||||
{
|
||||
$minors = $matrix->toArray();
|
||||
$dimensions = $matrix->rows;
|
||||
if ($dimensions == 1) {
|
||||
return $minors;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $dimensions; ++$i) {
|
||||
for ($j = 0; $j < $dimensions; ++$j) {
|
||||
$minors[$i][$j] = self::getDeterminantSegment($matrix, $i, $j);
|
||||
}
|
||||
}
|
||||
|
||||
return $minors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the minors of the matrix
|
||||
* The minor of a matrix A is the determinant of some smaller square matrix, cut down from A by removing one or
|
||||
* more of its rows or columns.
|
||||
* Minors obtained by removing just one row and one column from square matrices (first minors) are required for
|
||||
* calculating matrix cofactors, which in turn are useful for computing both the determinant and inverse of
|
||||
* square matrices.
|
||||
*
|
||||
* @param Matrix $matrix The matrix whose minors we wish to calculate
|
||||
* @return Matrix
|
||||
* @throws Exception
|
||||
**/
|
||||
public static function minors(Matrix $matrix)
|
||||
{
|
||||
if (!$matrix->isSquare()) {
|
||||
throw new Exception('Minors can only be calculated for a square matrix');
|
||||
}
|
||||
|
||||
return new Matrix(self::getMinors($matrix));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the trace of this matrix
|
||||
* The trace is defined as the sum of the elements on the main diagonal (the diagonal from the upper left to the lower right)
|
||||
* of the matrix
|
||||
*
|
||||
* @param Matrix $matrix The matrix whose trace we wish to calculate
|
||||
* @return float
|
||||
* @throws Exception
|
||||
**/
|
||||
public static function trace(Matrix $matrix)
|
||||
{
|
||||
if (!$matrix->isSquare()) {
|
||||
throw new Exception('Trace can only be extracted from a square matrix');
|
||||
}
|
||||
|
||||
$dimensions = $matrix->rows;
|
||||
$result = 0;
|
||||
for ($i = 1; $i <= $dimensions; ++$i) {
|
||||
$result += $matrix->getValue($i, $i);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the transpose of this matrix
|
||||
*
|
||||
* @param Matrix $matrix The matrix whose transpose we wish to calculate
|
||||
* @return Matrix
|
||||
* @throws Exception
|
||||
**/
|
||||
public static function transpose(Matrix $matrix)
|
||||
{
|
||||
$grid = call_user_func_array(
|
||||
'array_map',
|
||||
array_merge(
|
||||
[null],
|
||||
$matrix->toArray()
|
||||
)
|
||||
);
|
||||
|
||||
return new Matrix($grid);
|
||||
}
|
||||
}
|
||||
403
vendor/markbaker/matrix/classes/src/Matrix.php
vendored
Normal file
403
vendor/markbaker/matrix/classes/src/Matrix.php
vendored
Normal file
@ -0,0 +1,403 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Class for the management of Matrices
|
||||
*
|
||||
* @copyright Copyright (c) 2018 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Matrix;
|
||||
|
||||
/**
|
||||
* Matrix object.
|
||||
*
|
||||
* @package Matrix
|
||||
*
|
||||
* @property-read int $rows The number of rows in the matrix
|
||||
* @property-read int $columns The number of columns in the matrix
|
||||
* @method Matrix antidiagonal()
|
||||
* @method Matrix adjoint()
|
||||
* @method Matrix cofactors()
|
||||
* @method float determinant()
|
||||
* @method Matrix diagonal()
|
||||
* @method Matrix identity()
|
||||
* @method Matrix inverse()
|
||||
* @method Matrix pseudoInverse()
|
||||
* @method Matrix minors()
|
||||
* @method float trace()
|
||||
* @method Matrix transpose()
|
||||
* @method Matrix add(...$matrices)
|
||||
* @method Matrix subtract(...$matrices)
|
||||
* @method Matrix multiply(...$matrices)
|
||||
* @method Matrix divideby(...$matrices)
|
||||
* @method Matrix divideinto(...$matrices)
|
||||
*/
|
||||
class Matrix
|
||||
{
|
||||
protected $rows;
|
||||
protected $columns;
|
||||
protected $grid = [];
|
||||
|
||||
/*
|
||||
* Create a new Matrix object from an array of values
|
||||
*
|
||||
* @param array $grid
|
||||
*/
|
||||
public function __construct(array $grid)
|
||||
{
|
||||
$this->buildFromArray(array_values($grid));
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a new Matrix object from an array of values
|
||||
*
|
||||
* @param array $grid
|
||||
*/
|
||||
protected function buildFromArray(array $grid)
|
||||
{
|
||||
$this->rows = count($grid);
|
||||
$columns = array_reduce(
|
||||
$grid,
|
||||
function ($carry, $value) {
|
||||
return max($carry, is_array($value) ? count($value) : 1);
|
||||
},
|
||||
0
|
||||
);
|
||||
$this->columns = $columns;
|
||||
|
||||
array_walk(
|
||||
$grid,
|
||||
function (&$value) use ($columns) {
|
||||
if (!is_array($value)) {
|
||||
$value = [$value];
|
||||
}
|
||||
$value = array_pad(array_values($value), $columns, null);
|
||||
}
|
||||
);
|
||||
|
||||
$this->grid = $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a row number is a positive integer
|
||||
*
|
||||
* @param $row
|
||||
* @return int
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function validateRow($row)
|
||||
{
|
||||
if ((!is_numeric($row)) || (intval($row) < 1)) {
|
||||
throw new Exception('Invalid Row');
|
||||
}
|
||||
|
||||
return (int) $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a column number is a positive integer
|
||||
*
|
||||
* @param $column
|
||||
* @return int
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function validateColumn($column)
|
||||
{
|
||||
if ((!is_numeric($column)) || (intval($column) < 1)) {
|
||||
throw new Exception('Invalid Column');
|
||||
}
|
||||
|
||||
return (int) $column;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a row number falls within the set of rows for this matrix
|
||||
*
|
||||
* @param $row
|
||||
* @return int
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function validateRowInRange($row)
|
||||
{
|
||||
$row = static::validateRow($row);
|
||||
if ($row > $this->rows) {
|
||||
throw new Exception('Requested Row exceeds matrix size');
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a column number falls within the set of columns for this matrix
|
||||
*
|
||||
* @param $column
|
||||
* @return int
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function validateColumnInRange($column)
|
||||
{
|
||||
$column = static::validateColumn($column);
|
||||
if ($column > $this->columns) {
|
||||
throw new Exception('Requested Column exceeds matrix size');
|
||||
}
|
||||
|
||||
return $column;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a new matrix as a subset of rows from this matrix, starting at row number $row, and $rowCount rows
|
||||
* A $rowCount value of 0 will return all rows of the matrix from $row
|
||||
* A negative $rowCount value will return rows until that many rows from the end of the matrix
|
||||
*
|
||||
* Note that row numbers start from 1, not from 0
|
||||
*
|
||||
* @param $row
|
||||
* @param int $rowCount
|
||||
* @return static
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getRows($row, $rowCount = 1)
|
||||
{
|
||||
$row = $this->validateRowInRange($row);
|
||||
if ($rowCount == 0) {
|
||||
$rowCount = $this->rows - $row + 1;
|
||||
}
|
||||
|
||||
return new static(array_slice($this->grid, $row - 1, $rowCount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a new matrix as a subset of columns from this matrix, starting at column number $column, and $columnCount columns
|
||||
* A $columnCount value of 0 will return all columns of the matrix from $column
|
||||
* A negative $columnCount value will return columns until that many columns from the end of the matrix
|
||||
*
|
||||
* Note that column numbers start from 1, not from 0
|
||||
*
|
||||
* @param $column
|
||||
* @param int $columnCount
|
||||
* @return static
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getColumns($column, $columnCount = 1)
|
||||
{
|
||||
$column = $this->validateColumnInRange($column);
|
||||
if ($columnCount < 1) {
|
||||
$columnCount = $this->columns + $columnCount - $column + 1;
|
||||
}
|
||||
|
||||
$grid = [];
|
||||
for ($i = $column - 1; $i < $column + $columnCount - 1; ++$i) {
|
||||
$grid[] = array_column($this->grid, $i);
|
||||
}
|
||||
|
||||
return (new static($grid))->transpose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a new matrix as a subset of rows from this matrix, dropping rows starting at row number $row,
|
||||
* and $rowCount rows
|
||||
* A negative $rowCount value will drop rows until that many rows from the end of the matrix
|
||||
* A $rowCount value of 0 will remove all rows of the matrix from $row
|
||||
*
|
||||
* Note that row numbers start from 1, not from 0
|
||||
*
|
||||
* @param $row
|
||||
* @param int $rowCount
|
||||
* @return static
|
||||
* @throws Exception
|
||||
*/
|
||||
public function dropRows($row, $rowCount = 1)
|
||||
{
|
||||
$this->validateRowInRange($row);
|
||||
if ($rowCount == 0) {
|
||||
$rowCount = $this->rows - $row + 1;
|
||||
}
|
||||
|
||||
$grid = $this->grid;
|
||||
array_splice($grid, $row - 1, $rowCount);
|
||||
|
||||
return new static($grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a new matrix as a subset of columns from this matrix, dropping columns starting at column number $column,
|
||||
* and $columnCount columns
|
||||
* A negative $columnCount value will drop columns until that many columns from the end of the matrix
|
||||
* A $columnCount value of 0 will remove all columns of the matrix from $column
|
||||
*
|
||||
* Note that column numbers start from 1, not from 0
|
||||
*
|
||||
* @param $column
|
||||
* @param int $columnCount
|
||||
* @return static
|
||||
* @throws Exception
|
||||
*/
|
||||
public function dropColumns($column, $columnCount = 1)
|
||||
{
|
||||
$this->validateColumnInRange($column);
|
||||
if ($columnCount < 1) {
|
||||
$columnCount = $this->columns + $columnCount - $column + 1;
|
||||
}
|
||||
|
||||
$grid = $this->grid;
|
||||
array_walk(
|
||||
$grid,
|
||||
function (&$row) use ($column, $columnCount) {
|
||||
array_splice($row, $column - 1, $columnCount);
|
||||
}
|
||||
);
|
||||
|
||||
return new static($grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a value from this matrix, from the "cell" identified by the row and column numbers
|
||||
* Note that row and column numbers start from 1, not from 0
|
||||
*
|
||||
* @param $row
|
||||
* @param $column
|
||||
* @return static
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getValue($row, $column)
|
||||
{
|
||||
$row = $this->validateRowInRange($row);
|
||||
$column = $this->validateColumnInRange($column);
|
||||
|
||||
return $this->grid[$row - 1][$column - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Generator that will yield each row of the matrix in turn as a vector matrix
|
||||
* or the value of each cell if the matrix is a vector
|
||||
*
|
||||
* @return \Generator|Matrix[]|mixed[]
|
||||
*/
|
||||
public function rows()
|
||||
{
|
||||
foreach ($this->grid as $i => $row) {
|
||||
yield $i + 1 => ($this->columns == 1)
|
||||
? $row[0]
|
||||
: new static([$row]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Generator that will yield each column of the matrix in turn as a vector matrix
|
||||
* or the value of each cell if the matrix is a vector
|
||||
*
|
||||
* @return \Generator|Matrix[]|mixed[]
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
for ($i = 0; $i < $this->columns; ++$i) {
|
||||
yield $i + 1 => ($this->rows == 1)
|
||||
? $this->grid[0][$i]
|
||||
: new static(array_column($this->grid, $i));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify if the row and column dimensions of this matrix are equal,
|
||||
* i.e. if it is a "square" matrix
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSquare()
|
||||
{
|
||||
return $this->rows == $this->columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify if this matrix is a vector
|
||||
* i.e. if it comprises only a single row or a single column
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isVector()
|
||||
{
|
||||
return $this->rows == 1 || $this->columns == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the matrix as a 2-dimensional array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return $this->grid;
|
||||
}
|
||||
|
||||
protected static $getters = [
|
||||
'rows',
|
||||
'columns',
|
||||
];
|
||||
|
||||
/**
|
||||
* Access specific properties as read-only (no setters)
|
||||
*
|
||||
* @param $propertyName
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __get($propertyName)
|
||||
{
|
||||
$propertyName = strtolower($propertyName);
|
||||
|
||||
// Test for function calls
|
||||
if (in_array($propertyName, self::$getters)) {
|
||||
return $this->$propertyName;
|
||||
}
|
||||
|
||||
throw new Exception('Property does not exist');
|
||||
}
|
||||
|
||||
protected static $functions = [
|
||||
'antidiagonal',
|
||||
'adjoint',
|
||||
'cofactors',
|
||||
'determinant',
|
||||
'diagonal',
|
||||
'identity',
|
||||
'inverse',
|
||||
'minors',
|
||||
'trace',
|
||||
'transpose',
|
||||
];
|
||||
|
||||
protected static $operations = [
|
||||
'add',
|
||||
'subtract',
|
||||
'multiply',
|
||||
'divideby',
|
||||
'divideinto',
|
||||
'directsum',
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns the result of the function call or operation
|
||||
*
|
||||
* @param string $functionName
|
||||
* @param mixed[] $arguments
|
||||
* @return Matrix|float
|
||||
* @throws Exception|\InvalidArgumentException
|
||||
*/
|
||||
public function __call($functionName, $arguments)
|
||||
{
|
||||
$functionName = strtolower(str_replace('_', '', $functionName));
|
||||
|
||||
// Test for function calls
|
||||
if (in_array($functionName, self::$functions)) {
|
||||
$functionName = "\\" . __NAMESPACE__ . "\\{$functionName}";
|
||||
return $functionName($this, ...$arguments);
|
||||
}
|
||||
// Test for operation calls
|
||||
if (in_array($functionName, self::$operations)) {
|
||||
$functionName = "\\" . __NAMESPACE__ . "\\{$functionName}";
|
||||
return $functionName($this, ...$arguments);
|
||||
}
|
||||
throw new Exception('Function or Operation does not exist');
|
||||
}
|
||||
}
|
||||
68
vendor/markbaker/matrix/classes/src/Operators/Addition.php
vendored
Normal file
68
vendor/markbaker/matrix/classes/src/Operators/Addition.php
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace Matrix\Operators;
|
||||
|
||||
use Matrix\Matrix;
|
||||
use Matrix\Exception;
|
||||
|
||||
class Addition extends Operator
|
||||
{
|
||||
/**
|
||||
* Execute the addition
|
||||
*
|
||||
* @param mixed $value The matrix or numeric value to add to the current base value
|
||||
* @throws Exception If the provided argument is not appropriate for the operation
|
||||
* @return $this The operation object, allowing multiple additions to be chained
|
||||
**/
|
||||
public function execute($value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
$value = new Matrix($value);
|
||||
}
|
||||
|
||||
if (is_object($value) && ($value instanceof Matrix)) {
|
||||
return $this->addMatrix($value);
|
||||
} elseif (is_numeric($value)) {
|
||||
return $this->addScalar($value);
|
||||
}
|
||||
|
||||
throw new Exception('Invalid argument for addition');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the addition for a scalar
|
||||
*
|
||||
* @param mixed $value The numeric value to add to the current base value
|
||||
* @return $this The operation object, allowing multiple additions to be chained
|
||||
**/
|
||||
protected function addScalar($value)
|
||||
{
|
||||
for ($row = 0; $row < $this->rows; ++$row) {
|
||||
for ($column = 0; $column < $this->columns; ++$column) {
|
||||
$this->matrix[$row][$column] += $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the addition for a matrix
|
||||
*
|
||||
* @param Matrix $value The numeric value to add to the current base value
|
||||
* @return $this The operation object, allowing multiple additions to be chained
|
||||
* @throws Exception If the provided argument is not appropriate for the operation
|
||||
**/
|
||||
protected function addMatrix(Matrix $value)
|
||||
{
|
||||
$this->validateMatchingDimensions($value);
|
||||
|
||||
for ($row = 0; $row < $this->rows; ++$row) {
|
||||
for ($column = 0; $column < $this->columns; ++$column) {
|
||||
$this->matrix[$row][$column] += $value->getValue($row + 1, $column + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
65
vendor/markbaker/matrix/classes/src/Operators/DirectSum.php
vendored
Normal file
65
vendor/markbaker/matrix/classes/src/Operators/DirectSum.php
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Matrix\Operators;
|
||||
|
||||
use Matrix\Matrix;
|
||||
use Matrix\Exception;
|
||||
|
||||
class DirectSum extends Operator
|
||||
{
|
||||
/**
|
||||
* Execute the addition
|
||||
*
|
||||
* @param mixed $value The matrix or numeric value to add to the current base value
|
||||
* @throws Exception If the provided argument is not appropriate for the operation
|
||||
* @return $this The operation object, allowing multiple additions to be chained
|
||||
**/
|
||||
public function execute($value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
$value = new Matrix($value);
|
||||
}
|
||||
|
||||
if (is_object($value) && ($value instanceof Matrix)) {
|
||||
return $this->directSumMatrix($value);
|
||||
}
|
||||
|
||||
throw new Exception('Invalid argument for addition');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the direct sum for a matrix
|
||||
*
|
||||
* @param Matrix $value The numeric value to concatenate/direct sum with the current base value
|
||||
* @return $this The operation object, allowing multiple additions to be chained
|
||||
* @throws Exception If the provided argument is not appropriate for the operation
|
||||
**/
|
||||
protected function directSumMatrix(Matrix $value)
|
||||
{
|
||||
$originalColumnCount = count($this->matrix[0]);
|
||||
$originalRowCount = count($this->matrix);
|
||||
$additionalColumnCount = $value->columns;
|
||||
$additionalRowCount = $value->rows;
|
||||
$value = $value->toArray();
|
||||
|
||||
for ($row = 0; $row < $this->rows; ++$row) {
|
||||
$this->matrix[$row] = array_merge($this->matrix[$row], array_fill(0, $additionalColumnCount, 0));
|
||||
}
|
||||
|
||||
$this->matrix = array_merge(
|
||||
$this->matrix,
|
||||
array_fill(0, $additionalRowCount, array_fill(0, $originalColumnCount, 0))
|
||||
);
|
||||
|
||||
for ($row = $originalRowCount; $row < $originalRowCount + $additionalRowCount; ++$row) {
|
||||
array_splice(
|
||||
$this->matrix[$row],
|
||||
$originalColumnCount,
|
||||
$additionalColumnCount,
|
||||
$value[$row - $originalRowCount]
|
||||
);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
38
vendor/markbaker/matrix/classes/src/Operators/Division.php
vendored
Normal file
38
vendor/markbaker/matrix/classes/src/Operators/Division.php
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Matrix\Operators;
|
||||
|
||||
use \Matrix\Matrix;
|
||||
use \Matrix\Functions;
|
||||
use Matrix\Exception;
|
||||
|
||||
class Division extends Multiplication
|
||||
{
|
||||
/**
|
||||
* Execute the division
|
||||
*
|
||||
* @param mixed $value The matrix or numeric value to divide the current base value by
|
||||
* @throws Exception If the provided argument is not appropriate for the operation
|
||||
* @return $this The operation object, allowing multiple divisions to be chained
|
||||
**/
|
||||
public function execute($value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
$value = new Matrix($value);
|
||||
}
|
||||
|
||||
if (is_object($value) && ($value instanceof Matrix)) {
|
||||
try {
|
||||
$value = Functions::inverse($value);
|
||||
} catch (Exception $e) {
|
||||
throw new Exception('Division can only be calculated using a matrix with a non-zero determinant');
|
||||
}
|
||||
|
||||
return $this->multiplyMatrix($value);
|
||||
} elseif (is_numeric($value)) {
|
||||
return $this->multiplyScalar(1 / $value);
|
||||
}
|
||||
|
||||
throw new Exception('Invalid argument for division');
|
||||
}
|
||||
}
|
||||
77
vendor/markbaker/matrix/classes/src/Operators/Multiplication.php
vendored
Normal file
77
vendor/markbaker/matrix/classes/src/Operators/Multiplication.php
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Matrix\Operators;
|
||||
|
||||
use Matrix\Matrix;
|
||||
use \Matrix\Builder;
|
||||
use Matrix\Exception;
|
||||
|
||||
class Multiplication extends Operator
|
||||
{
|
||||
/**
|
||||
* Execute the multiplication
|
||||
*
|
||||
* @param mixed $value The matrix or numeric value to multiply the current base value by
|
||||
* @throws Exception If the provided argument is not appropriate for the operation
|
||||
* @return $this The operation object, allowing multiple multiplications to be chained
|
||||
**/
|
||||
public function execute($value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
$value = new Matrix($value);
|
||||
}
|
||||
|
||||
if (is_object($value) && ($value instanceof Matrix)) {
|
||||
return $this->multiplyMatrix($value);
|
||||
} elseif (is_numeric($value)) {
|
||||
return $this->multiplyScalar($value);
|
||||
}
|
||||
|
||||
throw new Exception('Invalid argument for multiplication');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the multiplication for a scalar
|
||||
*
|
||||
* @param mixed $value The numeric value to multiply with the current base value
|
||||
* @return $this The operation object, allowing multiple mutiplications to be chained
|
||||
**/
|
||||
protected function multiplyScalar($value)
|
||||
{
|
||||
for ($row = 0; $row < $this->rows; ++$row) {
|
||||
for ($column = 0; $column < $this->columns; ++$column) {
|
||||
$this->matrix[$row][$column] *= $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the multiplication for a matrix
|
||||
*
|
||||
* @param Matrix $value The numeric value to multiply with the current base value
|
||||
* @return $this The operation object, allowing multiple mutiplications to be chained
|
||||
* @throws Exception If the provided argument is not appropriate for the operation
|
||||
**/
|
||||
protected function multiplyMatrix(Matrix $value)
|
||||
{
|
||||
$this->validateReflectingDimensions($value);
|
||||
|
||||
$newRows = $this->rows;
|
||||
$newColumns = $value->columns;
|
||||
$matrix = Builder::createFilledMatrix(0, $newRows, $newColumns)
|
||||
->toArray();
|
||||
for ($row = 0; $row < $newRows; ++$row) {
|
||||
for ($column = 0; $column < $newColumns; ++$column) {
|
||||
$columnData = $value->getColumns($column + 1)->toArray();
|
||||
foreach ($this->matrix[$row] as $key => $valueData) {
|
||||
$matrix[$row][$column] += $valueData * $columnData[$key][0];
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->matrix = $matrix;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
78
vendor/markbaker/matrix/classes/src/Operators/Operator.php
vendored
Normal file
78
vendor/markbaker/matrix/classes/src/Operators/Operator.php
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace Matrix\Operators;
|
||||
|
||||
use Matrix\Matrix;
|
||||
use Matrix\Exception;
|
||||
|
||||
abstract class Operator
|
||||
{
|
||||
/**
|
||||
* Stored internally as a 2-dimension array of values
|
||||
*
|
||||
* @property mixed[][] $matrix
|
||||
**/
|
||||
protected $matrix;
|
||||
|
||||
/**
|
||||
* Number of rows in the matrix
|
||||
*
|
||||
* @property integer $rows
|
||||
**/
|
||||
protected $rows;
|
||||
|
||||
/**
|
||||
* Number of columns in the matrix
|
||||
*
|
||||
* @property integer $columns
|
||||
**/
|
||||
protected $columns;
|
||||
|
||||
/**
|
||||
* Create an new handler object for the operation
|
||||
*
|
||||
* @param Matrix $matrix The base Matrix object on which the operation will be performed
|
||||
*/
|
||||
public function __construct(Matrix $matrix)
|
||||
{
|
||||
$this->rows = $matrix->rows;
|
||||
$this->columns = $matrix->columns;
|
||||
$this->matrix = $matrix->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the dimensions of the matrices being operated on to see if they are valid for addition/subtraction
|
||||
*
|
||||
* @param Matrix $matrix The second Matrix object on which the operation will be performed
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function validateMatchingDimensions(Matrix $matrix)
|
||||
{
|
||||
if (($this->rows != $matrix->rows) || ($this->columns != $matrix->columns)) {
|
||||
throw new Exception('Matrices have mismatched dimensions');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the dimensions of the matrices being operated on to see if they are valid for multiplication/division
|
||||
*
|
||||
* @param Matrix $matrix The second Matrix object on which the operation will be performed
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function validateReflectingDimensions(Matrix $matrix)
|
||||
{
|
||||
if ($this->columns != $matrix->rows) {
|
||||
throw new Exception('Matrices have mismatched dimensions');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the result of the operation
|
||||
*
|
||||
* @return Matrix
|
||||
*/
|
||||
public function result()
|
||||
{
|
||||
return new Matrix($this->matrix);
|
||||
}
|
||||
}
|
||||
68
vendor/markbaker/matrix/classes/src/Operators/Subtraction.php
vendored
Normal file
68
vendor/markbaker/matrix/classes/src/Operators/Subtraction.php
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace Matrix\Operators;
|
||||
|
||||
use Matrix\Matrix;
|
||||
use Matrix\Exception;
|
||||
|
||||
class Subtraction extends Operator
|
||||
{
|
||||
/**
|
||||
* Execute the subtraction
|
||||
*
|
||||
* @param mixed $value The matrix or numeric value to subtract from the current base value
|
||||
* @throws Exception If the provided argument is not appropriate for the operation
|
||||
* @return $this The operation object, allowing multiple subtractions to be chained
|
||||
**/
|
||||
public function execute($value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
$value = new Matrix($value);
|
||||
}
|
||||
|
||||
if (is_object($value) && ($value instanceof Matrix)) {
|
||||
return $this->subtractMatrix($value);
|
||||
} elseif (is_numeric($value)) {
|
||||
return $this->subtractScalar($value);
|
||||
}
|
||||
|
||||
throw new Exception('Invalid argument for subtraction');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the subtraction for a scalar
|
||||
*
|
||||
* @param mixed $value The numeric value to subtracted from the current base value
|
||||
* @return $this The operation object, allowing multiple additions to be chained
|
||||
**/
|
||||
protected function subtractScalar($value)
|
||||
{
|
||||
for ($row = 0; $row < $this->rows; ++$row) {
|
||||
for ($column = 0; $column < $this->columns; ++$column) {
|
||||
$this->matrix[$row][$column] -= $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the subtraction for a matrix
|
||||
*
|
||||
* @param Matrix $value The numeric value to subtract from the current base value
|
||||
* @return $this The operation object, allowing multiple subtractions to be chained
|
||||
* @throws Exception If the provided argument is not appropriate for the operation
|
||||
**/
|
||||
protected function subtractMatrix(Matrix $value)
|
||||
{
|
||||
$this->validateMatchingDimensions($value);
|
||||
|
||||
for ($row = 0; $row < $this->rows; ++$row) {
|
||||
for ($column = 0; $column < $this->columns; ++$column) {
|
||||
$this->matrix[$row][$column] -= $value->getValue($row + 1, $column + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
26
vendor/markbaker/matrix/classes/src/functions/adjoint.php
vendored
Normal file
26
vendor/markbaker/matrix/classes/src/functions/adjoint.php
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the matrix adjoint() function
|
||||
*
|
||||
* @copyright Copyright (c) 2018 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Matrix;
|
||||
|
||||
/**
|
||||
* Returns the adjoint of a matrix or an array.
|
||||
*
|
||||
* @param Matrix|array $matrix Matrix or an array to treat as a matrix.
|
||||
* @return Matrix The new matrix
|
||||
* @throws Exception If argument isn't a valid matrix or array.
|
||||
*/
|
||||
function adjoint($matrix)
|
||||
{
|
||||
if (!is_object($matrix) || !($matrix instanceof Matrix)) {
|
||||
$matrix = new Matrix($matrix);
|
||||
}
|
||||
|
||||
return Functions::adjoint($matrix);
|
||||
}
|
||||
26
vendor/markbaker/matrix/classes/src/functions/antidiagonal.php
vendored
Normal file
26
vendor/markbaker/matrix/classes/src/functions/antidiagonal.php
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the matrix antidiagonal() function
|
||||
*
|
||||
* @copyright Copyright (c) 2018 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Matrix;
|
||||
|
||||
/**
|
||||
* Returns the antidiagonal of a matrix or an array.
|
||||
*
|
||||
* @param Matrix|array $matrix Matrix or an array to treat as a matrix.
|
||||
* @return Matrix The new matrix
|
||||
* @throws Exception If argument isn't a valid matrix or array.
|
||||
*/
|
||||
function antidiagonal($matrix)
|
||||
{
|
||||
if (!is_object($matrix) || !($matrix instanceof Matrix)) {
|
||||
$matrix = new Matrix($matrix);
|
||||
}
|
||||
|
||||
return Functions::antidiagonal($matrix);
|
||||
}
|
||||
26
vendor/markbaker/matrix/classes/src/functions/cofactors.php
vendored
Normal file
26
vendor/markbaker/matrix/classes/src/functions/cofactors.php
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the matrix cofactors() function
|
||||
*
|
||||
* @copyright Copyright (c) 2018 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Matrix;
|
||||
|
||||
/**
|
||||
* Returns the cofactors of a matrix or an array.
|
||||
*
|
||||
* @param Matrix|array $matrix Matrix or an array to treat as a matrix.
|
||||
* @return Matrix The new matrix
|
||||
* @throws Exception If argument isn't a valid matrix or array.
|
||||
*/
|
||||
function cofactors($matrix)
|
||||
{
|
||||
if (!is_object($matrix) || !($matrix instanceof Matrix)) {
|
||||
$matrix = new Matrix($matrix);
|
||||
}
|
||||
|
||||
return Functions::cofactors($matrix);
|
||||
}
|
||||
26
vendor/markbaker/matrix/classes/src/functions/determinant.php
vendored
Normal file
26
vendor/markbaker/matrix/classes/src/functions/determinant.php
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the matrix determinant() function
|
||||
*
|
||||
* @copyright Copyright (c) 2018 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Matrix;
|
||||
|
||||
/**
|
||||
* Returns the determinant of a matrix or an array.
|
||||
*
|
||||
* @param Matrix|array $matrix Matrix or an array to treat as a matrix.
|
||||
* @return Matrix The new matrix
|
||||
* @throws Exception If argument isn't a valid matrix or array.
|
||||
*/
|
||||
function determinant($matrix)
|
||||
{
|
||||
if (!is_object($matrix) || !($matrix instanceof Matrix)) {
|
||||
$matrix = new Matrix($matrix);
|
||||
}
|
||||
|
||||
return Functions::determinant($matrix);
|
||||
}
|
||||
26
vendor/markbaker/matrix/classes/src/functions/diagonal.php
vendored
Normal file
26
vendor/markbaker/matrix/classes/src/functions/diagonal.php
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the matrix diagonal() function
|
||||
*
|
||||
* @copyright Copyright (c) 2018 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Matrix;
|
||||
|
||||
/**
|
||||
* Returns the diagonal of a matrix or an array.
|
||||
*
|
||||
* @param Matrix|array $matrix Matrix or an array to treat as a matrix.
|
||||
* @return Matrix The new matrix
|
||||
* @throws Exception If argument isn't a valid matrix or array.
|
||||
*/
|
||||
function diagonal($matrix)
|
||||
{
|
||||
if (!is_object($matrix) || !($matrix instanceof Matrix)) {
|
||||
$matrix = new Matrix($matrix);
|
||||
}
|
||||
|
||||
return Functions::diagonal($matrix);
|
||||
}
|
||||
26
vendor/markbaker/matrix/classes/src/functions/identity.php
vendored
Normal file
26
vendor/markbaker/matrix/classes/src/functions/identity.php
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the matrix identity() function
|
||||
*
|
||||
* @copyright Copyright (c) 2018 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Matrix;
|
||||
|
||||
/**
|
||||
* Returns the identity of a matrix or an array.
|
||||
*
|
||||
* @param Matrix|array $matrix Matrix or an array to treat as a matrix.
|
||||
* @return Matrix The identity matrix
|
||||
* @throws Exception If argument isn't a valid matrix or array.
|
||||
*/
|
||||
function identity($matrix)
|
||||
{
|
||||
if (!is_object($matrix) || !($matrix instanceof Matrix)) {
|
||||
$matrix = new Matrix($matrix);
|
||||
}
|
||||
|
||||
return Functions::identity($matrix);
|
||||
}
|
||||
26
vendor/markbaker/matrix/classes/src/functions/inverse.php
vendored
Normal file
26
vendor/markbaker/matrix/classes/src/functions/inverse.php
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the matrix inverse() function
|
||||
*
|
||||
* @copyright Copyright (c) 2018 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Matrix;
|
||||
|
||||
/**
|
||||
* Returns the inverse of a matrix or an array.
|
||||
*
|
||||
* @param Matrix|array $matrix Matrix or an array to treat as a matrix.
|
||||
* @return Matrix The new matrix
|
||||
* @throws Exception If argument isn't a valid matrix or array.
|
||||
*/
|
||||
function inverse($matrix)
|
||||
{
|
||||
if (!is_object($matrix) || !($matrix instanceof Matrix)) {
|
||||
$matrix = new Matrix($matrix);
|
||||
}
|
||||
|
||||
return Functions::inverse($matrix);
|
||||
}
|
||||
26
vendor/markbaker/matrix/classes/src/functions/minors.php
vendored
Normal file
26
vendor/markbaker/matrix/classes/src/functions/minors.php
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the matrix minors() function
|
||||
*
|
||||
* @copyright Copyright (c) 2018 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Matrix;
|
||||
|
||||
/**
|
||||
* Returns the minors of a matrix or an array.
|
||||
*
|
||||
* @param Matrix|array $matrix Matrix or an array to treat as a matrix.
|
||||
* @return Matrix The new matrix
|
||||
* @throws Exception If argument isn't a valid matrix or array.
|
||||
*/
|
||||
function minors($matrix)
|
||||
{
|
||||
if (!is_object($matrix) || !($matrix instanceof Matrix)) {
|
||||
$matrix = new Matrix($matrix);
|
||||
}
|
||||
|
||||
return Functions::minors($matrix);
|
||||
}
|
||||
26
vendor/markbaker/matrix/classes/src/functions/trace.php
vendored
Normal file
26
vendor/markbaker/matrix/classes/src/functions/trace.php
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the matrix trace() function
|
||||
*
|
||||
* @copyright Copyright (c) 2018 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Matrix;
|
||||
|
||||
/**
|
||||
* Returns the trace of a matrix or an array.
|
||||
*
|
||||
* @param Matrix|array $matrix Matrix or an array to treat as a matrix.
|
||||
* @return float The trace of the matrix
|
||||
* @throws Exception If argument isn't a valid matrix or array.
|
||||
*/
|
||||
function trace($matrix)
|
||||
{
|
||||
if (!is_object($matrix) || !($matrix instanceof Matrix)) {
|
||||
$matrix = new Matrix($matrix);
|
||||
}
|
||||
|
||||
return Functions::trace($matrix);
|
||||
}
|
||||
26
vendor/markbaker/matrix/classes/src/functions/transpose.php
vendored
Normal file
26
vendor/markbaker/matrix/classes/src/functions/transpose.php
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the matrix transpose() function
|
||||
*
|
||||
* @copyright Copyright (c) 2018 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Matrix;
|
||||
|
||||
/**
|
||||
* Returns the transpose of a matrix or an array.
|
||||
*
|
||||
* @param Matrix|array $matrix Matrix or an array to treat as a matrix.
|
||||
* @return Matrix The transposed matrix
|
||||
* @throws Exception If argument isn't a valid matrix or array.
|
||||
*/
|
||||
function transpose($matrix)
|
||||
{
|
||||
if (!is_object($matrix) || !($matrix instanceof Matrix)) {
|
||||
$matrix = new Matrix($matrix);
|
||||
}
|
||||
|
||||
return Functions::transpose($matrix);
|
||||
}
|
||||
39
vendor/markbaker/matrix/classes/src/operations/add.php
vendored
Normal file
39
vendor/markbaker/matrix/classes/src/operations/add.php
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the matrix addition operation
|
||||
*
|
||||
* @copyright Copyright (c) 2018 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Matrix;
|
||||
|
||||
use Matrix\Operators\Addition;
|
||||
|
||||
/**
|
||||
* Adds two or more matrices
|
||||
*
|
||||
* @param mixed[] $matrixValues The matrices to add
|
||||
* @return Matrix
|
||||
* @throws Exception
|
||||
*/
|
||||
function add(...$matrixValues)
|
||||
{
|
||||
if (count($matrixValues) < 2) {
|
||||
throw new Exception('This operation requires at least 2 arguments');
|
||||
}
|
||||
|
||||
$matrix = array_shift($matrixValues);
|
||||
if (!is_object($matrix) || !($matrix instanceof Matrix)) {
|
||||
$matrix = new Matrix($matrix);
|
||||
}
|
||||
|
||||
$result = new Addition($matrix);
|
||||
|
||||
foreach ($matrixValues as $matrix) {
|
||||
$result->execute($matrix);
|
||||
}
|
||||
|
||||
return $result->result();
|
||||
}
|
||||
39
vendor/markbaker/matrix/classes/src/operations/directsum.php
vendored
Normal file
39
vendor/markbaker/matrix/classes/src/operations/directsum.php
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the matrix direct sum operation
|
||||
*
|
||||
* @copyright Copyright (c) 2018 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Matrix;
|
||||
|
||||
use Matrix\Operators\DirectSum;
|
||||
|
||||
/**
|
||||
* Adds two or more matrices
|
||||
*
|
||||
* @param mixed[] $matrixValues The matrices to add
|
||||
* @return Matrix
|
||||
* @throws Exception
|
||||
*/
|
||||
function directsum(...$matrixValues)
|
||||
{
|
||||
if (count($matrixValues) < 2) {
|
||||
throw new Exception('This operation requires at least 2 arguments');
|
||||
}
|
||||
|
||||
$matrix = array_shift($matrixValues);
|
||||
if (!is_object($matrix) || !($matrix instanceof Matrix)) {
|
||||
$matrix = new Matrix($matrix);
|
||||
}
|
||||
|
||||
$result = new DirectSum($matrix);
|
||||
|
||||
foreach ($matrixValues as $matrix) {
|
||||
$result->execute($matrix);
|
||||
}
|
||||
|
||||
return $result->result();
|
||||
}
|
||||
38
vendor/markbaker/matrix/classes/src/operations/divideby.php
vendored
Normal file
38
vendor/markbaker/matrix/classes/src/operations/divideby.php
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the matrix division operation
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Matrix;
|
||||
|
||||
use Matrix\Operators\Division;
|
||||
|
||||
/**
|
||||
* Divides two or more matrix numbers
|
||||
*
|
||||
* @param mixed[] $matrixValues The matrices to divide
|
||||
* @return Matrix
|
||||
*/
|
||||
function divideby(...$matrixValues)
|
||||
{
|
||||
if (count($matrixValues) < 2) {
|
||||
throw new \Exception('This function requires at least 2 arguments');
|
||||
}
|
||||
|
||||
$matrix = array_shift($matrixValues);
|
||||
if (!is_object($matrix) || !($matrix instanceof Matrix)) {
|
||||
$matrix = new Matrix($matrix);
|
||||
}
|
||||
|
||||
$result = new Division($matrix);
|
||||
|
||||
foreach ($matrixValues as $matrix) {
|
||||
$result->execute($matrix);
|
||||
}
|
||||
|
||||
return $result->result();
|
||||
}
|
||||
39
vendor/markbaker/matrix/classes/src/operations/divideinto.php
vendored
Normal file
39
vendor/markbaker/matrix/classes/src/operations/divideinto.php
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the matrix division operation
|
||||
*
|
||||
* @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Matrix;
|
||||
|
||||
use Matrix\Operators\Division;
|
||||
|
||||
/**
|
||||
* Divides two or more matrix numbers
|
||||
*
|
||||
* @param array of string|integer|float|Matrix $matrixValues The numbers to divide
|
||||
* @return Matrix
|
||||
*/
|
||||
function divideinto(...$matrixValues)
|
||||
{
|
||||
if (count($matrixValues) < 2) {
|
||||
throw new \Exception('This function requires at least 2 arguments');
|
||||
}
|
||||
$matrixValues = array_reverse($matrixValues);
|
||||
|
||||
$matrix = array_shift($matrixValues);
|
||||
if (!is_object($matrix) || !($matrix instanceof Matrix)) {
|
||||
$matrix = new Matrix($matrix);
|
||||
}
|
||||
|
||||
$result = new Division($matrix);
|
||||
|
||||
foreach ($matrixValues as $matrix) {
|
||||
$result->execute($matrix);
|
||||
}
|
||||
|
||||
return $result->result();
|
||||
}
|
||||
39
vendor/markbaker/matrix/classes/src/operations/multiply.php
vendored
Normal file
39
vendor/markbaker/matrix/classes/src/operations/multiply.php
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the matrix multiplication operation
|
||||
*
|
||||
* @copyright Copyright (c) 2018 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Matrix;
|
||||
|
||||
use Matrix\Operators\Multiplication;
|
||||
|
||||
/**
|
||||
* Multiplies two or more matrices
|
||||
*
|
||||
* @param mixed[] $matrixValues The matrices to multiply
|
||||
* @return Matrix
|
||||
* @throws Exception
|
||||
*/
|
||||
function multiply(...$matrixValues)
|
||||
{
|
||||
if (count($matrixValues) < 2) {
|
||||
throw new Exception('This operation requires at least 2 arguments');
|
||||
}
|
||||
|
||||
$matrix = array_shift($matrixValues);
|
||||
if (!is_object($matrix) || !($matrix instanceof Matrix)) {
|
||||
$matrix = new Matrix($matrix);
|
||||
}
|
||||
|
||||
$result = new Multiplication($matrix);
|
||||
|
||||
foreach ($matrixValues as $matrix) {
|
||||
$result->execute($matrix);
|
||||
}
|
||||
|
||||
return $result->result();
|
||||
}
|
||||
39
vendor/markbaker/matrix/classes/src/operations/subtract.php
vendored
Normal file
39
vendor/markbaker/matrix/classes/src/operations/subtract.php
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Function code for the matrix subtraction operation
|
||||
*
|
||||
* @copyright Copyright (c) 2018 Mark Baker (https://github.com/MarkBaker/PHPMatrix)
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
namespace Matrix;
|
||||
|
||||
use Matrix\Operators\Subtraction;
|
||||
|
||||
/**
|
||||
* Subtracts two or more matrices
|
||||
*
|
||||
* @param mixed[] $matrixValues The matrices to subtract
|
||||
* @return Matrix
|
||||
* @throws Exception
|
||||
*/
|
||||
function subtract(...$matrixValues)
|
||||
{
|
||||
if (count($matrixValues) < 2) {
|
||||
throw new Exception('This operation requires at least 2 arguments');
|
||||
}
|
||||
|
||||
$matrix = array_shift($matrixValues);
|
||||
if (!is_object($matrix) || !($matrix instanceof Matrix)) {
|
||||
$matrix = new Matrix($matrix);
|
||||
}
|
||||
|
||||
$result = new Subtraction($matrix);
|
||||
|
||||
foreach ($matrixValues as $matrix) {
|
||||
$result->execute($matrix);
|
||||
}
|
||||
|
||||
return $result->result();
|
||||
}
|
||||
68
vendor/markbaker/matrix/composer.json
vendored
Normal file
68
vendor/markbaker/matrix/composer.json
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
{
|
||||
"name": "markbaker/matrix",
|
||||
"type": "library",
|
||||
"description": "PHP Class for working with matrices",
|
||||
"keywords": ["matrix", "vector", "mathematics"],
|
||||
"homepage": "https://github.com/MarkBaker/PHPMatrix",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Mark Baker",
|
||||
"email": "mark@lange.demon.co.uk"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^5.6.0|^7.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.35|^5.4.0",
|
||||
"phpdocumentor/phpdocumentor":"2.*",
|
||||
"phpmd/phpmd": "2.*",
|
||||
"sebastian/phpcpd": "2.*",
|
||||
"phploc/phploc": "2.*",
|
||||
"squizlabs/php_codesniffer": "^3.3.0",
|
||||
"phpcompatibility/php-compatibility": "^8.0",
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3"
|
||||
},
|
||||
"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"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"style": [
|
||||
"phpcs --report-width=200 --report-summary --report-full classes/src/ --standard=PSR2 -n"
|
||||
],
|
||||
"test": [
|
||||
"phpunit"
|
||||
],
|
||||
"mess": [
|
||||
"phpmd classes/src/ xml codesize,unusedcode,design,naming -n"
|
||||
],
|
||||
"lines": [
|
||||
"phploc classes/src/ -n"
|
||||
],
|
||||
"cpd": [
|
||||
"phpcpd classes/src/ -n"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
19
vendor/markbaker/matrix/examples/test.php
vendored
Normal file
19
vendor/markbaker/matrix/examples/test.php
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
include __DIR__ . '/../classes/Bootstrap.php';
|
||||
|
||||
$grid1 = [
|
||||
[1, 3, 2],
|
||||
[2, 3, 1],
|
||||
];
|
||||
|
||||
$grid2 = [
|
||||
[1, 6],
|
||||
[0, 1],
|
||||
];
|
||||
|
||||
$matrix = new Matrix\Matrix($grid1);
|
||||
|
||||
$new = $matrix->directsum(new Matrix\Matrix($grid2));
|
||||
|
||||
var_dump($new);
|
||||
25
vendor/markbaker/matrix/license.md
vendored
Normal file
25
vendor/markbaker/matrix/license.md
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
The MIT License (MIT)
|
||||
=====================
|
||||
|
||||
Copyright © `2018` `Mark Baker`
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the “Software”), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user