Class: Function

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

Instance Method Summary collapse

Constructor Details

#initializeFunction

Returns a new instance of Function.


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

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


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

def eps ;@eps ;end

#oneObject


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

def one ;@one ;end

#tenObject


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

def ten ;@ten ;end

#twoObject


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

def two ;@two ;end

#values(x) ⇒ Object

<= defines functions solved


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

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


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

def zero;@zero;end