Class: Hornetseye::Composite

Inherits:
Element show all
Defined in:
lib/multiarray/composite.rb

Overview

Base class for composite types

Direct Known Subclasses

COMPLEX_, RGB_

Class Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Element

coercion, #compilable?, construct, #descriptor, #dup, fetch, #get, #initialize, #skip, #store, #strip, #values, #write

Methods inherited from Node

===, #[], #[]=, array_type, #array_type, #basetype, bool, byte, #check_shape, #coerce, coercion_bool, coercion_byte, coercion_maxint, #compilable?, compilable?, cond, contiguous, #decompose, #demand, #descriptor, dimension, #dimension, #dup, #empty?, empty?, #finalised?, finalised?, float, float_scalar, floating, #force, #get, height, #height, indgen, #inspect, match, maxint, #memory, #pointer_type, pointer_type, rgb?, #rgb?, #shape, shape, #simplify, #size, size, #storage_size, strip, #strip, subst, #subst, #to_a, to_s, #to_s, to_type, #typecode, typecode, variables, #variables, #width, width

Methods included from FLOAT_::Match

#align, #fit

Methods included from OBJECT::Match

#align, #fit

Methods included from Hornetseye::COMPLEX_::Match

#align, #fit

Methods included from Sequence_::Match

#align, #fit

Methods included from BOOL::Match

#fit

Methods included from RGB_::Match

#align, #fit

Methods included from INT_::Match

#fit

Methods included from Operations

#+@, #<=>, #b=, #b_with_decompose, #collect, #conditional, #convolve, define_binary_op, define_unary_op, #diagonal, #eq_with_multiarray, #fill!, #g=, #g_with_decompose, #histogram, #histogram_with_composite, #imag=, #imag_with_decompose, #inject, #integral, #lut, #lut_with_composite, #max, #min, #normalise, #product, #r=, #r_with_decompose, #range, #real=, #real_with_decompose, #roll, #sum, #to_type, #to_type_with_rgb, #transpose, #unroll

Constructor Details

This class inherits a constructor from Hornetseye::Element

Class Attribute Details

.element_typeClass

Access element type of composite type

Returns:

  • (Class)

    The element type.



28
29
30
# File 'lib/multiarray/composite.rb', line 28

def element_type
  @element_type
end

.num_elementsInteger

Get number of elements of composite type

Returns:

  • (Integer)

    Number of elements.



33
34
35
# File 'lib/multiarray/composite.rb', line 33

def num_elements
  @num_elements
end

Class Method Details

.basetypeClass

Base type of this data type

Returns:

  • (Class)

    Returns element_type.



82
83
84
# File 'lib/multiarray/composite.rb', line 82

def basetype
  element_type
end

.descriptor(hash) ⇒ String

Get unique descriptor of this class

Parameters:

  • hash (Hash)

    Labels for any variables.

Returns:

  • (String)

    Descriptor of this class.



69
70
71
72
73
74
75
# File 'lib/multiarray/composite.rb', line 69

def descriptor( hash )
  unless element_type.nil?
    inspect
  else
    super
  end
end

.directiveString

Directive for packing/unpacking elements of this type

Returns:

  • (String)

    Returns string with directive.



58
59
60
# File 'lib/multiarray/composite.rb', line 58

def directive
  element_type.directive * num_elements
end

.memoryClass

Memory type required to store elements of this type

Returns:

  • (Class)

    Returns element_type.memory.



40
41
42
# File 'lib/multiarray/composite.rb', line 40

def memory
  element_type.memory
end

.scalarClass

Scalar type to this type

Returns:

  • (Class)

    Returns element_type.



100
101
102
# File 'lib/multiarray/composite.rb', line 100

def scalar
  element_type
end

.storage_sizeInteger

Get storage size to store an element of this type

Returns:

  • (Integer)

    Returns element_type.storage_size * num_elements.



49
50
51
# File 'lib/multiarray/composite.rb', line 49

def storage_size
  element_type.storage_size * num_elements
end

.typecodesArray<Class>

Get list of types of composite type

Returns:

  • (Array<Class>)

    List of types.



91
92
93
# File 'lib/multiarray/composite.rb', line 91

def typecodes
  [ element_type ] * num_elements
end