Class: Liblinear::Array::Double

Inherits:
Liblinear::Array show all
Defined in:
lib/liblinear/array/double.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Liblinear::Array

#decode, #delete, #swig

Constructor Details

#initialize(array) ⇒ Double

Returns a new instance of Double.

Parameters:


18
19
20
21
22
23
24
# File 'lib/liblinear/array/double.rb', line 18

def initialize(array)
  @array = Liblinearswig.new_double(array.size)
  array.size.times do |index|
    Liblinearswig.double_setitem(@array, index, array[index])
  end
  @size = array.size
end

Class Method Details

.decode(array, size) ⇒ Array <Float>

Parameters:

  • array (SWIG::TYPE_p_double)
  • size (Integer)

Returns:


7
8
9
# File 'lib/liblinear/array/double.rb', line 7

def decode(array, size)
  size.times.map {|index| Liblinearswig.double_getitem(array, index)}
end

.delete(array) ⇒ Object

Parameters:

  • array (SWIG::TYPE_p_double)

12
13
14
# File 'lib/liblinear/array/double.rb', line 12

def delete(array)
  Liblinearswig.delete_double(array)
end