class Real

Attributes

continuedFraction[RW]
update_eval[RW]

Public Class Methods

continuedFractionFactory(a) click to toggle source
# File lib/m500.rb, line 3002
def Real::continuedFractionFactory(a)
  init=true
  b =  a.pop(2)
  tmp1 = "Fraction(Zahlen(#{b.at(0)}),Quotient(Zahlen(1),#{b.at(1)}))"
  tmp0 = ""
  a.reverse.each{|x|
    break if x.nil?
    tmp0 = "Fraction(Zahlen(#{x}),Quotient(Zahlen(1),(#{tmp1})))"
    tmp1 = tmp0
    tmp0 = ""
  }
  tmp1
end
defines() click to toggle source
# File lib/m500.rb, line 2951
def Real.defines
  @@threebareqs.encode('utf-8')
end
epsilon(e) click to toggle source
# File lib/m500.rb, line 2975
def Real::epsilon(e)
  #on epsilon change flag for dirty and recalculate
end
gcontinuedFractionFactory(a,y=true) click to toggle source
# File lib/m500.rb, line 3015
def Real::gcontinuedFractionFactory(a,y=true)
  Kettenbruch::allseitigfactory(a,y)
end
new!(a,b,label='') click to toggle source
# File lib/m500.rb, line 2954
def Real.new!(a,b,label='')
  if a.kind_of?(Real)
    a
  elsif a.kind_of?(Array)
    z = eval(gcontinuedFractionFactory(a))
    new(z.to_Q,b)
  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?(EmptySetClass) 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
s_add(a,b,label='') click to toggle source
# File lib/m500.rb, line 2972
def Real.s_add(a,b,label='')
  @@reals[label] = b
end

Private Class Methods

new(lbl,definitn,irrat) click to toggle source
# File lib/m500.rb, line 2979
def initialize(lbl,definitn,irrat)
  @label = lbl
  @equality_by_definition_symbols  = ["==",Real.defines]
  @definitn = definitn
  @rat = definitn
  @irrat = irrat
  @k = 5
  @k0 = 0
  @update_eval = proc{ ret = Quotient(0,1) ; (@k0..@k).to_a.each{|n| ret += @irrat.call(n)}; ret}
  @continuedfraction
end

Public Instance Methods

to_Ball() click to toggle source
# File lib/m500.rb, line 3018
def to_Ball
  rad = @@epsilon / Quotient(2,1)
  "(#{@rat - rad} .. #{@rat + rad})"
end
to_Ball!() click to toggle source
# File lib/m500.rb, line 3022
def to_Ball!
  rad = @@epsilon / Quotient(2,1)
  tmp = @rat - rad
  tmp.setdelta
  (tmp..(@rat + rad))
end
to_Dec() click to toggle source
# File lib/m500.rb, line 3034
def to_Dec
  @rat.to_Dec
end
to_Frac() click to toggle source
# File lib/m500.rb, line 3031
def to_Frac
  @rat.to_Frac
end
to_N() click to toggle source
# File lib/m500.rb, line 3046
def to_N
  @rat.to_N
end
to_N0() click to toggle source
# File lib/m500.rb, line 3043
def to_N0
  @rat.to_N0
end
to_Q() click to toggle source
# File lib/m500.rb, line 3037
def to_Q
  @rat.to_Q
end
to_Z() click to toggle source
# File lib/m500.rb, line 3040
def to_Z
  @rat.to_Z
end
to_a() click to toggle source
# File lib/m500.rb, line 3028
def to_a
  to_Ball!.to_a
end
to_s() click to toggle source
# File lib/m500.rb, line 3049
def to_s
  "#{@label} #{Real.defines} #{@definitn}"
end
to_sgml() click to toggle source
# File lib/m500.rb, line 2948
def to_sgml
  "<mn #{sgml_id}class='Real'>#{@a}</mn>"
end
updateApprox(&block) click to toggle source
# File lib/m500.rb, line 2990
def updateApprox(&block)
  instance_exec(&block)
end
updateApprox1() click to toggle source
# File lib/m500.rb, line 2993
def updateApprox1
  @rat += @update_eval.call
  #    instance_eval(@update_eval.call)
end