Created
May 2, 2016 16:01
-
-
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な行列を生成するスクリプト
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 '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