class CAS::Constant
Constant
is a `CAS::Op` container for a `Numeric` value, that is not a `CAS::Variable`, thus its derivative it is always zero
Public Class Methods
# File lib/numbers/constants.rb, line 36 def initialize(x) @x = x end
Public Instance Methods
Check if a constant is equal to another `CAS::Op` object
* **argument**: `CAs::Op` * **returns**: `TrueClass` or `FalseClass`
# File lib/numbers/constants.rb, line 107 def ==(op) if op.is_a? CAS::Constant return @x == op.x else return false end end
Args of a constant is an empty `Array`
* **returns**: `Array` empty
# File lib/numbers/constants.rb, line 99 def args [] end
Calling a constant will return the value of the constant itself.
* **argument**: Unused argument * **returns**: `Numeric` value of the constant
# File lib/numbers/constants.rb, line 57 def call(_f) @x end
There is no dependency in a constant, thus this method will always return false
* **argument**: Unused argument * **returns**: `FalseClass`
# File lib/numbers/constants.rb, line 66 def depend?(_v) false end
Evaluates the derivative of a constant. The derivative is always a `CAS::Zero`
“`
d
– c = 0 dx “`
# File lib/numbers/constants.rb, line 48 def diff(_v) CAS::Zero end
Inspection for `CAS::Constant` class
* **returns**: `String`
# File lib/numbers/constants.rb, line 118 def inspect "Const(#{self})" end
Simplification callback. It simplify the subgraph of each node until all possible simplification are performed (thus the execution time is not deterministic).
* **returns**: `CAS::Op` simplified version
# File lib/numbers/constants.rb, line 91 def simplify return self end
Subs for a constant is a dummy method that returns always `self`
* **argument**: Unused argument * **returns**: `CAS::Constant` that represent `self`
# File lib/numbers/constants.rb, line 82 def subs(_dt) return self end
Return the local Graphviz node of the tree
* **returns**: `String` of local Graphiz node
# File lib/Mr.CAS/graphviz.rb, line 85 def to_dot "Const(#{@x})" end
The string representation of a constant is the value of the constant
* **returns**: `String`
# File lib/numbers/constants.rb, line 74 def to_s "#{@x}" end