mirror of
https://github.com/gonum/gonum.git
synced 2025-10-09 00:50:16 +08:00
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:
10
mat64/qr.go
10
mat64/qr.go
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user