Class: Quartz::Function
- Inherits:
-
Object
- Object
- Quartz::Function
- Defined in:
- lib/rubyquartz/function.rb
Instance Method Summary collapse
-
#evaluate(input, output) ⇒ Object
input is a domain-lengthed array of Numerics output is a domain-lenghted array of Numerics OPTIMIZATION: Keep these arrays around in C-land to avoid reallocating them on each call?.
-
#initialize(domain, range) ⇒ Function
constructor
domain/range are each an array of Ranges when creating the CGFunctionRef: info = self domainDimention = domain.length domain = C array built from ‘domain’ as above for rangeDimention and range callbacks: evaluate -> #evaluate on the instance releaseInfo -> nothing since the info should only get released if we get GC’d?.
Constructor Details
#initialize(domain, range) ⇒ Function
domain/range are each an array of Ranges when creating the CGFunctionRef:
info = self
domainDimention = domain.length
domain = C array built from 'domain'
as above for rangeDimention and range
callbacks:
evaluate -> #evaluate on the instance
releaseInfo -> nothing since the info should only get released if we get GC'd?
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rubyquartz/function.rb', line 38 def initialize(domain, range) # Flatten the domain and range arrays of ranges to interleaved start/end pairs. # The length values should be the count of ranges, not the count of flattended values flattened_domain = [] domain.each {|r| flattened_domain << r.begin << r.end} flattened_range = [] range.each {|r| flattened_range << r.begin << r.end} _initialize(domain.length, flattened_domain, range.length, flattened_range) end |
Instance Method Details
#evaluate(input, output) ⇒ Object
input is a domain-lengthed array of Numerics output is a domain-lenghted array of Numerics OPTIMIZATION: Keep these arrays around in C-land to avoid reallocating them on each call?
53 54 55 |
# File 'lib/rubyquartz/function.rb', line 53 def evaluate(input, output) raise "Subclasses must implement evaluate" end |