Class: Yadriggy::C::FloatArray
Overview
Array of 64bit floating point numbers.
In C, the type of this array is arrayof(Float).
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from FFIArray
#==, #length, #memory_pointer, #set_values, #size, #to_a
Constructor Details
#initialize(size, ptr = nil) ⇒ FloatArray
84
85
86
87
88
89
90
|
# 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
|
Class Method Details
.element_type ⇒ Object
100
101
102
|
# File 'lib/yadriggy/c/ffi.rb', line 100
def self.element_type()
Float
end
|
Instance Method Details
#[](index) ⇒ Object
92
93
94
|
# File 'lib/yadriggy/c/ffi.rb', line 92
def [](index)
@array.get_float64(index * 8)
end
|
#[]=(index, value) ⇒ Object
96
97
98
|
# File 'lib/yadriggy/c/ffi.rb', line 96
def []=(index, value)
@array.put_float64(index * 8, value)
end
|