up previous next
AlmostQR

QR decomposition of a matrix

Syntax
AlmostQR(M: MAT): RECORD

Description
This function computes the decomposition of the matrix into an orthogonal and an upper triangular matrix with 1 on the diagonal. [orthogonal meaning that QT * Q is a diagonal matrix]

The auxiliary (possibly slow!) function Mat.SimplifySquareFactorsInAQR modifies Q and R in the decomposition so that the entries of the diagonal matrix QT * Q are squarefree rationals.

Example
/**/  M := matrix([ [4, -2, 3],  [3, 2, -2],  [0, 0, 3] ]);
/**/  Dec := AlmostQR(M);
/**/  Dec;
record[Q := matrix(QQ,
 [[4, -42/25, 0],
  [3, 56/25, 0],
  [0, 0, 3]])
, R := matrix(QQ,
 [[1, -2/25, 6/25],
  [0, 1, -17/14],
  [0, 0, 1]])
]

/**/  $mat.SimplifySquareFactorsInAQR(ref Dec);
/**/  Dec;
record[Q := matrix(QQ,
 [[4/5, -3/5, 0],
  [3/5, 4/5, 0],
  [0, 0, 1]])
, R := matrix(QQ,
 [[5, -2/5, 6/5],
  [0, 14/5, -17/5],
  [0, 0, 3]])
, SqDiag := [1, 1, 1]]

See Also