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

Instance Method Summary collapse

Methods inherited from Element

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

Methods inherited from Node

#+@, #<=>, ===, #[], #[]=, #allocate, #b=, #b_with_decompose, #basetype, #between?, bool, byte, #check_shape, #clip, #coerce, coercion_bool, coercion_byte, coercion_maxint, #collect, #compilable?, compilable?, #components, cond, #conditional, #convolve, define_binary_op, define_unary_op, #demand, #descriptor, #diagonal, #dilate, dimension, #dimension, #downsample, #dup, #each, #empty?, #eq_with_multiarray, #erode, #fill!, #finalised?, finalised?, #flip, float, float_scalar, floating, #fmod_with_float, #force, #g=, #g_with_decompose, #gauss_blur, #gauss_gradient, #get, #height, #histogram, #histogram_with_rgb, identity, #if, #if_else, #imag=, #imag_with_decompose, indgen, #inject, #inspect, #integral, #lut, #lut_with_rgb, #malloc, #mask, match, #matched?, #max, maxint, #mean, #memorise, #memory, #min, #normalise, #prod, #r=, #r_with_decompose, #range, #real=, #real_with_decompose, #reshape, #rgb?, rgb?, #roll, #shape, shape, #shift, #simplify, #size, #sobel, #stretch, #stride, #strides, #strip, strip, #subst, subst, #sum, #swap_rgb_with_scalar, #table, #to_a, #to_s, to_s, to_type, #to_type, #to_type_with_identity, #to_type_with_rgb, #transpose, #typecode, typecode, #unmask, #unroll, #variables, variables, #warp, #width

Methods included from Field_::Match

#align, #fit

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 BOOL::Match

#fit

Methods included from RGB_::Match

#align, #fit

Methods included from INT_::Match

#fit

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

.memory_typeClass

Memory type required to store elements of this type

Returns:

  • (Class)

    Returns element_type.memory_type.



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

def memory_type
  element_type.memory_type
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

Instance Method Details

#decompose(i) ⇒ Node

Decompose composite number

This method decomposes the composite number.

Returns:

  • (Node)

    Returns the requested component.



113
114
115
# File 'lib/multiarray/composite.rb', line 113

def decompose( i )
  self.class.element_type.new @value.decompose( i )
end