Class: Noyes::DCT
- Inherits:
-
Object
- Object
- Noyes::DCT
- Includes:
- Math, NoyesFilterDSL
- Defined in:
- lib/ruby_impl/dct.rb,
lib/common/noyes_dsl.rb
Overview
Takes the discrete cosing transform. Converts an n x m matrix to an n x order matrix. ncol should be set to m.
Instance Attribute Summary collapse
-
#melcos ⇒ Object
Returns the value of attribute melcos.
Instance Method Summary collapse
- #<<(data) ⇒ Object
-
#initialize(order, ncol) ⇒ DCT
constructor
A new instance of DCT.
Methods included from NoyesFilterDSL
Methods included from Math
#dot_product, log2, max, min
Constructor Details
#initialize(order, ncol) ⇒ DCT
Returns a new instance of DCT.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ruby_impl/dct.rb', line 9 def initialize order, ncol @melcos = [] order.times do |i| freq = PI * i.to_f / ncol ldct = Array.new ncol ncol.times do |j| ldct[j] = cos(freq * (j + 0.5)) / order # [1] end @melcos << ldct end @melcos end |
Instance Attribute Details
#melcos ⇒ Object
Returns the value of attribute melcos.
8 9 10 |
# File 'lib/ruby_impl/dct.rb', line 8 def melcos @melcos end |
Instance Method Details
#<<(data) ⇒ Object
22 23 24 25 26 |
# File 'lib/ruby_impl/dct.rb', line 22 def << data data.map do |dvec| @melcos.map {|m| dot_product m, dvec} end end |