Class: NuLin::LLS_QR
Instance Attribute Summary
Attributes inherited from LLS
Instance Method Summary collapse
- #compute ⇒ Object
-
#initialize(a, b, options) ⇒ LLS_QR
constructor
A new instance of LLS_QR.
Methods inherited from LLS
Constructor Details
#initialize(a, b, options) ⇒ LLS_QR
Returns a new instance of LLS_QR.
76 77 78 79 |
# File 'lib/nulin/lls.rb', line 76 def initialize(a, b, ) super compute end |
Instance Method Details
#compute ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/nulin/lls.rb', line 81 def compute m, n = @a.shape lda = m ldb = [1, m, n].max r, nrhs = @b.shape b = NVector.new(@typecode, ldb, nrhs) b[0...m, 0...nrhs] = @b lwork = [1, [m,n].min + [[m,n].min, nrhs].max].max work = NArray.new(@typecode, lwork) NuLin::Native.call(@typecode, "gels", "N", m, n, nrhs, @a, lda, b, ldb, work, lwork, 0) @solution = b[0...n, true] @solution.flatten! if @b_is_rank1 end |