qrtsol#
Purpose#
Computes the solution of \(R'x = b\) where R is an upper triangular matrix.
Format#
- x = qrtsol(b, R)#
- Parameters:
b (PxL matrix) – data
R (PxP matrix) – upper triangular matrix
- Returns:
x (PxL matrix) – solution of \(R'x = b\) where R is an upper triangular matrix
Remarks#
qrtsol() applies a forward solve to \(R'x = b\) to solve for x. Generally R
will be the R matrix from a QR factorization. qrtsol() may be used,
however, in any situation where R is upper triangular. If R is lower
triangular, transpose before calling qrtsol().
If R is not transposed, use qrsol().
Examples#
// Upper triangular matrix R
r = { 3 1,
0 2 };
b = { 7, 4 };
// Solve R'*x = b by passing R' (lower triangular) to qrtsol
x = qrtsol(b, r');
print "Solution x:";
print x;
print "R'*x (should equal b):";
print (r' * x);
The above code produces the following output:
Solution x:
2.3333333
0.83333333
R'*x (should equal b):
7.0000000
4.0000000
Source#
qrsol.src