class Neighbor::SparseVector
def from_array(arr)
def from_array(arr) arr = arr.to_a @dimensions = arr.size @indices = [] @values = [] arr.each_with_index do |v, i| if v != 0 @indices << i @values << v.to_f end end end
def from_array(arr) arr = arr.to_a @dimensions = arr.size @indices = [] @values = [] arr.each_with_index do |v, i| if v != 0 @indices << i @values << v.to_f end end end