Module: DSP::Dct
- Defined in:
- lib/dsprb/dct.rb,
sig/dsprb.rbs
Class Method Summary collapse
Class Method Details
.two(values, count) ⇒ ::Array[::Float]
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/dsprb/dct.rb', line 8 def two(values, count) length = values.length raise ArgumentError, "count must be positive, got #{count}" unless count.positive? Array.new(count) do |coefficient| total = 0.0 index = 0 while index < length total += values[index] * Math.cos(Math::PI * coefficient * (index + 0.5) / length) index += 1 end total end end |