class Yadriggy::C::FloatArray

Array of 64bit floating point numbers. In C, the type of this array is `arrayof(Float)`.

Public Class Methods

element_type() click to toggle source
# File lib/yadriggy/c/ffi.rb, line 100
def self.element_type()
  Float
end
new(size, ptr=nil) click to toggle source

@param [Integer] size array size. @param [FFI::MemoryPointer] ptr a memory pointer or nil.

If nil, a new memory block is allocated.
# File lib/yadriggy/c/ffi.rb, line 84
def initialize(size, ptr=nil)
  if ptr.nil?
    @array = FFI::MemoryPointer.new(:double, size)
  else
    @array = ptr
  end
end

Public Instance Methods

[](index) click to toggle source
# File lib/yadriggy/c/ffi.rb, line 92
def [](index)
  @array.get_float64(index * 8)
end
[]=(index, value) click to toggle source
# File lib/yadriggy/c/ffi.rb, line 96
def []=(index, value)
  @array.put_float64(index * 8, value)
end