Module: Math

Included in:
Noyes, Noyes::DCT, Noyes::HammingWindow, Noyes::MelFilter, Noyes::Preemphasizer, NoyesJava::Preemphasizer
Defined in:
lib/common/ruby_ext.rb,
lib/common/ruby_ext.rb,
lib/common/noyes_math.rb

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) log2(n)



24
25
26
# File 'lib/common/ruby_ext.rb', line 24

def Math.log2 n
  log(n)/log(2)
end

+ (Object) max(a, b)



2
3
4
# File 'lib/common/ruby_ext.rb', line 2

def self.max a, b
  a > b ? a : b
end

+ (Object) min(a, b)



5
6
7
# File 'lib/common/ruby_ext.rb', line 5

def self.min a, b
  a < b ? a : b
end

Instance Method Details

- (Object) dot_product(l1, l2)



2
3
4
5
6
7
8
# File 'lib/common/noyes_math.rb', line 2

def dot_product l1, l2
  sum = 0
  for i in 0...l1.size
    sum += l1[i] * l2[i]
  end
  sum
end