/usr/lib/ruby/vendor_ruby/numru/lapack.rb is in ruby-lapack 1.5-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | require "narray"
require "numru/lapack.so"
class NMatrix
# to lapack matrix
def to_lm
NArray.ref(self.transpose)
end
# to lapack band matrix
def to_lb(kl, ku, shift=0)
n = shape[0]
na = NArray.ref(self)
lb = NArray.new(typecode, kl+ku+1+shift, n)
n.times do |j|
i0 = [n-1,j+kl].min
i1 = [0,j-ku].max
l = i0 - i1 + 1
lb[-i1-1..-i0-1,j] = na[j,i0..i1]
end
lb
end
# to lapack symmetrix band matrix
def to_lsb(uplo, kd)
n = shape[0]
lsb = NArray.new(typecode, kd+1, n)
na = NArray.ref(self)
case uplo
when /U/i
n.times do |j|
i0 = [0,j-kd].max
i1 = j
lsb[i0+kd-j..i1+kd-j, j] = na[j,i0..i1]
end
when /L/i
n.times do |j|
i0 = j
i1 = [n-1,j+kd].min
lsb[i0-j..i1-j, j] = na[j,i0..i1]
end
else
raise "uplo is invalid"
end
lsb
end
end
|