Memory and Performance Improvements
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@64204 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
4da85678d4
commit
9641c16df0
|
@ -30,12 +30,6 @@
|
|||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,6 +25,14 @@
|
|||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
|
||||
|
||||
class PHPExcel_Autoloader
|
||||
{
|
||||
public static function Register() {
|
||||
|
|
|
@ -33,19 +33,9 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Matrix */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/Matrix.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation (Singleton)
|
||||
*
|
||||
|
@ -199,9 +189,9 @@ class PHPExcel_Calculation {
|
|||
|
||||
|
||||
// Constant conversion from text name/value to actual (datatyped) value
|
||||
private static $_ExcelConstants = array('TRUE' => True,
|
||||
'FALSE' => False,
|
||||
'NULL' => Null
|
||||
private static $_ExcelConstants = array('TRUE' => true,
|
||||
'FALSE' => false,
|
||||
'NULL' => null
|
||||
);
|
||||
|
||||
// PHPExcel functions
|
||||
|
@ -1718,9 +1708,9 @@ class PHPExcel_Calculation {
|
|||
($returnType == self::RETURN_ARRAY_AS_ERROR) ||
|
||||
($returnType == self::RETURN_ARRAY_AS_ARRAY)) {
|
||||
self::$returnArrayAsType = $returnType;
|
||||
return True;
|
||||
return true;
|
||||
}
|
||||
return False;
|
||||
return false;
|
||||
} // function setExcelCalendar()
|
||||
|
||||
|
||||
|
@ -1882,7 +1872,7 @@ class PHPExcel_Calculation {
|
|||
}
|
||||
|
||||
self::$functionReplaceFromExcel = self::$functionReplaceToExcel =
|
||||
self::$functionReplaceFromLocale = self::$functionReplaceToLocale = NULL;
|
||||
self::$functionReplaceFromLocale = self::$functionReplaceToLocale = null;
|
||||
self::$_localeLanguage = $locale;
|
||||
return true;
|
||||
}
|
||||
|
@ -1896,9 +1886,9 @@ class PHPExcel_Calculation {
|
|||
for ($i = 0; $i < $strlen; ++$i) {
|
||||
$chr = mb_substr($formula,$i,1);
|
||||
switch ($chr) {
|
||||
case '{' : $inBraces = True;
|
||||
case '{' : $inBraces = true;
|
||||
break;
|
||||
case '}' : $inBraces = False;
|
||||
case '}' : $inBraces = false;
|
||||
break;
|
||||
case $fromSeparator :
|
||||
if (!$inBraces) {
|
||||
|
@ -1912,7 +1902,7 @@ class PHPExcel_Calculation {
|
|||
private static function _translateFormula($from,$to,$formula,$fromSeparator,$toSeparator) {
|
||||
// Convert any Excel function names to the required language
|
||||
if (self::$_localeLanguage !== 'en_us') {
|
||||
$inBraces = False;
|
||||
$inBraces = false;
|
||||
// If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators
|
||||
if (strpos($formula,'"') !== false) {
|
||||
// So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded
|
||||
|
@ -1938,8 +1928,8 @@ class PHPExcel_Calculation {
|
|||
return $formula;
|
||||
}
|
||||
|
||||
private static $functionReplaceFromExcel = NULL;
|
||||
private static $functionReplaceToLocale = NULL;
|
||||
private static $functionReplaceFromExcel = null;
|
||||
private static $functionReplaceToLocale = null;
|
||||
|
||||
public function _translateFormulaToLocale($formula) {
|
||||
if (is_null(self::$functionReplaceFromExcel)) {
|
||||
|
@ -1967,8 +1957,8 @@ class PHPExcel_Calculation {
|
|||
} // function _translateFormulaToLocale()
|
||||
|
||||
|
||||
private static $functionReplaceFromLocale = NULL;
|
||||
private static $functionReplaceToExcel = NULL;
|
||||
private static $functionReplaceFromLocale = null;
|
||||
private static $functionReplaceToExcel = null;
|
||||
|
||||
public function _translateFormulaToEnglish($formula) {
|
||||
if (is_null(self::$functionReplaceFromLocale)) {
|
||||
|
@ -2610,7 +2600,7 @@ class PHPExcel_Calculation {
|
|||
// should be null in a function call
|
||||
// The guts of the lexical parser
|
||||
// Loop through the formula extracting each operator and operand in turn
|
||||
while(True) {
|
||||
while(true) {
|
||||
// echo 'Assessing Expression <b>'.substr($formula, $index).'</b><br />';
|
||||
$opCharacter = $formula{$index}; // Get the first character of the value at the current index position
|
||||
// echo 'Initial character of expression block is '.$opCharacter.'<br />';
|
||||
|
@ -2683,18 +2673,18 @@ class PHPExcel_Calculation {
|
|||
return $this->_raiseFormulaError("Formula Error: Internal error, non-function on stack");
|
||||
}
|
||||
// Check the argument count
|
||||
$argumentCountError = False;
|
||||
$argumentCountError = false;
|
||||
if (is_numeric($expectedArgumentCount)) {
|
||||
if ($expectedArgumentCount < 0) {
|
||||
// echo '$expectedArgumentCount is between 0 and '.abs($expectedArgumentCount).'<br />';
|
||||
if ($argumentCount > abs($expectedArgumentCount)) {
|
||||
$argumentCountError = True;
|
||||
$argumentCountError = true;
|
||||
$expectedArgumentCountString = 'no more than '.abs($expectedArgumentCount);
|
||||
}
|
||||
} else {
|
||||
// echo '$expectedArgumentCount is numeric '.$expectedArgumentCount.'<br />';
|
||||
if ($argumentCount != $expectedArgumentCount) {
|
||||
$argumentCountError = True;
|
||||
$argumentCountError = true;
|
||||
$expectedArgumentCountString = $expectedArgumentCount;
|
||||
}
|
||||
}
|
||||
|
@ -2705,19 +2695,19 @@ class PHPExcel_Calculation {
|
|||
switch ($argMatch[2]) {
|
||||
case '+' :
|
||||
if ($argumentCount < $argMatch[1]) {
|
||||
$argumentCountError = True;
|
||||
$argumentCountError = true;
|
||||
$expectedArgumentCountString = $argMatch[1].' or more ';
|
||||
}
|
||||
break;
|
||||
case '-' :
|
||||
if (($argumentCount < $argMatch[1]) || ($argumentCount > $argMatch[3])) {
|
||||
$argumentCountError = True;
|
||||
$argumentCountError = true;
|
||||
$expectedArgumentCountString = 'between '.$argMatch[1].' and '.$argMatch[3];
|
||||
}
|
||||
break;
|
||||
case ',' :
|
||||
if (($argumentCount != $argMatch[1]) && ($argumentCount != $argMatch[3])) {
|
||||
$argumentCountError = True;
|
||||
$argumentCountError = true;
|
||||
$expectedArgumentCountString = 'either '.$argMatch[1].' or '.$argMatch[3];
|
||||
}
|
||||
break;
|
||||
|
@ -2738,7 +2728,7 @@ class PHPExcel_Calculation {
|
|||
// If we've a comma when we're expecting an operand, then what we actually have is a null operand;
|
||||
// so push a null onto the stack
|
||||
if (($expectingOperand) || (!$expectingOperator)) {
|
||||
$output[] = array('type' => 'NULL Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => NULL);
|
||||
$output[] = array('type' => 'NULL Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => null);
|
||||
}
|
||||
// make sure there was a function
|
||||
$d = $stack->last(2);
|
||||
|
@ -2778,7 +2768,7 @@ class PHPExcel_Calculation {
|
|||
}
|
||||
$stack->push('Brace', '(');
|
||||
} else { // it's a var w/ implicit multiplication
|
||||
$output[] = array('type' => 'Value', 'value' => $matches[1], 'reference' => NULL);
|
||||
$output[] = array('type' => 'Value', 'value' => $matches[1], 'reference' => null);
|
||||
}
|
||||
} elseif (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'$/i', $val, $matches)) {
|
||||
// echo 'Element '.$val.' is a Cell reference<br />';
|
||||
|
@ -2840,7 +2830,7 @@ class PHPExcel_Calculation {
|
|||
$val = self::_wrapResult(str_replace('""','"',self::_unwrapResult($val)));
|
||||
} elseif (is_numeric($val)) {
|
||||
// echo 'Element is a Number<br />';
|
||||
if ((strpos($val,'.') !== False) || (stripos($val,'e') !== False) || ($val > PHP_INT_MAX) || ($val < -PHP_INT_MAX)) {
|
||||
if ((strpos($val,'.') !== false) || (stripos($val,'e') !== false) || ($val > PHP_INT_MAX) || ($val < -PHP_INT_MAX)) {
|
||||
// echo 'Casting '.$val.' to float<br />';
|
||||
$val = (float) $val;
|
||||
} else {
|
||||
|
@ -2855,7 +2845,7 @@ class PHPExcel_Calculation {
|
|||
// echo 'Element '.$localeConstant.' is an Excel Constant<br />';
|
||||
$val = self::$_ExcelConstants[$localeConstant];
|
||||
}
|
||||
$details = array('type' => 'Value', 'value' => $val, 'reference' => NULL);
|
||||
$details = array('type' => 'Value', 'value' => $val, 'reference' => null);
|
||||
if ($localeConstant) { $details['localeValue'] = $localeConstant; }
|
||||
$output[] = $details;
|
||||
}
|
||||
|
@ -2865,9 +2855,9 @@ class PHPExcel_Calculation {
|
|||
++$index;
|
||||
} elseif ($opCharacter == ')') { // miscellaneous error checking
|
||||
if ($expectingOperand) {
|
||||
$output[] = array('type' => 'Null Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => NULL);
|
||||
$output[] = array('type' => 'Null Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => null);
|
||||
$expectingOperand = false;
|
||||
$expectingOperator = True;
|
||||
$expectingOperator = true;
|
||||
} else {
|
||||
return $this->_raiseFormulaError("Formula Error: Unexpected ')'");
|
||||
}
|
||||
|
@ -3008,7 +2998,7 @@ class PHPExcel_Calculation {
|
|||
}
|
||||
$stack->push('Cell Reference',$cellValue,$cellRef);
|
||||
} else {
|
||||
$stack->push('Error',PHPExcel_Calculation_Functions::REF(),NULL);
|
||||
$stack->push('Error',PHPExcel_Calculation_Functions::REF(),null);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -3042,7 +3032,7 @@ class PHPExcel_Calculation {
|
|||
self::_checkMatrixOperands($operand1,$operand2,2);
|
||||
try {
|
||||
// Convert operand 1 from a PHP array to a matrix
|
||||
$matrix = new Matrix($operand1);
|
||||
$matrix = new PHPExcel_Shared_JAMA_Matrix($operand1);
|
||||
// Perform the required operation against the operand 1 matrix, passing in operand 2
|
||||
$matrixResult = $matrix->concat($operand2);
|
||||
$result = $matrixResult->getArray();
|
||||
|
@ -3089,7 +3079,7 @@ class PHPExcel_Calculation {
|
|||
if (is_array($arg)) {
|
||||
self::_checkMatrixOperands($arg,$multiplier,2);
|
||||
try {
|
||||
$matrix1 = new Matrix($arg);
|
||||
$matrix1 = new PHPExcel_Shared_JAMA_Matrix($arg);
|
||||
$matrixResult = $matrix1->arrayTimesEquals($multiplier);
|
||||
$result = $matrixResult->getArray();
|
||||
} catch (Exception $ex) {
|
||||
|
@ -3150,7 +3140,7 @@ class PHPExcel_Calculation {
|
|||
$cellValue = $this->extractCellRange($cellRef, $pCellParent->getParent()->getSheetByName($matches[2]), false);
|
||||
$pCell->attach($pCellParent);
|
||||
} else {
|
||||
$cellValue = NULL;
|
||||
$cellValue = null;
|
||||
}
|
||||
} else {
|
||||
return $this->_raiseFormulaError('Unable to access Cell Reference');
|
||||
|
@ -3164,7 +3154,7 @@ class PHPExcel_Calculation {
|
|||
$cellValue = $this->extractCellRange($cellRef, $pCellParent, false);
|
||||
$pCell->attach($pCellParent);
|
||||
} else {
|
||||
$cellValue = NULL;
|
||||
$cellValue = null;
|
||||
}
|
||||
$this->_writeDebug('Evaluation Result for cell '.$cellRef.' is '.$this->_showTypeDetails($cellValue));
|
||||
}
|
||||
|
@ -3356,7 +3346,7 @@ class PHPExcel_Calculation {
|
|||
if (!$recursingArrays) { self::_checkMatrixOperands($operand1,$operand2,2); }
|
||||
foreach($operand1 as $x => $operandData) {
|
||||
$this->_writeDebug('Evaluating '.$this->_showValue($operandData).' '.$operation.' '.$this->_showValue($operand2[$x]));
|
||||
$this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2[$x],$operation,$stack,True);
|
||||
$this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2[$x],$operation,$stack,true);
|
||||
$r = $stack->pop();
|
||||
$result[$x] = $r['value'];
|
||||
}
|
||||
|
@ -3434,7 +3424,7 @@ class PHPExcel_Calculation {
|
|||
if ($executeMatrixOperation) {
|
||||
try {
|
||||
// Convert operand 1 from a PHP array to a matrix
|
||||
$matrix = new Matrix($operand1);
|
||||
$matrix = new PHPExcel_Shared_JAMA_Matrix($operand1);
|
||||
// Perform the required operation against the operand 1 matrix, passing in operand 2
|
||||
$matrixResult = $matrix->$matrixFunction($operand2);
|
||||
$result = $matrixResult->getArray();
|
||||
|
@ -3532,7 +3522,7 @@ class PHPExcel_Calculation {
|
|||
if ($pSheet->cellExists($aReferences[0])) {
|
||||
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
|
||||
} else {
|
||||
$returnValue[$currentRow][$currentCol] = NULL;
|
||||
$returnValue[$currentRow][$currentCol] = null;
|
||||
}
|
||||
} else {
|
||||
// Extract cell data
|
||||
|
@ -3543,7 +3533,7 @@ class PHPExcel_Calculation {
|
|||
if ($pSheet->cellExists($reference)) {
|
||||
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
|
||||
} else {
|
||||
$returnValue[$currentRow][$currentCol] = NULL;
|
||||
$returnValue[$currentRow][$currentCol] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3604,7 +3594,7 @@ class PHPExcel_Calculation {
|
|||
if ($pSheet->cellExists($aReferences[0])) {
|
||||
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
|
||||
} else {
|
||||
$returnValue[$currentRow][$currentCol] = NULL;
|
||||
$returnValue[$currentRow][$currentCol] = null;
|
||||
}
|
||||
} else {
|
||||
// Extract cell data
|
||||
|
@ -3615,7 +3605,7 @@ class PHPExcel_Calculation {
|
|||
if ($pSheet->cellExists($reference)) {
|
||||
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
|
||||
} else {
|
||||
$returnValue[$currentRow][$currentCol] = NULL;
|
||||
$returnValue[$currentRow][$currentCol] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,12 +33,6 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -33,12 +33,6 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -33,12 +33,6 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -33,12 +33,6 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,12 +33,6 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,12 +33,6 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,12 +33,6 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,12 +33,6 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -64,12 +64,6 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,12 +33,6 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,12 +33,6 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,12 +33,6 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,12 +33,6 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,12 +32,6 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
* @package JAMA
|
||||
*/
|
||||
|
||||
define('RAND_MAX', mt_getrandmax());
|
||||
define('RAND_MIN', 0);
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
|
@ -13,23 +10,8 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/utils/Error.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/utils/Maths.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/CholeskyDecomposition.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/LUDecomposition.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/QRDecomposition.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/EigenvalueDecomposition.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/SingularValueDecomposition.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/Functions.php';
|
||||
|
||||
/*
|
||||
* Matrix class
|
||||
|
@ -42,7 +24,14 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/Functions.php';
|
|||
* @license PHP v3.0
|
||||
* @see http://math.nist.gov/javanumerics/jama/
|
||||
*/
|
||||
class Matrix {
|
||||
class PHPExcel_Shared_JAMA_Matrix {
|
||||
|
||||
|
||||
const PolymorphicArgumentException = "Invalid argument pattern for polymorphic function.";
|
||||
const ArgumentTypeException = "Invalid argument type.";
|
||||
const ArgumentBoundsException = "Invalid argument range.";
|
||||
const MatrixDimensionException = "Matrix dimensions are not equal.";
|
||||
const ArrayLengthException = "Array length must be a multiple of m.";
|
||||
|
||||
/**
|
||||
* Matrix storage
|
||||
|
@ -98,24 +87,6 @@ class Matrix {
|
|||
$this->n = $args[1];
|
||||
$this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0));
|
||||
break;
|
||||
//Rectangular matrix constant-filled - m x n filled with c
|
||||
case 'integer,integer,integer':
|
||||
$this->m = $args[0];
|
||||
$this->n = $args[1];
|
||||
$this->A = array_fill(0, $this->m, array_fill(0, $this->n, $args[2]));
|
||||
break;
|
||||
//Rectangular matrix constant-filled - m x n filled with c
|
||||
case 'integer,integer,double':
|
||||
$this->m = $args[0];
|
||||
$this->n = $args[1];
|
||||
$this->A = array_fill(0, $this->m, array_fill(0, $this->n, $args[2]));
|
||||
break;
|
||||
//Rectangular matrix - m x n initialized from 2D array
|
||||
case 'array,integer,integer':
|
||||
$this->m = $args[1];
|
||||
$this->n = $args[2];
|
||||
$this->A = $args[0];
|
||||
break;
|
||||
//Rectangular matrix - m x n initialized from packed array
|
||||
case 'array,integer':
|
||||
$this->m = $args[1];
|
||||
|
@ -131,15 +102,15 @@ class Matrix {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
throw new Exception(JAMAError(ArrayLengthException));
|
||||
throw new Exception(self::ArrayLengthException);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
@ -154,73 +125,6 @@ class Matrix {
|
|||
} // function getArray()
|
||||
|
||||
|
||||
/**
|
||||
* getArrayCopy
|
||||
*
|
||||
* @return array Matrix array copy
|
||||
*/
|
||||
public function getArrayCopy() {
|
||||
return $this->A;
|
||||
} // function getArrayCopy()
|
||||
|
||||
|
||||
/**
|
||||
* constructWithCopy
|
||||
* Construct a matrix from a copy of a 2-D array.
|
||||
*
|
||||
* @param double A[][] Two-dimensional array of doubles.
|
||||
* @exception IllegalArgumentException All rows must have the same length
|
||||
*/
|
||||
public function constructWithCopy($A) {
|
||||
$this->m = count($A);
|
||||
$this->n = count($A[0]);
|
||||
$newCopyMatrix = new Matrix($this->m, $this->n);
|
||||
for ($i = 0; $i < $this->m; ++$i) {
|
||||
if (count($A[$i]) != $this->n) {
|
||||
throw new Exception(JAMAError(RowLengthException));
|
||||
}
|
||||
for ($j = 0; $j < $this->n; ++$j) {
|
||||
$newCopyMatrix->A[$i][$j] = $A[$i][$j];
|
||||
}
|
||||
}
|
||||
return $newCopyMatrix;
|
||||
} // function constructWithCopy()
|
||||
|
||||
|
||||
/**
|
||||
* getColumnPackedCopy
|
||||
*
|
||||
* Get a column-packed array
|
||||
* @return array Column-packed matrix array
|
||||
*/
|
||||
public function getColumnPackedCopy() {
|
||||
$P = array();
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
array_push($P, $this->A[$j][$i]);
|
||||
}
|
||||
}
|
||||
return $P;
|
||||
} // function getColumnPackedCopy()
|
||||
|
||||
|
||||
/**
|
||||
* getRowPackedCopy
|
||||
*
|
||||
* Get a row-packed array
|
||||
* @return array Row-packed matrix array
|
||||
*/
|
||||
public function getRowPackedCopy() {
|
||||
$P = array();
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
array_push($P, $this->A[$i][$j]);
|
||||
}
|
||||
}
|
||||
return $P;
|
||||
} // function getRowPackedCopy()
|
||||
|
||||
|
||||
/**
|
||||
* getRowDimension
|
||||
*
|
||||
|
@ -273,9 +177,9 @@ class Matrix {
|
|||
//A($i0...; $j0...)
|
||||
case 'integer,integer':
|
||||
list($i0, $j0) = $args;
|
||||
if ($i0 >= 0) { $m = $this->m - $i0; } else { throw new Exception(JAMAError(ArgumentBoundsException)); }
|
||||
if ($j0 >= 0) { $n = $this->n - $j0; } else { throw new Exception(JAMAError(ArgumentBoundsException)); }
|
||||
$R = new Matrix($m, $n);
|
||||
if ($i0 >= 0) { $m = $this->m - $i0; } else { throw new Exception(self::ArgumentBoundsException); }
|
||||
if ($j0 >= 0) { $n = $this->n - $j0; } else { throw new Exception(self::ArgumentBoundsException); }
|
||||
$R = new PHPExcel_Shared_JAMA_Matrix($m, $n);
|
||||
for($i = $i0; $i < $this->m; ++$i) {
|
||||
for($j = $j0; $j < $this->n; ++$j) {
|
||||
$R->set($i, $j, $this->A[$i][$j]);
|
||||
|
@ -286,9 +190,9 @@ class Matrix {
|
|||
//A($i0...$iF; $j0...$jF)
|
||||
case 'integer,integer,integer,integer':
|
||||
list($i0, $iF, $j0, $jF) = $args;
|
||||
if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { throw new Exception(JAMAError(ArgumentBoundsException)); }
|
||||
if (($jF > $j0) && ($this->n >= $jF) && ($j0 >= 0)) { $n = $jF - $j0; } else { throw new Exception(JAMAError(ArgumentBoundsException)); }
|
||||
$R = new Matrix($m+1, $n+1);
|
||||
if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { throw new Exception(self::ArgumentBoundsException); }
|
||||
if (($jF > $j0) && ($this->n >= $jF) && ($j0 >= 0)) { $n = $jF - $j0; } else { throw new Exception(self::ArgumentBoundsException); }
|
||||
$R = new PHPExcel_Shared_JAMA_Matrix($m+1, $n+1);
|
||||
for($i = $i0; $i <= $iF; ++$i) {
|
||||
for($j = $j0; $j <= $jF; ++$j) {
|
||||
$R->set($i - $i0, $j - $j0, $this->A[$i][$j]);
|
||||
|
@ -299,9 +203,9 @@ class Matrix {
|
|||
//$R = array of row indices; $C = array of column indices
|
||||
case 'array,array':
|
||||
list($RL, $CL) = $args;
|
||||
if (count($RL) > 0) { $m = count($RL); } else { throw new Exception(JAMAError(ArgumentBoundsException)); }
|
||||
if (count($CL) > 0) { $n = count($CL); } else { throw new Exception(JAMAError(ArgumentBoundsException)); }
|
||||
$R = new Matrix($m, $n);
|
||||
if (count($RL) > 0) { $m = count($RL); } else { throw new Exception(self::ArgumentBoundsException); }
|
||||
if (count($CL) > 0) { $n = count($CL); } else { throw new Exception(self::ArgumentBoundsException); }
|
||||
$R = new PHPExcel_Shared_JAMA_Matrix($m, $n);
|
||||
for($i = 0; $i < $m; ++$i) {
|
||||
for($j = 0; $j < $n; ++$j) {
|
||||
$R->set($i - $i0, $j - $j0, $this->A[$RL[$i]][$CL[$j]]);
|
||||
|
@ -312,9 +216,9 @@ class Matrix {
|
|||
//$RL = array of row indices; $CL = array of column indices
|
||||
case 'array,array':
|
||||
list($RL, $CL) = $args;
|
||||
if (count($RL) > 0) { $m = count($RL); } else { throw new Exception(JAMAError(ArgumentBoundsException)); }
|
||||
if (count($CL) > 0) { $n = count($CL); } else { throw new Exception(JAMAError(ArgumentBoundsException)); }
|
||||
$R = new Matrix($m, $n);
|
||||
if (count($RL) > 0) { $m = count($RL); } else { throw new Exception(self::ArgumentBoundsException); }
|
||||
if (count($CL) > 0) { $n = count($CL); } else { throw new Exception(self::ArgumentBoundsException); }
|
||||
$R = new PHPExcel_Shared_JAMA_Matrix($m, $n);
|
||||
for($i = 0; $i < $m; ++$i) {
|
||||
for($j = 0; $j < $n; ++$j) {
|
||||
$R->set($i, $j, $this->A[$RL[$i]][$CL[$j]]);
|
||||
|
@ -325,9 +229,9 @@ class Matrix {
|
|||
//A($i0...$iF); $CL = array of column indices
|
||||
case 'integer,integer,array':
|
||||
list($i0, $iF, $CL) = $args;
|
||||
if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { throw new Exception(JAMAError(ArgumentBoundsException)); }
|
||||
if (count($CL) > 0) { $n = count($CL); } else { throw new Exception(JAMAError(ArgumentBoundsException)); }
|
||||
$R = new Matrix($m, $n);
|
||||
if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { throw new Exception(self::ArgumentBoundsException); }
|
||||
if (count($CL) > 0) { $n = count($CL); } else { throw new Exception(self::ArgumentBoundsException); }
|
||||
$R = new PHPExcel_Shared_JAMA_Matrix($m, $n);
|
||||
for($i = $i0; $i < $iF; ++$i) {
|
||||
for($j = 0; $j < $n; ++$j) {
|
||||
$R->set($i - $i0, $j, $this->A[$RL[$i]][$j]);
|
||||
|
@ -338,9 +242,9 @@ class Matrix {
|
|||
//$RL = array of row indices
|
||||
case 'array,integer,integer':
|
||||
list($RL, $j0, $jF) = $args;
|
||||
if (count($RL) > 0) { $m = count($RL); } else { throw new Exception(JAMAError(ArgumentBoundsException)); }
|
||||
if (($jF >= $j0) && ($this->n >= $jF) && ($j0 >= 0)) { $n = $jF - $j0; } else { throw new Exception(JAMAError(ArgumentBoundsException)); }
|
||||
$R = new Matrix($m, $n+1);
|
||||
if (count($RL) > 0) { $m = count($RL); } else { throw new Exception(self::ArgumentBoundsException); }
|
||||
if (($jF >= $j0) && ($this->n >= $jF) && ($j0 >= 0)) { $n = $jF - $j0; } else { throw new Exception(self::ArgumentBoundsException); }
|
||||
$R = new PHPExcel_Shared_JAMA_Matrix($m, $n+1);
|
||||
for($i = 0; $i < $m; ++$i) {
|
||||
for($j = $j0; $j <= $jF; ++$j) {
|
||||
$R->set($i, $j - $j0, $this->A[$RL[$i]][$j]);
|
||||
|
@ -349,61 +253,15 @@ class Matrix {
|
|||
return $R;
|
||||
break;
|
||||
default:
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
}
|
||||
} // function getMatrix()
|
||||
|
||||
|
||||
/**
|
||||
* setMatrix
|
||||
*
|
||||
* Set a submatrix
|
||||
* @param int $i0 Initial row index
|
||||
* @param int $j0 Initial column index
|
||||
* @param mixed $S Matrix/Array submatrix
|
||||
* ($i0, $j0, $S) $S = Matrix
|
||||
* ($i0, $j0, $S) $S = Array
|
||||
*/
|
||||
public function setMatrix() {
|
||||
if (func_num_args() > 0) {
|
||||
$args = func_get_args();
|
||||
$match = implode(",", array_map('gettype', $args));
|
||||
|
||||
switch($match) {
|
||||
case 'integer,integer,object':
|
||||
if ($args[2] instanceof Matrix) { $M = $args[2]; } else { throw new Exception(JAMAError(ArgumentTypeException)); }
|
||||
if (($args[0] + $M->m) <= $this->m) { $i0 = $args[0]; } else { throw new Exception(JAMAError(ArgumentBoundsException)); }
|
||||
if (($args[1] + $M->n) <= $this->n) { $j0 = $args[1]; } else { throw new Exception(JAMAError(ArgumentBoundsException)); }
|
||||
for($i = $i0; $i < $i0 + $M->m; ++$i) {
|
||||
for($j = $j0; $j < $j0 + $M->n; ++$j) {
|
||||
$this->A[$i][$j] = $M->get($i - $i0, $j - $j0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'integer,integer,array':
|
||||
$M = new Matrix($args[2]);
|
||||
if (($args[0] + $M->m) <= $this->m) { $i0 = $args[0]; } else { throw new Exception(JAMAError(ArgumentBoundsException)); }
|
||||
if (($args[1] + $M->n) <= $this->n) { $j0 = $args[1]; } else { throw new Exception(JAMAError(ArgumentBoundsException)); }
|
||||
for($i = $i0; $i < $i0 + $M->m; ++$i) {
|
||||
for($j = $j0; $j < $j0 + $M->n; ++$j) {
|
||||
$this->A[$i][$j] = $M->get($i - $i0, $j - $j0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
}
|
||||
} // function setMatrix()
|
||||
|
||||
|
||||
/**
|
||||
* checkMatrixDimensions
|
||||
*
|
||||
|
@ -412,14 +270,14 @@ class Matrix {
|
|||
* @return boolean
|
||||
*/
|
||||
public function checkMatrixDimensions($B = null) {
|
||||
if ($B instanceof Matrix) {
|
||||
if ($B instanceof PHPExcel_Shared_JAMA_Matrix) {
|
||||
if (($this->m == $B->getRowDimension()) && ($this->n == $B->getColumnDimension())) {
|
||||
return true;
|
||||
} else {
|
||||
throw new Exception(JAMAError(MatrixDimensionException));
|
||||
throw new Exception(self::MatrixDimensionException);
|
||||
}
|
||||
} else {
|
||||
throw new Exception(JAMAError(ArgumentTypeException));
|
||||
throw new Exception(self::ArgumentTypeException);
|
||||
}
|
||||
} // function checkMatrixDimensions()
|
||||
|
||||
|
@ -437,18 +295,6 @@ class Matrix {
|
|||
public function set($i = null, $j = null, $c = null) {
|
||||
// Optimized set version just has this
|
||||
$this->A[$i][$j] = $c;
|
||||
/*
|
||||
if (is_int($i) && is_int($j) && is_numeric($c)) {
|
||||
if (($i < $this->m) && ($j < $this->n)) {
|
||||
$this->A[$i][$j] = $c;
|
||||
} else {
|
||||
echo "A[$i][$j] = $c<br />";
|
||||
throw new Exception(JAMAError(ArgumentBoundsException));
|
||||
}
|
||||
} else {
|
||||
throw new Exception(JAMAError(ArgumentTypeException));
|
||||
}
|
||||
*/
|
||||
} // function set()
|
||||
|
||||
|
||||
|
@ -475,7 +321,7 @@ class Matrix {
|
|||
* @return Matrix Diagonal matrix
|
||||
*/
|
||||
public function diagonal($m = null, $n = null, $c = 1) {
|
||||
$R = new Matrix($m, $n);
|
||||
$R = new PHPExcel_Shared_JAMA_Matrix($m, $n);
|
||||
for($i = 0; $i < $m; ++$i) {
|
||||
$R->set($i, $i, $c);
|
||||
}
|
||||
|
@ -483,58 +329,6 @@ class Matrix {
|
|||
} // function diagonal()
|
||||
|
||||
|
||||
/**
|
||||
* filled
|
||||
*
|
||||
* Generate a filled matrix
|
||||
* @param int $m Row dimension
|
||||
* @param int $n Column dimension
|
||||
* @param int $c Fill constant
|
||||
* @return Matrix Filled matrix
|
||||
*/
|
||||
public function filled($m = null, $n = null, $c = 0) {
|
||||
if (is_int($m) && is_int($n) && is_numeric($c)) {
|
||||
$R = new Matrix($m, $n, $c);
|
||||
return $R;
|
||||
} else {
|
||||
throw new Exception(JAMAError(ArgumentTypeException));
|
||||
}
|
||||
} // function filled()
|
||||
|
||||
/**
|
||||
* random
|
||||
*
|
||||
* Generate a random matrix
|
||||
* @param int $m Row dimension
|
||||
* @param int $n Column dimension
|
||||
* @return Matrix Random matrix
|
||||
*/
|
||||
public function random($m = null, $n = null, $a = RAND_MIN, $b = RAND_MAX) {
|
||||
if (is_int($m) && is_int($n) && is_numeric($a) && is_numeric($b)) {
|
||||
$R = new Matrix($m, $n);
|
||||
for($i = 0; $i < $m; ++$i) {
|
||||
for($j = 0; $j < $n; ++$j) {
|
||||
$R->set($i, $j, mt_rand($a, $b));
|
||||
}
|
||||
}
|
||||
return $R;
|
||||
} else {
|
||||
throw new Exception(JAMAError(ArgumentTypeException));
|
||||
}
|
||||
} // function random()
|
||||
|
||||
|
||||
/**
|
||||
* packed
|
||||
*
|
||||
* Alias for getRowPacked
|
||||
* @return array Packed array
|
||||
*/
|
||||
public function packed() {
|
||||
return $this->getRowPacked();
|
||||
} // function packed()
|
||||
|
||||
|
||||
/**
|
||||
* getMatrixByRow
|
||||
*
|
||||
|
@ -551,7 +345,7 @@ class Matrix {
|
|||
return $this->getMatrix($i0, 0, $i0 + 1, $this->n);
|
||||
}
|
||||
} else {
|
||||
throw new Exception(JAMAError(ArgumentTypeException));
|
||||
throw new Exception(self::ArgumentTypeException);
|
||||
}
|
||||
} // function getMatrixByRow()
|
||||
|
||||
|
@ -572,7 +366,7 @@ class Matrix {
|
|||
return $this->getMatrix(0, $j0, $this->m, $j0 + 1);
|
||||
}
|
||||
} else {
|
||||
throw new Exception(JAMAError(ArgumentTypeException));
|
||||
throw new Exception(self::ArgumentTypeException);
|
||||
}
|
||||
} // function getMatrixByCol()
|
||||
|
||||
|
@ -584,7 +378,7 @@ class Matrix {
|
|||
* @return Matrix Transposed matrix
|
||||
*/
|
||||
public function transpose() {
|
||||
$R = new Matrix($this->n, $this->m);
|
||||
$R = new PHPExcel_Shared_JAMA_Matrix($this->n, $this->m);
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
$R->set($j, $i, $this->A[$i][$j]);
|
||||
|
@ -594,93 +388,6 @@ class Matrix {
|
|||
} // function transpose()
|
||||
|
||||
|
||||
/**
|
||||
* norm1
|
||||
*
|
||||
* One norm
|
||||
* @return float Maximum column sum
|
||||
*/
|
||||
public function norm1() {
|
||||
$r = 0;
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
$s = 0;
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
$s += abs($this->A[$i][$j]);
|
||||
}
|
||||
$r = ($r > $s) ? $r : $s;
|
||||
}
|
||||
return $r;
|
||||
} // function norm1()
|
||||
|
||||
|
||||
/**
|
||||
* norm2
|
||||
*
|
||||
* Maximum singular value
|
||||
* @return float Maximum singular value
|
||||
*/
|
||||
public function norm2() {
|
||||
} // function norm2()
|
||||
|
||||
|
||||
/**
|
||||
* normInf
|
||||
*
|
||||
* Infinite norm
|
||||
* @return float Maximum row sum
|
||||
*/
|
||||
public function normInf() {
|
||||
$r = 0;
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
$s = 0;
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
$s += abs($this->A[$i][$j]);
|
||||
}
|
||||
$r = ($r > $s) ? $r : $s;
|
||||
}
|
||||
return $r;
|
||||
} // function normInf()
|
||||
|
||||
|
||||
/**
|
||||
* normF
|
||||
*
|
||||
* Frobenius norm
|
||||
* @return float Square root of the sum of all elements squared
|
||||
*/
|
||||
public function normF() {
|
||||
$f = 0;
|
||||
for ($i = 0; $i < $this->m; ++$i) {
|
||||
for ($j = 0; $j < $this->n; ++$j) {
|
||||
$f = hypo($f,$this->A[$i][$j]);
|
||||
}
|
||||
}
|
||||
return $f;
|
||||
} // function normF()
|
||||
|
||||
|
||||
/**
|
||||
* Matrix rank
|
||||
*
|
||||
* @return effective numerical rank, obtained from SVD.
|
||||
*/
|
||||
public function rank () {
|
||||
$svd = new SingularValueDecomposition($this);
|
||||
return $svd->rank();
|
||||
} // function rank ()
|
||||
|
||||
|
||||
/**
|
||||
* Matrix condition (2 norm)
|
||||
*
|
||||
* @return ratio of largest to smallest singular value.
|
||||
*/
|
||||
public function cond () {
|
||||
$svd = new SingularValueDecomposition($this);
|
||||
return $svd->cond();
|
||||
} // function cond ()
|
||||
|
||||
|
||||
/**
|
||||
* trace
|
||||
*
|
||||
|
@ -721,13 +428,13 @@ class Matrix {
|
|||
|
||||
switch($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof Matrix) { $M = $args[0]; } else { throw new Exception(JAMAError(ArgumentTypeException)); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
|
||||
break;
|
||||
case 'array':
|
||||
$M = new Matrix($args[0]);
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
break;
|
||||
default:
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
break;
|
||||
}
|
||||
$this->checkMatrixDimensions($M);
|
||||
|
@ -738,7 +445,7 @@ class Matrix {
|
|||
}
|
||||
return $M;
|
||||
} else {
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
}
|
||||
} // function plus()
|
||||
|
||||
|
@ -757,13 +464,13 @@ class Matrix {
|
|||
|
||||
switch($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof Matrix) { $M = $args[0]; } else { throw new Exception(JAMAError(ArgumentTypeException)); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
|
||||
break;
|
||||
case 'array':
|
||||
$M = new Matrix($args[0]);
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
break;
|
||||
default:
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
break;
|
||||
}
|
||||
$this->checkMatrixDimensions($M);
|
||||
|
@ -788,7 +495,7 @@ class Matrix {
|
|||
}
|
||||
return $this;
|
||||
} else {
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
}
|
||||
} // function plusEquals()
|
||||
|
||||
|
@ -807,13 +514,13 @@ class Matrix {
|
|||
|
||||
switch($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof Matrix) { $M = $args[0]; } else { throw new Exception(JAMAError(ArgumentTypeException)); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
|
||||
break;
|
||||
case 'array':
|
||||
$M = new Matrix($args[0]);
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
break;
|
||||
default:
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
break;
|
||||
}
|
||||
$this->checkMatrixDimensions($M);
|
||||
|
@ -824,7 +531,7 @@ class Matrix {
|
|||
}
|
||||
return $M;
|
||||
} else {
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
}
|
||||
} // function minus()
|
||||
|
||||
|
@ -843,13 +550,13 @@ class Matrix {
|
|||
|
||||
switch($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof Matrix) { $M = $args[0]; } else { throw new Exception(JAMAError(ArgumentTypeException)); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
|
||||
break;
|
||||
case 'array':
|
||||
$M = new Matrix($args[0]);
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
break;
|
||||
default:
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
break;
|
||||
}
|
||||
$this->checkMatrixDimensions($M);
|
||||
|
@ -874,7 +581,7 @@ class Matrix {
|
|||
}
|
||||
return $this;
|
||||
} else {
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
}
|
||||
} // function minusEquals()
|
||||
|
||||
|
@ -894,13 +601,13 @@ class Matrix {
|
|||
|
||||
switch($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof Matrix) { $M = $args[0]; } else { throw new Exception(JAMAError(ArgumentTypeException)); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
|
||||
break;
|
||||
case 'array':
|
||||
$M = new Matrix($args[0]);
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
break;
|
||||
default:
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
break;
|
||||
}
|
||||
$this->checkMatrixDimensions($M);
|
||||
|
@ -911,7 +618,7 @@ class Matrix {
|
|||
}
|
||||
return $M;
|
||||
} else {
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
}
|
||||
} // function arrayTimes()
|
||||
|
||||
|
@ -931,13 +638,13 @@ class Matrix {
|
|||
|
||||
switch($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof Matrix) { $M = $args[0]; } else { throw new Exception(JAMAError(ArgumentTypeException)); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
|
||||
break;
|
||||
case 'array':
|
||||
$M = new Matrix($args[0]);
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
break;
|
||||
default:
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
break;
|
||||
}
|
||||
$this->checkMatrixDimensions($M);
|
||||
|
@ -962,7 +669,7 @@ class Matrix {
|
|||
}
|
||||
return $this;
|
||||
} else {
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
}
|
||||
} // function arrayTimesEquals()
|
||||
|
||||
|
@ -982,13 +689,13 @@ class Matrix {
|
|||
|
||||
switch($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof Matrix) { $M = $args[0]; } else { throw new Exception(JAMAError(ArgumentTypeException)); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
|
||||
break;
|
||||
case 'array':
|
||||
$M = new Matrix($args[0]);
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
break;
|
||||
default:
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
break;
|
||||
}
|
||||
$this->checkMatrixDimensions($M);
|
||||
|
@ -1018,7 +725,7 @@ class Matrix {
|
|||
}
|
||||
return $M;
|
||||
} else {
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
}
|
||||
} // function arrayRightDivide()
|
||||
|
||||
|
@ -1038,13 +745,13 @@ class Matrix {
|
|||
|
||||
switch($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof Matrix) { $M = $args[0]; } else { throw new Exception(JAMAError(ArgumentTypeException)); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
|
||||
break;
|
||||
case 'array':
|
||||
$M = new Matrix($args[0]);
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
break;
|
||||
default:
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
break;
|
||||
}
|
||||
$this->checkMatrixDimensions($M);
|
||||
|
@ -1055,7 +762,7 @@ class Matrix {
|
|||
}
|
||||
return $M;
|
||||
} else {
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
}
|
||||
} // function arrayRightDivideEquals()
|
||||
|
||||
|
@ -1075,13 +782,13 @@ class Matrix {
|
|||
|
||||
switch($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof Matrix) { $M = $args[0]; } else { throw new Exception(JAMAError(ArgumentTypeException)); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
|
||||
break;
|
||||
case 'array':
|
||||
$M = new Matrix($args[0]);
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
break;
|
||||
default:
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
break;
|
||||
}
|
||||
$this->checkMatrixDimensions($M);
|
||||
|
@ -1092,7 +799,7 @@ class Matrix {
|
|||
}
|
||||
return $M;
|
||||
} else {
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
}
|
||||
} // function arrayLeftDivide()
|
||||
|
||||
|
@ -1112,13 +819,13 @@ class Matrix {
|
|||
|
||||
switch($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof Matrix) { $M = $args[0]; } else { throw new Exception(JAMAError(ArgumentTypeException)); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
|
||||
break;
|
||||
case 'array':
|
||||
$M = new Matrix($args[0]);
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
break;
|
||||
default:
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
break;
|
||||
}
|
||||
$this->checkMatrixDimensions($M);
|
||||
|
@ -1129,7 +836,7 @@ class Matrix {
|
|||
}
|
||||
return $M;
|
||||
} else {
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
}
|
||||
} // function arrayLeftDivideEquals()
|
||||
|
||||
|
@ -1148,9 +855,9 @@ class Matrix {
|
|||
|
||||
switch($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof Matrix) { $B = $args[0]; } else { throw new Exception(JAMAError(ArgumentTypeException)); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $B = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
|
||||
if ($this->n == $B->m) {
|
||||
$C = new Matrix($this->m, $B->n);
|
||||
$C = new PHPExcel_Shared_JAMA_Matrix($this->m, $B->n);
|
||||
for($j = 0; $j < $B->n; ++$j) {
|
||||
for ($k = 0; $k < $this->n; ++$k) {
|
||||
$Bcolj[$k] = $B->A[$k][$j];
|
||||
|
@ -1170,9 +877,9 @@ class Matrix {
|
|||
}
|
||||
break;
|
||||
case 'array':
|
||||
$B = new Matrix($args[0]);
|
||||
$B = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
if ($this->n == $B->m) {
|
||||
$C = new Matrix($this->m, $B->n);
|
||||
$C = new PHPExcel_Shared_JAMA_Matrix($this->m, $B->n);
|
||||
for($i = 0; $i < $C->m; ++$i) {
|
||||
for($j = 0; $j < $C->n; ++$j) {
|
||||
$s = "0";
|
||||
|
@ -1189,7 +896,7 @@ class Matrix {
|
|||
return $M;
|
||||
break;
|
||||
case 'integer':
|
||||
$C = new Matrix($this->A);
|
||||
$C = new PHPExcel_Shared_JAMA_Matrix($this->A);
|
||||
for($i = 0; $i < $C->m; ++$i) {
|
||||
for($j = 0; $j < $C->n; ++$j) {
|
||||
$C->A[$i][$j] *= $args[0];
|
||||
|
@ -1198,7 +905,7 @@ class Matrix {
|
|||
return $C;
|
||||
break;
|
||||
case 'double':
|
||||
$C = new Matrix($this->m, $this->n);
|
||||
$C = new PHPExcel_Shared_JAMA_Matrix($this->m, $this->n);
|
||||
for($i = 0; $i < $C->m; ++$i) {
|
||||
for($j = 0; $j < $C->n; ++$j) {
|
||||
$C->A[$i][$j] = $args[0] * $this->A[$i][$j];
|
||||
|
@ -1207,7 +914,7 @@ class Matrix {
|
|||
return $C;
|
||||
break;
|
||||
case 'float':
|
||||
$C = new Matrix($this->A);
|
||||
$C = new PHPExcel_Shared_JAMA_Matrix($this->A);
|
||||
for($i = 0; $i < $C->m; ++$i) {
|
||||
for($j = 0; $j < $C->n; ++$j) {
|
||||
$C->A[$i][$j] *= $args[0];
|
||||
|
@ -1216,11 +923,11 @@ class Matrix {
|
|||
return $C;
|
||||
break;
|
||||
default:
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
throw new Exception(PolymorphicArgumentException);
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
}
|
||||
} // function times()
|
||||
|
||||
|
@ -1239,13 +946,13 @@ class Matrix {
|
|||
|
||||
switch($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof Matrix) { $M = $args[0]; } else { throw new Exception(JAMAError(ArgumentTypeException)); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
|
||||
break;
|
||||
case 'array':
|
||||
$M = new Matrix($args[0]);
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
break;
|
||||
default:
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
break;
|
||||
}
|
||||
$this->checkMatrixDimensions($M);
|
||||
|
@ -1270,7 +977,7 @@ class Matrix {
|
|||
}
|
||||
return $this;
|
||||
} else {
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
}
|
||||
} // function power()
|
||||
|
||||
|
@ -1289,100 +996,27 @@ class Matrix {
|
|||
|
||||
switch($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof Matrix) { $M = $args[0]; } else { throw new Exception(JAMAError(ArgumentTypeException)); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
|
||||
case 'array':
|
||||
$M = new Matrix($args[0]);
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
break;
|
||||
default:
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
break;
|
||||
}
|
||||
$this->checkMatrixDimensions($M);
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
// $this->A[$i][$j] = '"'.trim($this->A[$i][$j],'"').trim($M->get($i, $j),'"').'"';
|
||||
$this->A[$i][$j] = trim($this->A[$i][$j],'"').trim($M->get($i, $j),'"');
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
} else {
|
||||
throw new Exception(JAMAError(PolymorphicArgumentException));
|
||||
throw new Exception(self::PolymorphicArgumentException);
|
||||
}
|
||||
} // function concat()
|
||||
|
||||
|
||||
/**
|
||||
* chol
|
||||
*
|
||||
* Cholesky decomposition
|
||||
* @return Matrix Cholesky decomposition
|
||||
*/
|
||||
public function chol() {
|
||||
return new CholeskyDecomposition($this);
|
||||
} // function chol()
|
||||
|
||||
|
||||
/**
|
||||
* lu
|
||||
*
|
||||
* LU decomposition
|
||||
* @return Matrix LU decomposition
|
||||
*/
|
||||
public function lu() {
|
||||
return new LUDecomposition($this);
|
||||
} // function lu()
|
||||
|
||||
|
||||
/**
|
||||
* qr
|
||||
*
|
||||
* QR decomposition
|
||||
* @return Matrix QR decomposition
|
||||
*/
|
||||
public function qr() {
|
||||
return new QRDecomposition($this);
|
||||
} // function qr()
|
||||
|
||||
|
||||
/**
|
||||
* eig
|
||||
*
|
||||
* Eigenvalue decomposition
|
||||
* @return Matrix Eigenvalue decomposition
|
||||
*/
|
||||
public function eig() {
|
||||
return new EigenvalueDecomposition($this);
|
||||
} // function eig()
|
||||
|
||||
|
||||
/**
|
||||
* svd
|
||||
*
|
||||
* Singular value decomposition
|
||||
* @return Singular value decomposition
|
||||
*/
|
||||
public function svd() {
|
||||
return new SingularValueDecomposition($this);
|
||||
} // function svd()
|
||||
|
||||
|
||||
/**
|
||||
* Solve A*X = B.
|
||||
*
|
||||
* @param Matrix $B Right hand side
|
||||
* @return Matrix ... Solution if A is square, least squares solution otherwise
|
||||
*/
|
||||
public function solve($B) {
|
||||
if ($this->m == $this->n) {
|
||||
$LU = new LUDecomposition($this);
|
||||
return $LU->solve($B);
|
||||
} else {
|
||||
$QR = new QRDecomposition($this);
|
||||
return $QR->solve($B);
|
||||
}
|
||||
} // function solve()
|
||||
|
||||
|
||||
/**
|
||||
* Matrix inverse or pseudoinverse.
|
||||
*
|
||||
|
@ -1393,53 +1027,4 @@ class Matrix {
|
|||
} // function inverse()
|
||||
|
||||
|
||||
/**
|
||||
* det
|
||||
*
|
||||
* Calculate determinant
|
||||
* @return float Determinant
|
||||
*/
|
||||
public function det() {
|
||||
$L = new LUDecomposition($this);
|
||||
return $L->det();
|
||||
} // function det()
|
||||
|
||||
|
||||
/**
|
||||
* Older debugging utility for backwards compatability.
|
||||
*
|
||||
* @return html version of matrix
|
||||
*/
|
||||
public function mprint($A, $format="%01.2f", $width=2) {
|
||||
$m = count($A);
|
||||
$n = count($A[0]);
|
||||
$spacing = str_repeat(' ',$width);
|
||||
|
||||
for ($i = 0; $i < $m; ++$i) {
|
||||
for ($j = 0; $j < $n; ++$j) {
|
||||
$formatted = sprintf($format, $A[$i][$j]);
|
||||
echo $formatted.$spacing;
|
||||
}
|
||||
echo "<br />";
|
||||
}
|
||||
} // function mprint()
|
||||
|
||||
|
||||
/**
|
||||
* Debugging utility.
|
||||
*
|
||||
* @return Output HTML representation of matrix
|
||||
*/
|
||||
public function toHTML($width=2) {
|
||||
print('<table style="background-color:#eee;">');
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
print('<tr>');
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
print('<td style="background-color:#fff;border:1px solid #000;padding:2px;text-align:center;vertical-align:middle;">' . $this->A[$i][$j] . '</td>');
|
||||
}
|
||||
print('</tr>');
|
||||
}
|
||||
print('</table>');
|
||||
} // function toHTML()
|
||||
|
||||
} // class Matrix
|
||||
|
|
|
@ -34,6 +34,7 @@ Fixed in SVN:
|
|||
- Feature: (MBaker) Work item 14301 - PHPExcel_Worksheet->toArray() is returning truncated values
|
||||
- Feature: (MBaker) Configure PDF Writer margins based on Excel Worksheet Margin Settings value
|
||||
- Feature: (MBaker) Added Contiguous flag for the CSV Reader, when working with Read Filters
|
||||
- Feature: (MBaker) Added getFormattedValue() method for cell object
|
||||
- Bugfix: (Progi1984) Workitem 7895 - Excel5 : Formula : Percent
|
||||
- Bugfix: (MB) Work item 14143 - NA() doesn't propagate in matrix calc - quick fix in JAMA/Matrix.php
|
||||
- Bugfix: (Progi1984) Workitem 7895 - Excel5 : Formula : Error constant
|
||||
|
|
Loading…
Reference in New Issue