70 $nrm =
hypo($nrm, $this->QR[
$i][$k]);
74 if ($this->QR[$k][$k] < 0) {
78 $this->QR[
$i][$k] /= $nrm;
80 $this->QR[$k][$k] += 1.0;
82 for ($j = $k + 1; $j <
$this->n; ++$j) {
85 $s += $this->QR[
$i][$k] * $this->QR[
$i][$j];
87 $s = -
$s / $this->QR[$k][$k];
89 $this->QR[
$i][$j] +=
$s * $this->QR[
$i][$k];
93 $this->Rdiag[$k] = -$nrm;
107 if ($this->Rdiag[$j] == 0) {
128 $H[
$i][$j] = $this->QR[
$i][$j];
151 $R[
$i][$j] = $this->QR[
$i][$j];
152 } elseif (
$i == $j) {
153 $R[
$i][$j] = $this->Rdiag[
$i];
173 for ($k = $this->
n - 1; $k >= 0; --$k) {
178 for ($j = $k; $j <
$this->n; ++$j) {
179 if ($this->QR[$k][$k] != 0) {
182 $s += $this->QR[
$i][$k] * $Q[
$i][$j];
184 $s = -
$s / $this->QR[$k][$k];
186 $Q[
$i][$j] +=
$s * $this->QR[
$i][$k];
213 for ($j = 0; $j < $nx; ++$j) {
216 $s += $this->QR[
$i][$k] *
$X[
$i][$j];
218 $s = -
$s / $this->QR[$k][$k];
220 $X[
$i][$j] +=
$s * $this->QR[
$i][$k];
225 for ($k = $this->n - 1; $k >= 0; --$k) {
226 for ($j = 0; $j < $nx; ++$j) {
227 $X[$k][$j] /= $this->Rdiag[$k];
229 for (
$i = 0;
$i < $k; ++
$i) {
230 for ($j = 0; $j < $nx; ++$j) {
231 $X[
$i][$j] -=
$X[$k][$j] * $this->QR[
$i][$k];
237 return $X->getMatrix(0, $this->n - 1, 0, $nx);
getH()
Return the Householder vectors.
getQ()
Generate and return the (economy-sized) orthogonal factor.
getR()
Return the upper triangular factor.
if(! $in) print Initializing normalization quick check tables n
getRowDimension()
getRowDimension.
isFullRank()
Is the matrix full rank?
For an m-by-n matrix A with m >= n, the QR decomposition is an m-by-n orthogonal matrix Q and an n-by...
hypo($a, $b)
Pythagorean Theorem:.
const MATRIX_RANK_EXCEPTION
getColumnDimension()
getColumnDimension.
solve(Matrix $B)
Least squares solution of A*X = B.
__construct(Matrix $A)
QR Decomposition computed by Householder reflections.
const MATRIX_DIMENSION_EXCEPTION
Class for the creating "special" Matrices.