class Sigma
Attributes
k[RW]
k0[RW]
update_proc[RW]
Public Class Methods
epsilon(e)
click to toggle source
# File lib/M500_containers.rb, line 360 def Sigma::epsilon(e) #on epsilon change flag for dirty and recalculate end
new(rat,irrat,abs=1)
click to toggle source
# File lib/M500_containers.rb, line 363 def initialize(rat,irrat,abs=1) @absolute = abs @rat = rat @irrat = irrat @k = 1 @k0 = 0 @update_proc = proc{ ret = Quotient(0,1) ; (@k0..@k).to_a.each{|n| ret += @irrat.call(n)}; ret} end
new!(a,b)
click to toggle source
# File lib/M500_containers.rb, line 342 def Sigma.new!(a,b) if a.kind_of?(Sigma) a elsif a.kind_of?(Quotient) new(a,b) elsif a.kind_of?(Natural) or a.kind_of?(Counting) or a.kind_of?(Zahlen) or a.kind_of?(Fraction) or a.kind_of?(Decimal) elsif new(a.to_Q,b) elsif a.kind_of?(NaughtClass) or a.kind_of?(EmptyListClass) or a.kind_of?(NilClass) a unless b new(Quotinet(0,1),b) if b elsif a.kind_of?(NANClass) or a.kind_of?(InfinityClass) a end end
Public Instance Methods
convergents()
click to toggle source
# File lib/M500_containers.rb, line 372 def convergents [] end
irrational()
click to toggle source
# File lib/M500_containers.rb, line 375 def irrational true ? false : true end
next()
click to toggle source
# File lib/M500_containers.rb, line 396 def next t = @k @k0 = t @k += 1 @rat += @update_proc.call t = @k @k0 = t @k += 1 end
rational?()
click to toggle source
# File lib/M500_containers.rb, line 378 def rational? true ? true : false end
to_Dec()
click to toggle source
# File lib/M500_containers.rb, line 410 def to_Dec @rat.to_Dec end
to_Q()
click to toggle source
# File lib/M500_containers.rb, line 407 def to_Q @rat end
to_a()
click to toggle source
# File lib/M500_containers.rb, line 381 def to_a convergents end
to_s()
click to toggle source
# File lib/M500_containers.rb, line 384 def to_s e = "" e = "-" if @absolute == -1 # @update_proc end
updateApprox(&block)
click to toggle source
# File lib/M500_containers.rb, line 389 def updateApprox(&block) instance_exec(&block) end
updateApprox1()
click to toggle source
# File lib/M500_containers.rb, line 392 def updateApprox1 @rat += @update_proc.call # instance_eval(@update_eval.call) end