Skip to content

Instantly share code, notes, and snippets.

@Kumassy
Created May 2, 2016 16:01
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 Kumassy/d6bd01c1d2f61ec803d68ac189993653 to your computer and use it in GitHub Desktop.
Save Kumassy/d6bd01c1d2f61ec803d68ac189993653 to your computer and use it in GitHub Desktop.
a_(i,i)=1,a_(i,i-1)=1,a_(i,i+1)=1な行列を生成するスクリプト
require 'matrix'
# 情報数学概論の検証
def matrix(row_size,col_size = row_size)
Matrix.build(row_size, col_size) do | row,col |
if (row == col) || row == col +1 || row + 1 == col
1
else
0
end
end
end
1.upto 50 do |i|
puts "n=#{i}: #{matrix(i).det}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment