class RCGTK::ConstantVector

A constant vector value used for SIMD instructions.

Public Class Methods

new(size_or_values, &block) click to toggle source

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/rcgtk/value.rb, line 491
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

extract_element(index) click to toggle source

@param [Integer] index Index of desired element.

@return [ConstantExpr] Extracted element.

# File lib/rcgtk/value.rb, line 505
def extract_element(index)
        ConstantExpr.new(Bindings.const_extract_element(@ptr, index))
end
insert_element(element, index) click to toggle source

@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/rcgtk/value.rb, line 513
def insert_element(element, index)
        ConstantExpr.new(Bindings.const_insert_element(@ptr, element, index))
end
length()
Alias for: size
shuffle(other, mask) click to toggle source

@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/rcgtk/value.rb, line 521
def shuffle(other, mask)
        ConstantVector.new(Bindings.const_shuffle_vector(@ptr, other, mask))
end
size() click to toggle source
# File lib/rcgtk/value.rb, line 525
def size
        self.type.size
end
Also aliased as: length