class RLTK::CG::ConstantVector
A constant vector value used for SIMD instructions.
Public Class Methods
Create a new constant vector value.
@example Using array of values:
ConstantVector.new([Int32.new(0), Int32.new(1)])
@example Using size:
ConstantVector.new(2) { |i| Int32.new(i) }
@yieldparam index [Integer] Index of the value in the vector.
@param [FFI::Pointer, Array<Value>, Integer] size_or_values Number of values or array of values. @param [Proc] block Block evaluated if size is specified.
# File lib/rltk/cg/value.rb, line 490 def initialize(size_or_values, &block) @ptr = if size_or_values.is_a?(FFI::Pointer) size_or_values else vals_ptr = make_ptr_to_elements(size_or_values, &block) Bindings.const_vector(vals_ptr, vals_ptr.size / vals_ptr.type_size) end end
Public Instance Methods
@param [Integer] index Index of desired element.
@return [ConstantExpr] Extracted element.
# File lib/rltk/cg/value.rb, line 504 def extract_element(index) ConstantExpr.new(Bindings.const_extract_element(@ptr, index)) end
@param [Value] element Value
to insert into the vector. @param [Integer] index Index to insert the value at.
@return [ConstantExpr] New vector representation with inserted value.
# File lib/rltk/cg/value.rb, line 512 def insert_element(element, index) ConstantExpr.new(Bindings.const_insert_element(@ptr, element, index)) end
@param [ConstantVector] other Other vector to shuffle with this one. @param [ConstantVector] mask Mask to use when shuffling.
@return [ConstantVector] New vector formed by shuffling the two vectors together using the mask.
# File lib/rltk/cg/value.rb, line 520 def shuffle(other, mask) ConstantVector.new(Bindings.const_shuffle_vector(@ptr, other, mask)) end
# File lib/rltk/cg/value.rb, line 524 def size self.type.size end