Skip to content

Instantly share code, notes, and snippets.

@vznvzn
Created October 13, 2017 01:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vznvzn/add2f12178b8d9db2f4cc0b9f3f1e1bc to your computer and use it in GitHub Desktop.
Save vznvzn/add2f12178b8d9db2f4cc0b9f3f1e1bc to your computer and use it in GitHub Desktop.
require 'statsample'
def sum(l)
t = 0.0
l.each { |x| t += x }
return t
end
raise if (ARGV[0].nil?)
d = "out/#{ARGV[0]}"
l = Dir.glob("#{d}/*").select { |x| x =~ /out\d+.txt$/}
n = l.size
i = n - 1
a = Kernel.eval(File.open("#{d}/out#{i}.txt").readlines[0])
l = a['lb'].map { |x| x.size }
raise if (sum(l) != 0)
vx = a['v']
vxn = Hash[[vx + ['c'], (0..vx.size).to_a].transpose]
am = (1..vx.size).map { [0] * vx.size }
vx.each \
{
|x|
(vx + ['c']).each \
{
|y|
am[vxn[x]][vxn[y]] = a[x][y] if (!a[x][y].nil?)
}
}
am = am.transpose
b = am.pop
am = am.transpose
p(vx)
p(am)
p(b)
p(Matrix[*am].eigenvalues)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment