Module: Digiproc::Convolvable::ClassMethods
- Included in:
- Functions
- Defined in:
- lib/concerns/convolvable.rb
Overview
This module contains class methods for performing convolution based off a strategy. Digiproc::Convolvable extends ClassMethods, and therefore all methods can be called on the Convolable module. Note that arrays in this module must be of Numeric types
Instance Method Summary collapse
-
#acorr(data) ⇒ Object
Alias to #auto_correlation ie: Digiproc::Convolvable.acorr() # => [3, 8, 14, 8, 3].
-
#auto_correlation(data) ⇒ Object
auto_correlation(data [Array]) => returns Array Uses the cross_correlation method to perform cross correlation of data on itself.
-
#conv(data1, data2, strategy = Digiproc::Strategies::BFConvolutionStrategy) ⇒ Object
Alias to #convolve.
-
#convolve(data1, data2, strategy = Digiproc::Strategies::BFConvolutionStrategy) ⇒ Object
convolve(data1 [Array], data2 [Array], strategy [ConvolutionStrategy]) => returns Array This method performs convolution.
-
#cross_correlation(data1, data2) ⇒ Object
cross_correlation(data1 [Array], data2 [Array]) => returns Array Uses the #conv method to perform cross_correlation by reversing the second data set order Does not accept a strategy as a third parameter Digiproc::Convolvable.cross_correlation(arr1, arr2).
-
#xcorr(data1, data2) ⇒ Object
Alias to #cross_correlation.
Instance Method Details
#acorr(data) ⇒ Object
Alias to #auto_correlation ie: Digiproc::Convolvable.acorr() # => [3, 8, 14, 8, 3]
56 57 58 |
# File 'lib/concerns/convolvable.rb', line 56 def acorr(data) cross_correlation(data, data) end |
#auto_correlation(data) ⇒ Object
auto_correlation(data [Array]) => returns Array Uses the cross_correlation method to perform cross correlation of data on itself. Digiproc::Convolvable.auto_correlation() # => [3, 8, 14, 8, 3]
47 48 49 |
# File 'lib/concerns/convolvable.rb', line 47 def auto_correlation(data) cross_correlation(data, data) end |
#conv(data1, data2, strategy = Digiproc::Strategies::BFConvolutionStrategy) ⇒ Object
Alias to #convolve
24 25 26 |
# File 'lib/concerns/convolvable.rb', line 24 def conv(data1, data2, strategy = Digiproc::Strategies::BFConvolutionStrategy) strategy.conv(data1,data2) end |
#convolve(data1, data2, strategy = Digiproc::Strategies::BFConvolutionStrategy) ⇒ Object
convolve(data1 [Array], data2 [Array], strategy [ConvolutionStrategy]) => returns Array This method performs convolution. ‘strategy` can be custom-written as long as it matches the ConvolutionStrategy interface: have a class method called `conv` which takes 2 arrays and convolves them. ie: Digiproc::Convolvable.conv(,[1,2,3]) #=> [1, 4, 10, 12, 9]
18 19 20 |
# File 'lib/concerns/convolvable.rb', line 18 def convolve(data1, data2, strategy = Digiproc::Strategies::BFConvolutionStrategy) strategy.conv(data1, data2, strategy) end |
#cross_correlation(data1, data2) ⇒ Object
cross_correlation(data1 [Array], data2 [Array]) => returns Array Uses the #conv method to perform cross_correlation by reversing the second data set order Does not accept a strategy as a third parameter Digiproc::Convolvable.cross_correlation(arr1, arr2)
33 34 35 |
# File 'lib/concerns/convolvable.rb', line 33 def cross_correlation(data1, data2) conv(data1, data2.reverse) end |
#xcorr(data1, data2) ⇒ Object
Alias to #cross_correlation
39 40 41 |
# File 'lib/concerns/convolvable.rb', line 39 def xcorr(data1, data2) cross_correlation(data1, data2) end |