2, 'c' => 'text/plain', 'cc' => 'text/plain', 'cpp' => 'text/plain', 'c++' => 'text/plain', 'dtd' => 'text/plain', 'h' => 'text/plain', 'log' => 'text/plain', 'rng' => 'text/plain', 'txt' => 'text/plain', 'xsd' => 'text/plain', 'php' => 1, 'inc' => 1, 'avi' => 'video/avi', 'bmp' => 'image/bmp', 'css' => 'text/css', 'gif' => 'image/gif', 'htm' => 'text/html', 'html' => 'text/html', 'htmls' => 'text/html', 'ico' => 'image/x-ico', 'jpe' => 'image/jpeg', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'js' => 'application/x-javascript', 'midi' => 'audio/midi', 'mid' => 'audio/midi', 'mod' => 'audio/mod', 'mov' => 'movie/quicktime', 'mp3' => 'audio/mp3', 'mpg' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'pdf' => 'application/pdf', 'png' => 'image/png', 'swf' => 'application/shockwave-flash', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'wav' => 'audio/wav', 'xbm' => 'image/xbm', 'xml' => 'text/xml', ); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); $basename = basename(__FILE__); if (!strpos($_SERVER['REQUEST_URI'], $basename)) { chdir(Extract_Phar::$temp); include $web; return; } $pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename)); if (!$pt || $pt == '/') { $pt = $web; header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt); exit; } $a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt); if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) { header('HTTP/1.0 404 Not Found'); echo "\n \n File Not Found<title>\n </head>\n <body>\n <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>"; exit; } $b = pathinfo($a); if (!isset($b['extension'])) { header('Content-Type: text/plain'); header('Content-Length: ' . filesize($a)); readfile($a); exit; } if (isset($mimes[$b['extension']])) { if ($mimes[$b['extension']] === 1) { include $a; exit; } if ($mimes[$b['extension']] === 2) { highlight_file($a); exit; } header('Content-Type: ' .$mimes[$b['extension']]); header('Content-Length: ' . filesize($a)); readfile($a); exit; } } class Extract_Phar { static $temp; static $origdir; const GZ = 0x1000; const BZ2 = 0x2000; const MASK = 0x3000; const START = 'vendor/autoload.php'; const LEN = 6695; static function go($return = false) { $fp = fopen(__FILE__, 'rb'); fseek($fp, self::LEN); $L = unpack('V', $a = (binary)fread($fp, 4)); $m = (binary)''; do { $read = 8192; if ($L[1] - strlen($m) < 8192) { $read = $L[1] - strlen($m); } $last = (binary)fread($fp, $read); $m .= $last; } while (strlen($last) && strlen($m) < $L[1]); if (strlen($m) < $L[1]) { die('ERROR: manifest length read was "' . strlen($m) .'" should be "' . $L[1] . '"'); } $info = self::_unpack($m); $f = $info['c']; if ($f & self::GZ) { if (!function_exists('gzinflate')) { die('Error: zlib extension is not enabled -' . ' gzinflate() function needed for zlib-compressed .phars'); } } if ($f & self::BZ2) { if (!function_exists('bzdecompress')) { die('Error: bzip2 extension is not enabled -' . ' bzdecompress() function needed for bz2-compressed .phars'); } } $temp = self::tmpdir(); if (!$temp || !is_writable($temp)) { $sessionpath = session_save_path(); if (strpos ($sessionpath, ";") !== false) $sessionpath = substr ($sessionpath, strpos ($sessionpath, ";")+1); if (!file_exists($sessionpath) || !is_dir($sessionpath)) { die('Could not locate temporary directory to extract phar'); } $temp = $sessionpath; } $temp .= '/pharextract/'.basename(__FILE__, '.phar'); self::$temp = $temp; self::$origdir = getcwd(); @mkdir($temp, 0777, true); $temp = realpath($temp); if (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) { self::_removeTmpFiles($temp, getcwd()); @mkdir($temp, 0777, true); @file_put_contents($temp . '/' . md5_file(__FILE__), ''); foreach ($info['m'] as $path => $file) { $a = !file_exists(dirname($temp . '/' . $path)); @mkdir(dirname($temp . '/' . $path), 0777, true); clearstatcache(); if ($path[strlen($path) - 1] == '/') { @mkdir($temp . '/' . $path, 0777); } else { file_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp)); @chmod($temp . '/' . $path, 0666); } } } chdir($temp); if (!$return) { include self::START; } } static function tmpdir() { if (strpos(PHP_OS, 'WIN') !== false) { if ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) { return $var; } if (is_dir('/temp') || mkdir('/temp')) { return realpath('/temp'); } return false; } if ($var = getenv('TMPDIR')) { return $var; } return realpath('/tmp'); } static function _unpack($m) { $info = unpack('V', substr($m, 0, 4)); $l = unpack('V', substr($m, 10, 4)); $m = substr($m, 14 + $l[1]); $s = unpack('V', substr($m, 0, 4)); $o = 0; $start = 4 + $s[1]; $ret['c'] = 0; for ($i = 0; $i < $info[1]; $i++) { $len = unpack('V', substr($m, $start, 4)); $start += 4; $savepath = substr($m, $start, $len[1]); $start += $len[1]; $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24))); $ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3] & 0xffffffff); $ret['m'][$savepath][7] = $o; $o += $ret['m'][$savepath][2]; $start += 24 + $ret['m'][$savepath][5]; $ret['c'] |= $ret['m'][$savepath][4] & self::MASK; } return $ret; } static function extractFile($path, $entry, $fp) { $data = ''; $c = $entry[2]; while ($c) { if ($c < 8192) { $data .= @fread($fp, $c); $c = 0; } else { $c -= 8192; $data .= @fread($fp, 8192); } } if ($entry[4] & self::GZ) { $data = gzinflate($data); } elseif ($entry[4] & self::BZ2) { $data = bzdecompress($data); } if (strlen($data) != $entry[0]) { die("Invalid internal .phar file (size error " . strlen($data) . " != " . $stat[7] . ")"); } if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) { die("Invalid internal .phar file (checksum error)"); } return $data; } static function _removeTmpFiles($temp, $origdir) { chdir($temp); foreach (glob('*') as $f) { if (file_exists($f)) { is_dir($f) ? @rmdir($f) : @unlink($f); if (file_exists($f) && is_dir($f)) { self::_removeTmpFiles($f, getcwd()); } } } @rmdir($temp); clearstatcache(); chdir($origdir); } } Extract_Phar::go(); __HALT_COMPILER(); ?> ©�� ������������������src/MatrixException.phpm���k=Vm���ÌÍ4 ¶���������src/LUDecomposition.php��k=V��/Õ}f¶���������src/Matrix.php,C��k=V,C��‹Aä¶���������src����k=V��������¶���������vendor/autoload.php·���k=V·���՜ֶ���������vendor����k=V��������¶������!���vendor/composer/autoload_psr4.phpÏ���k=VÏ���†“þ?¶���������vendor/composer/ClassLoader.php”0��k=V”0��¸Lh¦¶������%���vendor/composer/autoload_classmap.php•��k=V•��9ZÀý¶���������vendor/composer/LICENSE3��k=V3��fýÞX¶���������vendor/composer����k=V��������¶������'���vendor/composer/autoload_namespaces.php•���k=V•���tÛ!×¶������!���vendor/composer/autoload_real.phpv��k=Vv��ïûYö¶������<?php namespace mcordingley\LinearAlgebra; use Exception; class MatrixException extends Exception { }<?php namespace mcordingley\LinearAlgebra; /** * Creates an LU Decomposition using Crout's Method and provides methods for using it. * * LU Decomposition references: * @reference: Numerical Recipes, 3rd edition (section 2.3) http://nrbook.com * @reference: http://www.cs.rpi.edu/~flaherje/pdf/lin6.pdf * * Crout's Method reference: * @reference: http://www.physics.utah.edu/~detar/phys6720/handouts/crout.txt * * Code reference: * @reference: http://rosettacode.org/wiki/LU_decomposition */ class LUDecomposition extends Matrix { protected $parity = 1; // 1 if the number of row interchanges is even, -1 if it is odd. (used for determinants) protected $permutations; // Stores a vector representation of the row permutations performed on this matrix. /** * Constructor * * Copies the matrix, then performs the LU Decomposition. * * @param \mcordingley\LinearAlgebra\Matrix The matrix to decompose. */ public function __construct(\mcordingley\LinearAlgebra\Matrix $matrix) { // Copy the matrix $matrix->map(function($element, $i, $j, $matrix){ $this->internal[$i][$j] = $element; }); $this->rowCount = $matrix->rows; $this->columnCount = $matrix->columns; if( ! $this->isSquare()) throw new MatrixException("Matrix is not square."); $this->LUDecomp(); } /** * Performs the LU Decomposition. * * This uses Crout's method with partial (row) pivoting and implicit scaling * to perform the decomposition in-place on a copy of the original matrix. */ private function LUDecomp() { $scaling = array(); $this->parity = 1; // start parity at +1 (parity is "even" for zero row interchanges) $n = $this->rows; $p =& $this->permutations; // We want to find the largest element in each row for scaling. for ($i = 0; $i < $n; ++$i) { $biggest = 0; for ($j = 0; $j < $n; ++$j) { $temp = abs($this->internal[$i][$j]); $biggest = max($temp, $biggest); } if ($biggest == 0) throw new MatrixException("Matrix is singular."); $scaling[$i] = 1 / $biggest; $p[$i] = $i; // Initialize permutations vector } // Now we find the LU decomposition. This is the outer loop over diagonal elements. for($k = 0; $k < $n; ++$k) { // Search for the best (biggest) pivot element $biggest = 0; $max_row_index = $k; for($i = $k; $i < $n; ++$i) { $temp = $scaling[$i] * abs($this->internal[$i][$k]); if($temp > $biggest) { $biggest = $temp; $max_row_index = $i; } } // Perform the row pivot and store in the permuations vector if($k != $max_row_index) { $this->rowPivot($k, $max_row_index); $temp = $p[$k]; $p[$k] = $p[$max_row_index]; $p[$max_row_index] = $temp; $this->parity = -$this->parity; // flip parity } if ($this->internal[$k][$k] == 0) throw new MatrixException("Matrix is singular."); // Crout's algorithm for ($i = $k + 1; $i < $n; ++$i) { // Divide by the pivot element $this->internal[$i][$k] = $this->internal[$i][$k] / $this->internal[$k][$k]; // Subtract from each element in the sub-matrix for ($j = $k + 1; $j < $n; ++$j) { $this->internal[$i][$j] = $this->internal[$i][$j] - $this->internal[$i][$k] * $this->internal[$k][$j]; } } } } /** * Returns the determinant of the LU decomposition * * @see \mcordingley\LinearAlgebra\Matrix::determinant() * @return double */ public function determinant() { $n = $this->rows; $determinant = $this->parity; // Start with +1 for an even # of row swaps, -1 for an odd # // The determinant is simply the product of the diagonal elements, with sign given // by the number of row permutations (-1 for odd, +1 for even) for($i = 0; $i < $n; ++$i) { $determinant *= $this->get($i, $i); } return $determinant; } /** * Swaps $thisRow for $thatRow * * @param int $thisRow * @param int $thatRow */ private function rowPivot($thisRow, $thatRow) { $temp = $this->internal[$thisRow]; $this->internal[$thisRow]= $this->internal[$thatRow]; $this->internal[$thatRow] = $temp; } /** * Solves a linear set of equations in the form A * x = b for x, where A * is the decomposed matrix of coefficients (now P*L*U), $x is the vector * of unknowns, and $b is the vector of knowns. * * @param array $b - vector of knowns * @return array $x - the solution vector */ public function solve(array $b) { $n = $this->rows; if(count($b) !== $n) { throw new MatrixException ('The knowns vector must be the same size as the coefficient matrix.'); } $y = array(); // L*y = b $x = array(); // U*x = y $skip = TRUE; // Solve L * y = b for y (forward substitution) for($i = 0; $i < $n; ++$i) { $this_b = $b[$this->permutations[$i]]; // Unscramble the permutations if($skip && $this_b == 0) { // Leading zeroes in b give zeroes in y. $y[$i] = 0; } else { if($skip) $skip = FALSE; // We found a non-zero element, so don't skip any more. $y[$i] = $this_b; for($j = 0; $j < $i; ++$j) { $y[$i] = $y[$i] - $this->get($i, $j) * $y[$j]; } } } // Solve U * x = y for x (backward substitution) for($i = $n - 1; $i >= 0; --$i) { $x[$i] = $y[$i]; for($j = $i + 1; $j < $n; ++$j) { $x[$i] = $x[$i] - $this->get($i, $j) * $x[$j]; } $x[$i] = $x[$i] / $this->get($i, $i); // Keep division out of the inner loop } return $x; } /** * Finds the inverse matrix using the LU decomposition. * * Workes by solving LUX = B for X where X is the inverse matrix of same rank and order as LU, * and B is an identity matrix, also of the same rank and order. * * overrides \mcordingley\LinearAlgebra\Matrix::inverse() * * @return \mcordingley\LinearAlgebra\Matrix - The inverse matrix */ public function inverse() { $inverse = array(); // Get size of matrix $n = $this->rows; $b = array_fill(0, $n, 0); // initialize empty vector // For each j from 0 to n-1 for($j = 0; $j < $n; ++$j) { // this is the jth column of the identity matrix $b[$j] = 1; // get the solution vector and copy to the jth column of the inverse matrix $x = $this->solve($b); for($i = 0; $i < $n; ++$i) { $inverse[$i][$j] = $x[$i]; } $b[$j] = 0; // Get the vector ready for the next column. } return new Matrix($inverse); } /** * Utility method for debugging - echos the * matrix in easy-to-read format. */ private function printMatrix(array $matrix) { $n = count($matrix); foreach($matrix as $row) { foreach($row as $column){ echo $column.', '; } echo "\n"; } } }<?php namespace mcordingley\LinearAlgebra; use ArrayAccess; use Exception; class Matrix implements ArrayAccess { /** * Number of columns in the matrix. * * @var int */ protected $columnCount; /** * Number of rows in the matrix. * @var int */ protected $rowCount; /** * Internal array for the matrix data that this class wraps. * * @var array */ protected $internal; /** * LU Decomposition of this matrix, lazily created as needed. * * @var LUDecomposition */ protected $LU = null; //LU decomposition, stored so we only need to build it once. /** * __construct * * Example: * $transform = new Matrix([ * [0, 1, 2], * [3, 4, 5], * [6, 7, 8] * ]); * * @param array $literal Array representation of the matrix. */ public function __construct(array $literal) { if (!$this->isLiteralValid($literal)) { throw new MatrixException('Invalid array provided: ' . print_r($literal, true)); } $this->internal = $literal; $this->rowCount = count($literal); $this->columnCount = count($literal[0]); } /** * __get * * Magic method to make the public "properties" read-only. * * @param string $property * @return mixed */ public function __get($property) { switch ($property) { case 'columns': return $this->columnCount; case 'rows': return $this->rowCount; default: return null; } } public function __toString() { $rowStrings = array_map(function ($row) { return '[' . implode(', ', $row) . ']'; }, $this->internal); return '[' . implode(', ', $rowStrings) . ']'; } /** * add * * Adds either another matrix or a scalar to the current matrix, returning * a new matrix instance. * * @param mixed $value Matrix or scalar to add to this matrix * @return self New matrix with the added value * @throws MatrixException */ public function add($value) { if ($value instanceof Matrix) { if ($this->rows != $value->rows || $this->columns != $value->columns) { throw new MatrixException('Cannot add two matrices of different size.'); } return $this->map(function($element, $i, $j) use ($value) { return $element + $value->get($i, $j); }); } else { return $this->map(function($element) use ($value) { return $element + $value; }); } } /** * adjoint * * Creates and returns a new matrix that is the adjoint of this matrix. * * @return self * @throws MatrixException */ public function adjoint() { if (!$this->isSquare($this)) { throw new MatrixException('Adjoints can only be called on square matrices: ' . print_r($this->internal, true)); } return $this->inverse()->multiply($this->determinant()); } /** * determinant * * @return float The matrix's determinant */ public function determinant() { if (!$this->isSquare($this)) { throw new MatrixException('Determinants can only be called on square matrices: ' . print_r($this->internal, true)); } // Base case for a 1 by 1 matrix if ($this->rows == 1) { return $this->get(0, 0); } return $this->getLUDecomp()->determinant(); } /** * equals * * Checks to see if two matrices are equal in value. * * @param Matrix $matrixB * @return boolean True if equal. False otherwise. */ public function equals(Matrix $matrixB) { if ($this->rowCount != $matrixB->rowCount || $this->columnCount != $matrixB->columnCount) { return false; } for ($i = $this->rowCount; $i--; ) { for ($j = $this->columnCount; $j--; ) { if ($this->get($i, $j) != $matrixB->get($i, $j)) { return false; } } } return true; } /** * get * * @param int $row Which zero-based row index to access. * @param int $column Which zero-based column index to access. * @return float */ public function get($row, $column) { return $this->internal[$row][$column]; } /** * identity * * Creates a new identity matrix of the specified size. * * @param int $size How many rows and columns the identity matrix should have * @return self */ public static function identity($size) { $literal = array(); for ($i = 0; $i < $size; ++$i) { $literal[] = array(); for ($j = 0; $j < $size; ++$j) { $literal[$i][] = ($i == $j) ? 1 : 0; } } return new static($literal); } /** * inverse * * Creates and returns a new matrix that is the inverse of this matrix. * * @return self * @throws MatrixException */ public function inverse() { if (!$this->isSquare($this)) { throw new MatrixException('Inverse can only be called on square matrices: ' . print_r($this->internal, true)); } if ($this->determinant() == 0) { throw new MatrixException('This matrix has a zero determinant and is therefore not invertable: ' . print_r($this->internal, true)); } if ($this->isSymmetric()) { try { return $this->choleskyInverse(); } catch (Exception $exception) { // Allow this to fall through to the more general algorithm. } } // Use LU decomposition for the general case. return $this->getLUDecomp()->inverse(); } /** * isSquare * * @return boolean True if the matrix is square, false otherwise. */ public function isSquare() { return $this->rows == $this->columns; } /** * isSymmetric * * @return boolean */ public function isSymmetric() { if (!$this->isSquare()) { return false; } for ($i = 0; $i < $this->rows; ++$i) { for ($j = 0; $j < $this->columns; ++$j) { if ($i == $j) { continue; } if ($this->get($i, $j) != $this->get($j, $i)) { return false; } } } return true; } /** * map * * Iterates over the current matrix with a callback function to return a new * matrix with the mapped values. $callback takes four arguments: * - The current matrix element * - The current row * - The current column * - The matrix being iterated over * * @param callable $callback A function that returns the computed new values. * @return self */ public function map(callable $callback) { $literal = array(); for ($i = 0; $i < $this->rows; $i++) { $row = array(); for ($j = 0; $j < $this->columns; $j++) { $row[] = $callback($this->get($i, $j), $i, $j, $this); } $literal[] = $row; } return new static($literal); } /** * multiply * * Multiplies either another matrix or a scalar with the current matrix, * returning a new matrix instance. * * @param mixed $value Matrix or scalar to multiply with this matrix * @return self * @throws MatrixException */ public function multiply($value) { if ($value instanceof Matrix) { // TODO: This is another good candidate for optimization. Too many loops! if ($this->columns != $value->rows) { throw new MatrixException('Cannot multiply matrices of these sizes.'); } $literal = array(); for ($i = 0; $i < $this->rows; $i++) { $row = array(); for ($j = 0; $j < $value->columns; $j++) { $sum = 0; for ($k = 0; $k < $this->columns; $k++) { $sum += $this->get($i, $k) * $value->get($k, $j); } $row[] = $sum; } $literal[] = $row; } return new static($literal); } else { return $this->map(function($element) use ($value) { return $element * $value; }); } } /** * submatrix * * Returns a new matrix with the selected row and column removed, useful for * calculating determinants or other recursive operations on matrices. * * @param int $row Row to remove, null to remove no row. * @param int $column Column to remove, null to remove no column. * @return self */ public function submatrix($row = null, $column = null) { $literal = array(); for ($i = 0; $i < $this->rows; $i++) { if ($i === $row) { continue; } $rowLiteral = array(); for ($j = 0; $j < $this->columns; $j++) { if ($j === $column) { continue; } $rowLiteral[] = $this->get($i, $j); } $literal[] = $rowLiteral; } return new static($literal); } /** * subtract * * Subtracts either another matrix or a scalar from the current matrix, * returning a new matrix instance. * * @param mixed $value Matrix or scalar to subtract from this matrix * @return self * @throws MatrixException */ public function subtract($value) { if ($value instanceof Matrix) { if ($this->rows != $value->rows || $this->columns != $value->columns) { throw new MatrixException('Cannot subtract two matrices of different size.'); } return $this->map(function($element, $i, $j) use ($value) { return $element - $value->get($i, $j); }); } else { return $this->map(function($element) use ($value) { return $element - $value; }); } } /** * toArray * * @return array */ public function toArray() { return $this->internal; } /** * trace * * Sums the main diagonal values of a square matrix. * * @return float */ public function trace() { if (!$this->isSquare($this)) { throw new MatrixException('Trace can only be called on square matrices: ' . print_r($this->internal, true)); } $trace = 0; for ($i = 0; $i < $this->rows; $i++) { $trace += $this->get($i, $i); } return $trace; } /** * transpose * * Creates and returns a new matrix that is a transposition of this matrix. * * @return self */ public function transpose() { $literal = array(); for ($i = 0; $i < $this->columns; $i++) { $literal[] = array(); for ($j = 0; $j < $this->rows; $j++) { $literal[$i][] = $this->get($j, $i); } } return new static($literal); } // // Array Access Interface // public function offsetExists($offset) { return isset($this->internal[$offset]); } public function offsetGet($offset) { return $this->internal[$offset]; } public function offsetSet($offset, $value) { throw new MatrixException('Attempt to set a value on a matrix. Matrix instances are immutable.'); } public function offsetUnset($offset) { throw new MatrixException('Attempt to unset a value on a matrix. Matrix instances are immutable.'); } /** * choleskyDecomposition * * Returns the Cholesky decomposition of a matrix. * Matrix must be square and symmetrical for this to work. * Returns just the lower triangular matrix, as the upper is a mirror image * of that. * * @return self * @throws MatrixException */ protected function choleskyDecomposition() { $literal = $this->toArray(); $rows = count($literal); $ztol = 1.0e-5; // Zero-fill an array-representation of a matrix $t = array(); for ($i = 0; $i < $rows; ++$i) { $t[] = array(); for ($j = 0; $j < $rows; ++$j) { $t[$i][] = 0; } } for ($i = 0; $i < $rows; ++$i) { $S = 0; for ($k = 0; $k < $i; ++$k) { $S += pow($t[$k][$i], 2); } $d = $this->get($i, $i) - $S; if (abs($d) < $ztol) { $t[$i][$i] = 0; } else { if ($d < 0) { throw new MatrixException("Matrix not positive-definite"); } $t[$i][$i] = sqrt($d); } for ($j = $i + 1; $j < $rows; ++$j) { $S = 0; for ($k = 0; $k < $i; ++$i) { $S += $t[$k][$i] * $t[$k][$j]; } if (abs($S) < $ztol) { $S = 0; } try { $t[$i][$j] = ($literal[$i][$j] - $S) / $t[$i][$i]; } catch (Exception $exception) { throw new MatrixException("Zero diagonal"); } } } return new self($t); } /** * choleskyInverse * * @return self */ protected function choleskyInverse() { //Translated from: http://adorio-research.org/wordpress/?p=4560 $t = $this->choleskyDecomposition()->toArray(); $B = array(); for ($i = 0; $i < $this->rowCount; ++$i) { $B[] = array(); for ($j = 0; $j < $this->rowCount; ++$j) { $B[$i][] = 0; } } for ($j = $this->rowCount; $j--; ) { $tjj = $t[$j][$j]; $S = 0; for ($k = $j + 1; $k < $this->rowCount; ++$k) { $S += $t[$j][$k] * $B[$j][$k]; } $B[$j][$j] = 1 / pow($tjj, 2) - $S / $tjj; for ($i = $j; $i--; ) { $sum = 0; for ($k = $i + 1; $k < $this->rowCount; ++$k) { $sum += $t[$i][$k] * $B[$k][$j]; } $B[$j][$i] = $B[$i][$j] = -$sum / $t[$i][$i]; } } return new self($B); } /** * getLUDecomp * * Lazy-loads the LU decomposition. If it has already been built for this * matrix, it returns the existing one. Otherwise, it creates a new one. * * @return LUDecomposition */ protected function getLUDecomp() { if (!$this->LU) { $this->LU = new LUDecomposition($this); } return $this->LU; } /** * isLiteralValid * * Tests an array representation of a matrix to see if it would make a valid matrix * * @param array $literal * @return boolean */ protected function isLiteralValid(array $literal) { // Matrix must have at least one row if (!count($literal)) { return false; } // Matrix must have at least one column if (!count($literal[0])) { return false; } // Matrix must have the same number of columns in each row $lastRow = false; foreach ($literal as $row) { $thisRow = count($row); if ($lastRow !== false && $lastRow != $thisRow) { return false; } $lastRow = $thisRow; } return true; } }<?php // autoload.php @generated by Composer require_once __DIR__ . '/composer' . '/autoload_real.php'; return ComposerAutoloaderInit54294bf10d2ba2661e7d057dc0168fe0::getLoader(); <?php // autoload_psr4.php @generated by Composer $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( 'mcordingley\\LinearAlgebra\\' => array($baseDir . '/src'), ); <?php /* * This file is part of Composer. * * (c) Nils Adermann <naderman@naderman.de> * Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Composer\Autoload; /** * ClassLoader implements a PSR-0 class loader * * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md * * $loader = new \Composer\Autoload\ClassLoader(); * * // register classes with namespaces * $loader->add('Symfony\Component', __DIR__.'/component'); * $loader->add('Symfony', __DIR__.'/framework'); * * // activate the autoloader * $loader->register(); * * // to enable searching the include path (eg. for PEAR packages) * $loader->setUseIncludePath(true); * * In this example, if you try to use a class in the Symfony\Component * namespace or one of its children (Symfony\Component\Console for instance), * the autoloader will first look for the class under the component/ * directory, and it will then fallback to the framework/ directory if not * found before giving up. * * This class is loosely based on the Symfony UniversalClassLoader. * * @author Fabien Potencier <fabien@symfony.com> * @author Jordi Boggiano <j.boggiano@seld.be> */ class ClassLoader { // PSR-4 private $prefixLengthsPsr4 = array(); private $prefixDirsPsr4 = array(); private $fallbackDirsPsr4 = array(); // PSR-0 private $prefixesPsr0 = array(); private $fallbackDirsPsr0 = array(); private $useIncludePath = false; private $classMap = array(); private $classMapAuthoritative = false; public function getPrefixes() { if (!empty($this->prefixesPsr0)) { return call_user_func_array('array_merge', $this->prefixesPsr0); } return array(); } public function getPrefixesPsr4() { return $this->prefixDirsPsr4; } public function getFallbackDirs() { return $this->fallbackDirsPsr0; } public function getFallbackDirsPsr4() { return $this->fallbackDirsPsr4; } public function getClassMap() { return $this->classMap; } /** * @param array $classMap Class to filename map */ public function addClassMap(array $classMap) { if ($this->classMap) { $this->classMap = array_merge($this->classMap, $classMap); } else { $this->classMap = $classMap; } } /** * Registers a set of PSR-0 directories for a given prefix, either * appending or prepending to the ones previously set for this prefix. * * @param string $prefix The prefix * @param array|string $paths The PSR-0 root directories * @param bool $prepend Whether to prepend the directories */ public function add($prefix, $paths, $prepend = false) { if (!$prefix) { if ($prepend) { $this->fallbackDirsPsr0 = array_merge( (array) $paths, $this->fallbackDirsPsr0 ); } else { $this->fallbackDirsPsr0 = array_merge( $this->fallbackDirsPsr0, (array) $paths ); } return; } $first = $prefix[0]; if (!isset($this->prefixesPsr0[$first][$prefix])) { $this->prefixesPsr0[$first][$prefix] = (array) $paths; return; } if ($prepend) { $this->prefixesPsr0[$first][$prefix] = array_merge( (array) $paths, $this->prefixesPsr0[$first][$prefix] ); } else { $this->prefixesPsr0[$first][$prefix] = array_merge( $this->prefixesPsr0[$first][$prefix], (array) $paths ); } } /** * Registers a set of PSR-4 directories for a given namespace, either * appending or prepending to the ones previously set for this namespace. * * @param string $prefix The prefix/namespace, with trailing '\\' * @param array|string $paths The PSR-0 base directories * @param bool $prepend Whether to prepend the directories * * @throws \InvalidArgumentException */ public function addPsr4($prefix, $paths, $prepend = false) { if (!$prefix) { // Register directories for the root namespace. if ($prepend) { $this->fallbackDirsPsr4 = array_merge( (array) $paths, $this->fallbackDirsPsr4 ); } else { $this->fallbackDirsPsr4 = array_merge( $this->fallbackDirsPsr4, (array) $paths ); } } elseif (!isset($this->prefixDirsPsr4[$prefix])) { // Register directories for a new namespace. $length = strlen($prefix); if ('\\' !== $prefix[$length - 1]) { throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); } $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; $this->prefixDirsPsr4[$prefix] = (array) $paths; } elseif ($prepend) { // Prepend directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( (array) $paths, $this->prefixDirsPsr4[$prefix] ); } else { // Append directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( $this->prefixDirsPsr4[$prefix], (array) $paths ); } } /** * Registers a set of PSR-0 directories for a given prefix, * replacing any others previously set for this prefix. * * @param string $prefix The prefix * @param array|string $paths The PSR-0 base directories */ public function set($prefix, $paths) { if (!$prefix) { $this->fallbackDirsPsr0 = (array) $paths; } else { $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; } } /** * Registers a set of PSR-4 directories for a given namespace, * replacing any others previously set for this namespace. * * @param string $prefix The prefix/namespace, with trailing '\\' * @param array|string $paths The PSR-4 base directories * * @throws \InvalidArgumentException */ public function setPsr4($prefix, $paths) { if (!$prefix) { $this->fallbackDirsPsr4 = (array) $paths; } else { $length = strlen($prefix); if ('\\' !== $prefix[$length - 1]) { throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); } $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; $this->prefixDirsPsr4[$prefix] = (array) $paths; } } /** * Turns on searching the include path for class files. * * @param bool $useIncludePath */ public function setUseIncludePath($useIncludePath) { $this->useIncludePath = $useIncludePath; } /** * Can be used to check if the autoloader uses the include path to check * for classes. * * @return bool */ public function getUseIncludePath() { return $this->useIncludePath; } /** * Turns off searching the prefix and fallback directories for classes * that have not been registered with the class map. * * @param bool $classMapAuthoritative */ public function setClassMapAuthoritative($classMapAuthoritative) { $this->classMapAuthoritative = $classMapAuthoritative; } /** * Should class lookup fail if not found in the current class map? * * @return bool */ public function isClassMapAuthoritative() { return $this->classMapAuthoritative; } /** * Registers this instance as an autoloader. * * @param bool $prepend Whether to prepend the autoloader or not */ public function register($prepend = false) { spl_autoload_register(array($this, 'loadClass'), true, $prepend); } /** * Unregisters this instance as an autoloader. */ public function unregister() { spl_autoload_unregister(array($this, 'loadClass')); } /** * Loads the given class or interface. * * @param string $class The name of the class * @return bool|null True if loaded, null otherwise */ public function loadClass($class) { if ($file = $this->findFile($class)) { includeFile($file); return true; } } /** * Finds the path to the file where the class is defined. * * @param string $class The name of the class * * @return string|false The path if found, false otherwise */ public function findFile($class) { // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 if ('\\' == $class[0]) { $class = substr($class, 1); } // class map lookup if (isset($this->classMap[$class])) { return $this->classMap[$class]; } if ($this->classMapAuthoritative) { return false; } $file = $this->findFileWithExtension($class, '.php'); // Search for Hack files if we are running on HHVM if ($file === null && defined('HHVM_VERSION')) { $file = $this->findFileWithExtension($class, '.hh'); } if ($file === null) { // Remember that this class does not exist. return $this->classMap[$class] = false; } return $file; } private function findFileWithExtension($class, $ext) { // PSR-4 lookup $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; $first = $class[0]; if (isset($this->prefixLengthsPsr4[$first])) { foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { if (0 === strpos($class, $prefix)) { foreach ($this->prefixDirsPsr4[$prefix] as $dir) { if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { return $file; } } } } } // PSR-4 fallback dirs foreach ($this->fallbackDirsPsr4 as $dir) { if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { return $file; } } // PSR-0 lookup if (false !== $pos = strrpos($class, '\\')) { // namespaced class name $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); } else { // PEAR-like class name $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; } if (isset($this->prefixesPsr0[$first])) { foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { if (0 === strpos($class, $prefix)) { foreach ($dirs as $dir) { if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { return $file; } } } } } // PSR-0 fallback dirs foreach ($this->fallbackDirsPsr0 as $dir) { if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { return $file; } } // PSR-0 include paths. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { return $file; } } } /** * Scope isolated include. * * Prevents access to $this/self from included files. */ function includeFile($file) { include $file; } <?php // autoload_classmap.php @generated by Composer $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( 'mcordingley\\LinearAlgebra\\LUDecomposition' => $baseDir . '/src/LUDecomposition.php', 'mcordingley\\LinearAlgebra\\Matrix' => $baseDir . '/src/Matrix.php', 'mcordingley\\LinearAlgebra\\MatrixException' => $baseDir . '/src/MatrixException.php', ); Copyright (c) 2015 Nils Adermann, Jordi Boggiano 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. <?php // autoload_namespaces.php @generated by Composer $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( ); <?php // autoload_real.php @generated by Composer class ComposerAutoloaderInit54294bf10d2ba2661e7d057dc0168fe0 { private static $loader; public static function loadClassLoader($class) { if ('Composer\Autoload\ClassLoader' === $class) { require __DIR__ . '/ClassLoader.php'; } } public static function getLoader() { if (null !== self::$loader) { return self::$loader; } spl_autoload_register(array('ComposerAutoloaderInit54294bf10d2ba2661e7d057dc0168fe0', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); spl_autoload_unregister(array('ComposerAutoloaderInit54294bf10d2ba2661e7d057dc0168fe0', 'loadClassLoader')); $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { $loader->set($namespace, $path); } $map = require __DIR__ . '/autoload_psr4.php'; foreach ($map as $namespace => $path) { $loader->setPsr4($namespace, $path); } $classMap = require __DIR__ . '/autoload_classmap.php'; if ($classMap) { $loader->addClassMap($classMap); } $loader->register(true); return $loader; } } function composerRequire54294bf10d2ba2661e7d057dc0168fe0($file) { require $file; } BnkôQì ß]EéË˲Â<›”���GBMB