QR decomposition: Difference between revisions
→Library QR, gonum/matrix: update for library changes, also reorganize code a bit.
(→{{header|Go}}: add gonum/matrix solution) |
(→Library QR, gonum/matrix: update for library changes, also reorganize code a bit.) |
||
Line 1,116:
===Library QR, gonum/matrix===
<lang go>
"fmt"
Line 1,132 ⟶ 1,130:
})
f := mat64.QR(a)
fmt.Printf("q:
fmt.Printf("r:
// task 2: use qr decomp for polynomial regression example
x :=
y
fmt.Printf("polyfit:
mat64.Formatted(mat64.QR(a).Solve(b), mat64.Prefix(" ")))
}
func
for
v *= i1▼
}
}
▲ f := mat64.QR(a)
}</lang>
▲ return f.Solve(y)
{{out}}
<pre>
q: ⎡-0.857 0.394 -0.331⎤
▲⎣ 0.000 0.000 35.000⎦
polyfit: ⎡1.000⎤
⎣3.000⎦▼
▲⎣3.000⎦
</pre>
|