Method: When::Coordinates::Residue::BestRationalApproximations#succ
- Defined in:
- lib/when_exe/coordinates.rb
#succ ⇒ Array<Numeric>
最良近似分数を生成する
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 |
# File 'lib/when_exe/coordinates.rb', line 561 def succ value = @current if (@count_limit.kind_of?(Numeric) && @count >= @count_limit) || (@error.kind_of?(Numeric) && @e && @error >= @e.abs) @current = nil else if @z==@k @e = 0 @current = [@p[1], @q[1], 0] else @z = 1.0/(@z-@k) @k = @z.floor @e = @p[1].to_f/@q[1]-@x.to_f/@y @current = [@p[1], @q[1], @e] @p = [@p[1], @p[1]*@k + @p[0]] @q = [@q[1], @q[1]*@k + @q[0]] end @count += 1 end return value end |