module MachineLearningWorkbench::Monkey::Mappable
Public Instance Methods
map(dim=0) { |self| ... }
click to toggle source
Maps along a NArray dimension, and returns NArray @return [NArray] NOTE: this indexing is not consistent with NArray, which uses 0 to indicate
columns rather than the 0th dimension (rows)
# File lib/machine_learning_workbench/monkey.rb, line 301 def map dim=0 raise ArgumentError unless dim.kind_of?(Integer) && dim.between?(0,ndim) # TODO: return iterator instead of raise raise NotImplementedError unless block_given? indices = [true]*ndim ret = [] shape[dim].times.each do |i| indices[dim] = i ret << yield(self[*indices]) end self.class[*ret] end