Class: Noyes::LogCompressor

Inherits:
Object
  • Object
show all
Includes:
NoyesFilterDSL
Defined in:
lib/ruby_impl/log_compress.rb,
lib/common/noyes_dsl.rb

Overview

Takes the log base 10 of an incoming m x n array. The dimensions of the array remain unchanged. If a value is zero then the value log_zero is used instead of plunging into singularity land and throwing an exception.

Instance Method Summary collapse

Methods included from NoyesFilterDSL

#+, #|

Constructor Details

#initialize(log_zero = -0.00001) ⇒ LogCompressor

Returns a new instance of LogCompressor.


6
7
8
# File 'lib/ruby_impl/log_compress.rb', line 6

def initialize log_zero = -0.00001
  @log_zero = log_zero
end

Instance Method Details

#<<(mspec) ⇒ Object


9
10
11
# File 'lib/ruby_impl/log_compress.rb', line 9

def << mspec
  mspec.map {|msp| msp.map { |m|  m > 0 ? Math::log(m) : @log_zero}}
end