Module: NMatrix::FactorizeLUMethods
- Defined in:
- lib/nmatrix/math.rb
Overview
Methods for generating permutation matrix from LU factorization results.
Class Method Summary collapse
Class Method Details
.permutation_array_for(pivot_array) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/nmatrix/math.rb', line 51 def permutation_array_for(pivot_array) perm_arry = Array.new(pivot_array.size) { |i| i } perm_arry.each_index do |i| #the pivot indices returned by LAPACK getrf are indexed starting #from 1, so we need to subtract 1 here perm_arry[i], perm_arry[pivot_array[i]-1] = perm_arry[pivot_array[i]-1], perm_arry[i] end perm_arry end |