Module: Num4EquLib
- Extended by:
- FFI::Library
- Defined in:
- lib/num4equ.rb
Overview
数値計算による方程式の解法ライブラリ
Class Method Summary collapse
-
.bisection(a, b, func) ⇒ double
二分法による解法.
-
.newtonMethod(a, func) ⇒ double
ニュートン法による解法.
-
.secantMethod(a, b, func) ⇒ double
割線法による解法.
Instance Method Summary collapse
Class Method Details
.bisection(a, b, func) ⇒ double
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/num4equ.rb', line 47 def bisectionMethod(a, b, func) ok_ptr = FFI::MemoryPointer.new :int x = bisectionMethodFFI(a, b, func, ok_ptr) ok = ok_ptr.read_int ok_ptr.free() if ok < 0 then raise RangeError.new("a:" + a.to_s + " " + "b:" + b.to_s) end return x end |
.newtonMethod(a, func) ⇒ double
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/num4equ.rb', line 30 def newtonMethod(a, func) ok_ptr = FFI::MemoryPointer.new :int x = newtonMethodFFI(a, func, ok_ptr) ok = ok_ptr.read_int ok_ptr.free() if ok < 0 then raise RangeError.new("a:" + a.to_s) end return x end |
.secantMethod(a, b, func) ⇒ double
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/num4equ.rb', line 64 def secantMethod(a, b, func) ok_ptr = FFI::MemoryPointer.new :int x = secantMethodFFI(a, b, func, ok_ptr) ok = ok_ptr.read_int ok_ptr.free() if ok < 0 then raise RangeError.new("a:" + a.to_s + " " + "b:" + b.to_s) end return x end |
Instance Method Details
#func(a) {|a| ... } ⇒ double
15 |
# File 'lib/num4equ.rb', line 15 callback :f, [:double], :double |