Created
October 13, 2017 01:05
-
-
Save vznvzn/add2f12178b8d9db2f4cc0b9f3f1e1bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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