Module: MetaheuristicAlgorithms::CalculationHelper

Included in:
FunctionWrappers::EasomFunctionWrapper, FunctionWrappers::MichaelwiczFunctionWrapper
Defined in:
lib/metaheuristic_algorithms/calculation_helper.rb

Instance Method Summary collapse

Instance Method Details

#bigdecimal_acos(cos_value) ⇒ Object


37
38
39
# File 'lib/metaheuristic_algorithms/calculation_helper.rb', line 37

def bigdecimal_acos(cos_value)
  BigDecimal(Math.acos(cos_value.to_f).to_s)
end

#bigdecimal_asin(sin_value) ⇒ Object


33
34
35
# File 'lib/metaheuristic_algorithms/calculation_helper.rb', line 33

def bigdecimal_asin(sin_value)
  BigDecimal(Math.asin(sin_value.to_f).to_s)
end

#bigdecimal_atan2(y, x) ⇒ Object


41
42
43
# File 'lib/metaheuristic_algorithms/calculation_helper.rb', line 41

def bigdecimal_atan2(y, x)
  BigDecimal(Math.atan2(y.to_f, x.to_f).to_s)
end

#bigdecimal_cos(angle_in_radian) ⇒ Object


21
22
23
# File 'lib/metaheuristic_algorithms/calculation_helper.rb', line 21

def bigdecimal_cos(angle_in_radian)
  BigDecimal(Math.cos(angle_in_radian.to_f).to_s)
end

#bigdecimal_exp(bigdecimal_value) ⇒ Object


17
18
19
# File 'lib/metaheuristic_algorithms/calculation_helper.rb', line 17

def bigdecimal_exp(bigdecimal_value)
  BigDecimal(Math.exp(bigdecimal_value.to_f).to_s)
end

#bigdecimal_sin(angle_in_radian) ⇒ Object


25
26
27
# File 'lib/metaheuristic_algorithms/calculation_helper.rb', line 25

def bigdecimal_sin(angle_in_radian)
  BigDecimal(Math.sin(angle_in_radian.to_f).to_s)
end

#bigdecimal_sqrt(bigdecimal_value) ⇒ Object


45
46
47
# File 'lib/metaheuristic_algorithms/calculation_helper.rb', line 45

def bigdecimal_sqrt(bigdecimal_value)
  BigDecimal(Math.sqrt(bigdecimal_value.to_f).to_s)
end

#bigdecimal_tan(angle_in_radian) ⇒ Object


29
30
31
# File 'lib/metaheuristic_algorithms/calculation_helper.rb', line 29

def bigdecimal_tan(angle_in_radian)
  BigDecimal(Math.tan(angle_in_radian.to_f).to_s)
end

#degree_to_radian(degree) ⇒ Object


7
8
9
10
# File 'lib/metaheuristic_algorithms/calculation_helper.rb', line 7

def degree_to_radian(degree)
  # degree * BigDecimal(Math::PI.to_s) / BigDecimal('180')
  degree * Math::PI / 180
end

#radian_to_degree(radian) ⇒ Object


12
13
14
15
# File 'lib/metaheuristic_algorithms/calculation_helper.rb', line 12

def radian_to_degree(radian)
  # radian * BigDecimal('180') / BigDecimal(Math::PI.to_s)
  radian * 180 / Math::PI
end