Module: Stick::Matrix::Hessenberg
- Defined in:
- lib/stick/matrix/hessenberg.rb
Class Method Summary collapse
-
.QR(mat) ⇒ Object
The matrix must be an upper R^(n x n) Hessenberg matrix.
Class Method Details
.QR(mat) ⇒ Object
The matrix must be an upper R^(n x n) Hessenberg matrix
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/stick/matrix/hessenberg.rb', line 11 def Hessenberg.QR(mat) r = mat.clone n = r.row_size q = Matrix.I(n) for j in (0...n-1) c, s = Givens.givens(r[j,j], r[j+1, j]) cs = Matrix[[c, s], [-s, c]] q *= Matrix.diag(Matrix.I(j), cs, Matrix.I(n - j - 2)) r[j..j+1, j..n-1] = cs.t * r[j..j+1, j..n-1] end return q, r end |