Class: Function

Inherits:
Object
  • Object
show all
Defined in:
sample/nlsolve.rb

Overview

:nodoc: all

Instance Method Summary collapse

Constructor Details

#initializeFunction

Returns a new instance of Function.



14
15
16
17
18
19
20
# File 'sample/nlsolve.rb', line 14

def initialize()
  @zero = BigDecimal.new("0.0")
  @one  = BigDecimal.new("1.0")
  @two  = BigDecimal.new("2.0")
  @ten  = BigDecimal.new("10.0")
  @eps  = BigDecimal.new("1.0e-16")
end

Instance Method Details

#epsObject



25
# File 'sample/nlsolve.rb', line 25

def eps ;@eps ;end

#oneObject



22
# File 'sample/nlsolve.rb', line 22

def one ;@one ;end

#tenObject



24
# File 'sample/nlsolve.rb', line 24

def ten ;@ten ;end

#twoObject



23
# File 'sample/nlsolve.rb', line 23

def two ;@two ;end

#values(x) ⇒ Object

<= defines functions solved



26
27
28
29
30
31
32
33
# File 'sample/nlsolve.rb', line 26

def values(x) # <= defines functions solved
  f = []
  f1 = x[0]*x[0] + x[1]*x[1] - @two # f1 = x**2 + y**2 - 2 => 0
  f2 = x[0] - x[1]                  # f2 = x    - y        => 0
  f <<= f1
  f <<= f2
  f
end

#zeroObject



21
# File 'sample/nlsolve.rb', line 21

def zero;@zero;end