Method: Stick::Matrix::LU.factorization

Defined in:
lib/stick/matrix/lu.rb

.factorization(mat) ⇒ Object

LU factorization: A = LU where L is lower triangular and U is upper triangular



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/stick/matrix/lu.rb', line 30

def LU.factorization(mat)
  u = mat.clone
  n = u.column_size
  i = Matrix.I(n)
  l = i.clone
  (n-1).times {|k|
    mk = gauss(u, k)
    u = mk * u  # M_{n-1} * ... * M_1 * A = U
    l += i - mk  # L = M_1^{-1} * ... * M_{n-1}^{-1} = I + sum_{k=1}^{n-1} tau * e
  }
  return l, u
end