class Otohatiyau
Public Class Methods
essence_inverse_otohatiyau(a, b)
click to toggle source
# File lib/Otohatiyau.rb, line 41 def self.essence_inverse_otohatiyau(a, b) Vector[*a[0]].inner_product(Vector[*b]) + a[1] end
essence_otohatiyau(a, b)
click to toggle source
# File lib/Otohatiyau.rb, line 27 def self.essence_otohatiyau(a, b) otohatiyau = Otohatiyau::otohatiyau(a, b) [otohatiyau[0], otohatiyau[-1][-1]] end
inverse_otohatiyau(b, q, r)
click to toggle source
# File lib/Otohatiyau.rb, line 32 def self.inverse_otohatiyau(b, q, r) a = 0 b.each_with_index do |v, k| a += v * q[k] end a += r[-1] a end
otohatiyau(a, b)
click to toggle source
# File lib/Otohatiyau.rb, line 5 def self.otohatiyau(a, b) q = Array.new r = Array.new b.each_with_index do |v, k| q[k] = if k == 0 then a / b[k] else r[k - 1] / b[k] end r[k] = if k == 0 then a % b[k] else r[k - 1] % b[k] end end [q, r] end