Class: DTW::Bands::SakoeChiba

Inherits:
Data
  • Object
show all
Defined in:
lib/dtwrb/bands.rb,
sig/dtwrb.rbs

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ratio:) ⇒ SakoeChiba

Returns a new instance of SakoeChiba.

Raises:

  • (ArgumentError)


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

#ratioObject (readonly)

Returns the value of attribute ratio

Returns:

  • (Object)

    the current value of ratio



5
6
7
# File 'lib/dtwrb/bands.rb', line 5

def ratio
  @ratio
end

Class Method Details

.newSakoeChiba

Parameters:

  • ratio: (::Numeric)

Returns:



117
# File 'sig/dtwrb.rbs', line 117

def self.new: (ratio: ::Numeric) -> SakoeChiba

Instance Method Details

#radius(length_a, length_b) ⇒ ::Integer

The |n - m| + 1 term keeps at least one path feasible when the lengths differ widely.

Parameters:

  • (::Integer)
  • (::Integer)

Returns:

  • (::Integer)


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]

Returns:

  • (::Hash[::Symbol, untyped])


120
# File 'sig/dtwrb.rbs', line 120

def to_h: () -> ::Hash[::Symbol, untyped]

#withSakoeChiba

Parameters:

  • (Object)

Returns:



119
# File 'sig/dtwrb.rbs', line 119

def with: (**untyped) -> SakoeChiba