Class: Symbolic::Misc::Sum
- Inherits:
-
Object
- Object
- Symbolic::Misc::Sum
- Includes:
- Symbolic
- Defined in:
- lib/symbolic/sum.rb
Overview
blah
Constant Summary
Constants included from Symbolic
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#lb ⇒ Object
readonly
Returns the value of attribute lb.
-
#term ⇒ Object
readonly
Returns the value of attribute term.
-
#ub ⇒ Object
readonly
Returns the value of attribute ub.
Class Method Summary collapse
Instance Method Summary collapse
- #diff(wrt) ⇒ Object
- #expand ⇒ Object
-
#initialize(term, index, lb, ub) ⇒ Sum
constructor
A new instance of Sum.
- #subs(to_replace, replacement = nil) ⇒ Object
- #value ⇒ Object
- #variables ⇒ Object
Methods included from Symbolic
#*, #**, #+, #+@, #-, #-@, #/, #coerce, #factorial, #inspect, #operations, #taylor, #to_s
Constructor Details
#initialize(term, index, lb, ub) ⇒ Sum
Returns a new instance of Sum.
8 9 10 |
# File 'lib/symbolic/sum.rb', line 8 def initialize(term,index,lb,ub) @term, @index, @lb, @ub = term, index, lb, ub end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
6 7 8 |
# File 'lib/symbolic/sum.rb', line 6 def index @index end |
#lb ⇒ Object (readonly)
Returns the value of attribute lb.
6 7 8 |
# File 'lib/symbolic/sum.rb', line 6 def lb @lb end |
#term ⇒ Object (readonly)
Returns the value of attribute term.
6 7 8 |
# File 'lib/symbolic/sum.rb', line 6 def term @term end |
#ub ⇒ Object (readonly)
Returns the value of attribute ub.
6 7 8 |
# File 'lib/symbolic/sum.rb', line 6 def ub @ub end |
Class Method Details
Instance Method Details
#diff(wrt) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/symbolic/sum.rb', line 20 def diff(wrt) #TODO: error if wrt is the index if @term.diff(wrt) != 0 Sum.new(@term.diff(wrt),@index,@lb,@ub) else 0 end end |
#expand ⇒ Object
14 15 16 |
# File 'lib/symbolic/sum.rb', line 14 def (lb..ub).collect{|ind| @term.subs(@index,ind)}.inject{|m,t| m + t} end |
#subs(to_replace, replacement = nil) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/symbolic/sum.rb', line 34 def subs(to_replace, replacement=nil) #TODO: error if to_replace is @index if replacement == nil and to_replace.is_a?(Hash) super(to_replace) else Sum.new(@term.subs(to_replace, replacement),@index,@lb,@ub) end end |
#value ⇒ Object
31 32 33 |
# File 'lib/symbolic/sum.rb', line 31 def value self..value end |
#variables ⇒ Object
17 18 19 |
# File 'lib/symbolic/sum.rb', line 17 def variables @term.variables.reject{|var| var == @index} end |