11 define(
'PHPEXCEL_ROOT', dirname(__FILE__) .
'/../../../');
12 require(PHPEXCEL_ROOT .
'PHPExcel/Autoloader.php');
67 if (func_num_args() > 0) {
68 $args = func_get_args();
69 $match = implode(
",", array_map(
'gettype', $args));
74 $this->m = count($args[0]);
75 $this->n = count($args[0][0]);
82 $this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0));
85 case 'integer,integer':
88 $this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0));
94 $this->n = count($args[0]) /
$this->m;
98 if (($this->m * $this->n) == count($args[0])) {
101 $this->A[$i][$j] = $args[0][$i + $j *
$this->m];
156 public function get($i =
null, $j =
null) {
157 return $this->A[$i][$j];
172 if (func_num_args() > 0) {
173 $args = func_get_args();
174 $match = implode(
",", array_map(
'gettype', $args));
178 case 'integer,integer':
179 list($i0, $j0) = $args;
183 for($i = $i0; $i <
$this->m; ++$i) {
184 for($j = $j0; $j <
$this->n; ++$j) {
185 $R->set($i, $j, $this->A[$i][$j]);
191 case 'integer,integer,integer,integer':
192 list($i0, $iF, $j0, $jF) = $args;
196 for($i = $i0; $i <= $iF; ++$i) {
197 for($j = $j0; $j <= $jF; ++$j) {
198 $R->set($i - $i0, $j - $j0, $this->A[$i][$j]);
205 list($RL, $CL) = $args;
209 for($i = 0; $i <
$m; ++$i) {
210 for($j = 0; $j <
$n; ++$j) {
211 $R->set($i - $i0, $j - $j0, $this->A[$RL[$i]][$CL[$j]]);
218 list($RL, $CL) = $args;
222 for($i = 0; $i <
$m; ++$i) {
223 for($j = 0; $j <
$n; ++$j) {
224 $R->set($i, $j, $this->A[$RL[$i]][$CL[$j]]);
230 case 'integer,integer,array':
231 list($i0, $iF, $CL) = $args;
235 for($i = $i0; $i < $iF; ++$i) {
236 for($j = 0; $j <
$n; ++$j) {
237 $R->set($i - $i0, $j, $this->A[$RL[$i]][$j]);
243 case 'array,integer,integer':
244 list($RL, $j0, $jF) = $args;
248 for($i = 0; $i <
$m; ++$i) {
249 for($j = $j0; $j <= $jF; ++$j) {
250 $R->set($i, $j - $j0, $this->A[$RL[$i]][$j]);
274 if (($this->m == $B->getRowDimension()) && ($this->n == $B->getColumnDimension())) {
295 public function set($i =
null, $j =
null, $c =
null) {
297 $this->A[$i][$j] = $c;
325 for($i = 0; $i <
$m; ++$i) {
343 return $this->
getMatrix($i0, 0, $iF + 1, $this->n);
345 return $this->
getMatrix($i0, 0, $i0 + 1, $this->n);
364 return $this->
getMatrix(0, $j0, $this->m, $jF + 1);
366 return $this->
getMatrix(0, $j0, $this->m, $j0 + 1);
384 $R->set($j, $i, $this->A[$i][$j]);
399 $n = min($this->m, $this->n);
400 for($i = 0; $i <
$n; ++$i) {
401 $s += $this->A[$i][$i];
425 if (func_num_args() > 0) {
426 $args = func_get_args();
427 $match = implode(
",", array_map(
'gettype', $args));
443 $M->set($i, $j, $M->get($i, $j) + $this->A[$i][$j]);
461 if (func_num_args() > 0) {
462 $args = func_get_args();
463 $match = implode(
",", array_map(
'gettype', $args));
480 $value = $M->get($i, $j);
481 if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
482 $this->A[$i][$j] = trim($this->A[$i][$j],
'"');
485 if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) {
486 $value = trim($value,
'"');
490 $this->A[$i][$j] += $value;
511 if (func_num_args() > 0) {
512 $args = func_get_args();
513 $match = implode(
",", array_map(
'gettype', $args));
529 $M->set($i, $j, $M->get($i, $j) - $this->A[$i][$j]);
547 if (func_num_args() > 0) {
548 $args = func_get_args();
549 $match = implode(
",", array_map(
'gettype', $args));
566 $value = $M->get($i, $j);
567 if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
568 $this->A[$i][$j] = trim($this->A[$i][$j],
'"');
571 if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) {
572 $value = trim($value,
'"');
576 $this->A[$i][$j] -= $value;
598 if (func_num_args() > 0) {
599 $args = func_get_args();
600 $match = implode(
",", array_map(
'gettype', $args));
616 $M->set($i, $j, $M->get($i, $j) * $this->A[$i][$j]);
635 if (func_num_args() > 0) {
636 $args = func_get_args();
637 $match = implode(
",", array_map(
'gettype', $args));
654 $value = $M->get($i, $j);
655 if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
656 $this->A[$i][$j] = trim($this->A[$i][$j],
'"');
659 if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) {
660 $value = trim($value,
'"');
664 $this->A[$i][$j] *= $value;
686 if (func_num_args() > 0) {
687 $args = func_get_args();
688 $match = implode(
",", array_map(
'gettype', $args));
705 $value = $M->get($i, $j);
706 if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
707 $this->A[$i][$j] = trim($this->A[$i][$j],
'"');
710 if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) {
711 $value = trim($value,
'"');
717 $M->set($i, $j,
'#DIV/0!');
719 $M->set($i, $j, $this->A[$i][$j] / $value);
742 if (func_num_args() > 0) {
743 $args = func_get_args();
744 $match = implode(
",", array_map(
'gettype', $args));
760 $this->A[$i][$j] = $this->A[$i][$j] / $M->get($i, $j);
779 if (func_num_args() > 0) {
780 $args = func_get_args();
781 $match = implode(
",", array_map(
'gettype', $args));
797 $M->set($i, $j, $M->get($i, $j) / $this->A[$i][$j]);
816 if (func_num_args() > 0) {
817 $args = func_get_args();
818 $match = implode(
",", array_map(
'gettype', $args));
834 $this->A[$i][$j] = $M->get($i, $j) / $this->A[$i][$j];
852 if (func_num_args() > 0) {
853 $args = func_get_args();
854 $match = implode(
",", array_map(
'gettype', $args));
859 if ($this->n == $B->m) {
861 for($j = 0; $j < $B->n; ++$j) {
863 $Bcolj[$k] = $B->A[$k][$j];
866 $Arowi = $this->A[$i];
869 $s += $Arowi[$k] * $Bcolj[$k];
881 if ($this->n == $B->m) {
883 for($i = 0; $i < $C->m; ++$i) {
884 for($j = 0; $j < $C->n; ++$j) {
886 for($k = 0; $k < $C->n; ++$k) {
887 $s += $this->A[$i][$k] * $B->A[$k][$j];
900 for($i = 0; $i < $C->m; ++$i) {
901 for($j = 0; $j < $C->n; ++$j) {
902 $C->A[$i][$j] *= $args[0];
909 for($i = 0; $i < $C->m; ++$i) {
910 for($j = 0; $j < $C->n; ++$j) {
911 $C->A[$i][$j] = $args[0] * $this->A[$i][$j];
918 for($i = 0; $i < $C->m; ++$i) {
919 for($j = 0; $j < $C->n; ++$j) {
920 $C->A[$i][$j] *= $args[0];
943 if (func_num_args() > 0) {
944 $args = func_get_args();
945 $match = implode(
",", array_map(
'gettype', $args));
962 $value = $M->get($i, $j);
963 if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
964 $this->A[$i][$j] = trim($this->A[$i][$j],
'"');
967 if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) {
968 $value = trim($value,
'"');
972 $this->A[$i][$j] = pow($this->A[$i][$j],$value);
993 if (func_num_args() > 0) {
994 $args = func_get_args();
995 $match = implode(
",", array_map(
'gettype', $args));
1010 $this->A[$i][$j] = trim($this->A[$i][$j],
'"').trim($M->get($i, $j),
'"');
1027 if ($this->m == $this->n) {
1029 return $LU->solve($B);
1032 return $QR->solve($B);
const MatrixDimensionException
const PolymorphicArgumentException
const ArrayLengthException
const ArgumentTypeException
const ArgumentBoundsException
JAMAError($errorNumber=null)
Custom error handler.
An exception for terminatinating execution or to throw for unit testing.
inverse()
Matrix inverse or pseudoinverse.
getMatrixByRow($i0=null, $iF=null)
getMatrixByRow
getRowDimension()
getRowDimension
identity($m=null, $n=null)
identity
diagonal($m=null, $n=null, $c=1)
diagonal
arrayLeftDivide()
arrayLeftDivide
arrayRightDivide()
arrayRightDivide
const ArgumentTypeException
const MatrixDimensionException
const ArrayLengthException
getColumnDimension()
getColumnDimension
arrayTimesEquals()
arrayTimesEquals
arrayLeftDivideEquals()
arrayLeftDivideEquals
const PolymorphicArgumentException
__construct()
Polymorphic constructor.
arrayRightDivideEquals()
arrayRightDivideEquals
checkMatrixDimensions($B=null)
checkMatrixDimensions
getMatrixByCol($j0=null, $jF=null)
getMatrixByCol
const ArgumentBoundsException
static convertToNumberIfFraction(&$operand)
Identify whether a string contains a fractional numeric value, and convert it to a numeric if it is.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'