Reduce cost of row operations in QR

It is not obvious how to get similar optimisations into the Q'B
operation without allocation, so I'm leaving that.
This commit is contained in:
kortschak
2014-01-16 14:24:45 +10:30
parent f2d47be707
commit 61aa81a28f

View File

@@ -169,12 +169,14 @@ func (f QRFactor) Solve(b *Dense) (x *Dense) {
// Solve R*X = Y;
for k := n - 1; k >= 0; k-- {
for j := 0; j < bn; j++ {
b.Set(k, j, b.At(k, j)/rDiag[k])
row := b.rowView(k)
for j := range row[:bn] {
row[j] /= rDiag[k]
}
for i := 0; i < k; i++ {
for j := 0; j < bn; j++ {
b.Set(i, j, b.At(i, j)-b.At(k, j)*qr.At(i, k))
row := b.rowView(i)
for j := range row[:bn] {
row[j] -= b.At(k, j) * qr.At(i, k)
}
}
}