27        private $QR = array();
 
   57                        $this->QR = $A->getArrayCopy();
 
   58                        $this->m  = $A->getRowDimension();
 
   59                        $this->n  = $A->getColumnDimension();
 
   65                                        $nrm = 
hypo($nrm, $this->QR[
$i][$k]);
 
   69                                        if ($this->QR[$k][$k] < 0) {
 
   73                                                $this->QR[
$i][$k] /= $nrm;
 
   75                                        $this->QR[$k][$k] += 1.0;
 
   77                                        for ($j = $k+1; $j < 
$this->n; ++$j) {
 
   80                                                        $s += $this->QR[
$i][$k] * $this->QR[
$i][$j];
 
   82                                                $s = -
$s/$this->QR[$k][$k];
 
   84                                                        $this->QR[
$i][$j] += 
$s * $this->QR[
$i][$k];
 
   88                                $this->Rdiag[$k] = -$nrm;
 
  103                        if ($this->Rdiag[$j] == 0) {
 
  120                                        $H[
$i][$j] = $this->QR[
$i][$j];
 
  139                                        $R[
$i][$j] = $this->QR[
$i][$j];
 
  140                                } elseif (
$i == $j) {
 
  141                                        $R[
$i][$j] = $this->Rdiag[
$i];
 
  157                for ($k = $this->n-1; $k >= 0; --$k) {
 
  162                        for ($j = $k; $j < 
$this->n; ++$j) {
 
  163                                if ($this->QR[$k][$k] != 0) {
 
  166                                                $s += $this->QR[
$i][$k] * $Q[
$i][$j];
 
  168                                        $s = -
$s/$this->QR[$k][$k];
 
  170                                                $Q[
$i][$j] += 
$s * $this->QR[
$i][$k];
 
  195                if ($B->getRowDimension() == $this->m) {
 
  198                                $nx = $B->getColumnDimension();
 
  199                                $X  = $B->getArrayCopy();
 
  202                                        for ($j = 0; $j < $nx; ++$j) {
 
  205                                                        $s += $this->QR[
$i][$k] * $X[
$i][$j];
 
  207                                                $s = -
$s/$this->QR[$k][$k];
 
  209                                                        $X[
$i][$j] += 
$s * $this->QR[
$i][$k];
 
  214                                for ($k = $this->n-1; $k >= 0; --$k) {
 
  215                                        for ($j = 0; $j < $nx; ++$j) {
 
  216                                                $X[$k][$j] /= $this->Rdiag[$k];
 
  218                                        for (
$i = 0; 
$i < $k; ++
$i) {
 
  219                                                for ($j = 0; $j < $nx; ++$j) {
 
  220                                                        $X[
$i][$j] -= $X[$k][$j]* $this->QR[
$i][$k];
 
  225                                return ($X->getMatrix(0, $this->n-1, 0, $nx));
 
An exception for terminatinating execution or to throw for unit testing.
const ArgumentTypeException
const MatrixDimensionException
const MatrixRankException
getR()
Return the upper triangular factor.
__construct($A)
QR Decomposition computed by Householder reflections.
getQ()
Generate and return the (economy-sized) orthogonal factor.
isFullRank()
Is the matrix full rank?
solve($B)
Least squares solution of A*X = B.
getH()
Return the Householder vectors.
const MatrixRankException