Class: Yadriggy::C::Float32Array
- Defined in:
- lib/yadriggy/c/ffi.rb
Overview
Array of 32bit floating point numbers.
In C, the type of this array is arrayof(Float32)
.
Class Method Summary collapse
Instance Method Summary collapse
- #[](index) ⇒ Object
- #[]=(index, value) ⇒ Object
-
#initialize(size, ptr = nil) ⇒ Float32Array
constructor
A new instance of Float32Array.
Methods inherited from FFIArray
#==, #length, #memory_pointer, #set_values, #size, #to_a
Constructor Details
#initialize(size, ptr = nil) ⇒ Float32Array
Returns a new instance of Float32Array.
112 113 114 115 116 117 118 |
# File 'lib/yadriggy/c/ffi.rb', line 112 def initialize(size, ptr=nil) if ptr.nil? @array = FFI::MemoryPointer.new(:float, size) else @array = ptr end end |
Class Method Details
Instance Method Details
#[](index) ⇒ Object
120 121 122 |
# File 'lib/yadriggy/c/ffi.rb', line 120 def [](index) @array.get_float32(index * 4) end |
#[]=(index, value) ⇒ Object
124 125 126 |
# File 'lib/yadriggy/c/ffi.rb', line 124 def []=(index, value) @array.put_float32(index * 4, value) end |