Class: DTW::Bands::SakoeChiba
- Inherits:
-
Data
- Object
- Data
- DTW::Bands::SakoeChiba
- Defined in:
- lib/dtwrb/bands.rb,
sig/dtwrb.rbs
Instance Attribute Summary collapse
-
#ratio ⇒ Object
readonly
Returns the value of attribute ratio.
Class Method Summary collapse
Instance Method Summary collapse
- #bounds(row, rows, columns) ⇒ [::Integer, ::Integer]
-
#initialize(ratio:) ⇒ SakoeChiba
constructor
A new instance of SakoeChiba.
-
#radius(length_a, length_b) ⇒ ::Integer
The |n - m| + 1 term keeps at least one path feasible when the lengths differ widely.
- #to_h ⇒ ::Hash[::Symbol, untyped]
- #with ⇒ SakoeChiba
Constructor Details
#initialize(ratio:) ⇒ SakoeChiba
Returns a new instance of SakoeChiba.
6 7 8 9 10 11 |
# File 'lib/dtwrb/bands.rb', line 6 def initialize(ratio:) width = Float(ratio) raise ArgumentError, "band ratio must be non-negative, got #{width}" if width.negative? super(ratio: width) end |
Instance Attribute Details
#ratio ⇒ Object (readonly)
Returns the value of attribute ratio
5 6 7 |
# File 'lib/dtwrb/bands.rb', line 5 def ratio @ratio end |
Class Method Details
.new ⇒ SakoeChiba
118 |
# File 'sig/dtwrb.rbs', line 118
def self.new: (ratio: ::Numeric) -> SakoeChiba
|
Instance Method Details
#bounds(row, rows, columns) ⇒ [::Integer, ::Integer]
18 19 20 21 |
# File 'lib/dtwrb/bands.rb', line 18 def bounds(row, rows, columns) width = radius(rows, columns) [row - width, row + width] end |
#radius(length_a, length_b) ⇒ ::Integer
The |n - m| + 1 term keeps at least one path feasible when the lengths differ widely.
14 15 16 |
# File 'lib/dtwrb/bands.rb', line 14 def radius(length_a, length_b) [(ratio * [length_a, length_b].max).ceil, (length_a - length_b).abs + 1].max end |
#to_h ⇒ ::Hash[::Symbol, untyped]
122 |
# File 'sig/dtwrb.rbs', line 122
def to_h: () -> ::Hash[::Symbol, untyped]
|