This class is used to map Ruby objects on native datatypes and to do element-type coercions for native datatypes.
| Type | This class is used to map Ruby objects on native datatypes and to do element-type coercions for native datatypes. |
| Functions | |
| Type. | Same as Type.to_s. |
| Type.to_s | Display name of this type. |
| Type. | Same as Type.to_s. |
| Type. | Marshalling support. |
| Type. | Used internally. |
| Type. | Used internally. |
| Type. | Allocate required memory for this type. |
| Type. | Check whether this is an empty array. |
| Type. | Returns number of dimensions for arrays or 0. |
| Type. | Returns stride of array or nil. |
| Type. | Used internally. |
| Type. | Used internally to get corresponding type with contiguous memory-layout. |
| Type. | Returns array of strides for arrays or []. |
| Type. | Returns array of dimensions for arrays or []. |
| Type.size | Recursively compute number of elements. |
| Type. | Used internally to check for correct size of arguments. |
| Type. | Used internally to check for correct shape of arguments. |
| Type. | Used internally to check for correct shape of filter for correlation. |
| Type. | Used internally to describe memory-layout of this type. |
| Type. | Returns true if the memory-layout of this type is contiguous. |
| Type. | Allocate new instance and fill with index array. |
| Type. | Recursively get element-type for multi-dimensional arrays or return itself. |
| Type. | Recursively get basic type for multi-dimensional arrays and composite numbers or return itself. |
| Type.rgb? | Used internally. |
| Type.bool | Used internally. |
| Type. | Used internally. |
| Type. | Used internally. |
| Type. | Used internally. |
| Type. | Used internally. |
| Type.byte | Used internally. |
| Type. | Used internally. |
| Type. | Decompose composite numbers, i.e. |
| Type. | Used internally. |
| Type. | Used internally. |
| Type. | Used internally. |
| Type. | Used internally. |
| Type.fit | Used internally. |
| Type. | Used internally. |
| Type. | Used internally. |
| Type. | Used internally for caching JIT-methods. |
| Type. | Used internally. |
| Type. | Used internally for balancing native types. |
| Type.=== | Test on identity. |
| to_s | Convert data to string. |
| export | Convert data to string. |
| to_str | Same as to_s. |
| coerce | Used internally. |
| _dump | Marshalling support. |
| element_type | Used internally. |
| num_elements | Used internally. |
| typecode | Get type of elements. |
| typesize | Storage size of type (number of bytes for native types, number of Ruby objects otherwise) |
| size | Overall number of elements in array or 1 if this is not an array. |
| empty? | Returns a boolean indicating whether this is an empty array. |
| stride | Used internally to get array stride. |
| layout | Used internally to describe memory-layout of this type. |
| contiguous? | Used internally. |
| contiguous | Used internally to get corresponding type with contiguous memory-layout. |
| dimension | Get number of dimensions of this array or 0 if this is not an array. |
| shape | Get array with dimensions of this array or [] if this is not an array. |
| strides | Used internally. |
| width | Get width of array. |
| height | Get height of array. |
| basetype | Used internally. |
| rgb? | Used internally. |
| check_size | Used internally to check for correct size of arguments. |
| check_shape | Used internally to check for correct shape of arguments. |
| check_filter | Used internally to check for correct shape of filter for correlation. |
| memory | Used internally. |
| to_type | Element-wise conversion to a different type. |
| typecast | Used internally to typecast native data. |
| reshape | Create array with same data but different shape. |
| decompose | Decompose composite numbers, i.e. |
| set | Used internally to set content of this object to specified value. |
| get | Used internally to get content of this object. |
| sel | Get single elements or a region of this array. |
| at | Get single elements or a region of this array. |
| [] | Get single elements or a region of this array. |
| assign | Assign new values to elements. |
| []= | Assign value to an element or to a region of the array. |
| == | Test on equality. |
| fill! | Overwrite value or fill with value if this is an array. |
| each | Iterator to iterate over all elements. |
| multi_each | Iterator mechanism for iterating over multiple arrays at the same time. |
| collect | Apply function to each element and return result. |
| collect! | Apply function to each element and replace elements with result. |
| multi_collect | Iterator mechanism for iterating over multiple arrays at the same time. |
| op | Used internally to perform element-wise operations (map operations). |
| op_ | Used internally to perform element-wise operations (map operations). |
| inject | Similar to Array::inject. |
| inject_ | Used internally to perform injections (reduce operations). |
| indgen! | Fill with index values. |
| random! | Fill with random numbers. |
| swap_rgb | Swap red and blue channel. |
| conditional | Select elements from a or b depending whether this value is true or false. |
| map | Apply element-wise look-up to array. |
| hist | Compute histogram of the array. |
| hist_weighted | Compute weighted histogram of the array. |
| muladd | Used internally to perform correlations. |
| muladd_ | Used internally to perform correlations. |
| correlate | Optimized n-dimensional correlation for small filters. |
| integral | Compute integral of n-dimensional array. |
| integrate | Used internally. |
| knot | Used internally. |
| integrate_ | Used internally. |
| divergence | Compute divergence of n-dimensional array. |
| zip | Converts the elements of self and each argument to arrays and concatenates them. |
| real | Get real part of complex number(s). |
| real= | Set real part of complex number(s). |
| imag | Get imaginary part of complex number(s). |
| imag= | Set imaginary part of complex numbers(s). |
| r | Get red channel. |
| r= | Set red channel. |
| g | Get green channel. |
| g= | Set green channel. |
| b | Get blue channel. |
| b= | Set blue channel. |
| zero? | Compare with zero. |
| zero? | Compare with zero. |
| -@ | Compute additive inverse. |
| +@ | Does nothing. |
| abs | Compute absolute value. |
| arg | Compute complex argument. |
| conj | Compute complex conjugate. |
| floor | Round to largest integer not greater than this value. |
| ceil | Round to smallest integer not smaller than this value. |
| not | Compute boolean “not”. |
| ~ | Compute bitwise “not”. |
| round | Round to nearest integer. |
| and | Boolean “and”. |
| or | Boolean “or”. |
| & | Bitwise “and”. |
| | | Bitwise “or”. |
| ^ | Bitwise “xor”. |
| << | Shift bits to the left. |
| >> | Shift bits to the right. |
| <=> | Comparison operator. |
| + | Addition. |
| - | Subtraction. |
| * | Multiplication. |
| / | Division. |
| % | Remainder. |
| ** | Power. |
| < | Lower-than comparison. |
| <= | Lower-than-or-equal-to comparison. |
| > | Greater-than comparison. |
| >= | Greater-than-or-equal-to comparison. |
| eq | Equal-to comparison. |
| ne | Not-equal-to comparison. |
| ge | Same as >= |
| gt | Same as > |
| le | Same as <= |
| lt | Same as < |
| major | Choose larger value of two. |
| minor | Choose smaller value of two. |
def Type.inspect
Same as Type.to_s.
def Type.to_str
Same as Type.to_s.
def Type.indgen( offset = 0, increment = 1 )
Allocate new instance and fill with index array. Use indgen! instead.
def Type.match( value, context = nil )
Used internally. Find type which matches a Ruby value. Align the resulting type depending on the context (e.g. prefer single-precision floating-point if the context is SFLOAT).
| value | Ruby value to find native type for |
| context | Preferred type (optional) |
def to_str
Same as to_s.
def set( value = typecode.default )
Used internally to set content of this object to specified value.
| value | Ruby object, Ruby array, or object of class Sequence_ |
def get
Used internally to get content of this object.
Ruby object or object of class Sequence_
def sel( * indices )
Get single elements or a region of this array. Use []- or []=-operator instead.
def multi_collect( type, * args )
Iterator mechanism for iterating over multiple arrays at the same time. You need to specify a block of code accepting an element of each array as parameter.
| type | Element type of resulting array (optional) |
| args | the other array(s) |
Array with return values.
def hist( size, options = { :target => UINT, :safe => true } )
Compute histogram of the array. Note that the size of the histogram must be sufficient to avoid a memory access violation.
| size | Size of histogram |
| target | Element-type of new histogram |
| safe | Do range checks to avoid segmentation fault |
Sequence object containing the histogram.
def hist_weighted( size, weights, options = { :safe => true } )
Compute weighted histogram of the array. Note that the size of the histogram must be sufficient to avoid a memory access violation.
| size | Size of histogram |
| weights | Weights for individual samples |
| safe | Do range checks to avoid segmentation fault |
Sequence object containing the weighted histogram.
def correlate( filter )
Optimized n-dimensional correlation for small filters. The correlation is computed directly and is suitable for small filters. Correlation with elements of type OBJECT is supported as well, but it is very slow. The output object will have the same shape as this object. The boundaries are dealt with by assuming out-of-boundary elements to be zero.
The filter needs to be of type Type and the dimension should be the same as the dimension of this object.
Note that if the filter is separable you should use the separated filters instead to achieve higher performance.
def integral
Compute integral of n-dimensional array. Computes the integral image which is also known as the summed area table. Each element of the resulting array contains the sum of the elements of the input array which do not have any index bigger than the index of the resulting element.
def knot( arr, args, comp, labels, rank, default, options = {} )
Used internally. Call Sequence_.components instead.
Same as Type.to_s.
def Type.inspect
Display name of this type.
def Type.to_s
Same as Type.to_s.
def Type.to_str
Marshalling support.
def Type._load( str )
Used internally.
def Type.element_type
Used internally.
def Type.num_elements
Allocate required memory for this type.
def Type.alloc( n = 1 )
Check whether this is an empty array.
def Type.empty?
Returns number of dimensions for arrays or 0.
def Type.dimension
Returns stride of array or nil.
def Type.stride
Used internally.
def Type.contiguous?
Returns array of strides for arrays or [].
def Type.strides
Returns array of dimensions for arrays or [].
def Type.shape
Recursively compute number of elements.
def Type.size
Used internally to check for correct size of arguments.
def Type.check_size( * args )
Used internally to check for correct shape of arguments.
def Type.check_shape( * args )
Used internally to check for correct shape of filter for correlation.
def Type.check_filter( filter )
Used internally to describe memory-layout of this type.
def Type.layout
Allocate new instance and fill with index array.
def Type.indgen( offset = 0, increment = 1 )
Recursively get element-type for multi-dimensional arrays or return itself.
def Type.typecode
Recursively get basic type for multi-dimensional arrays and composite numbers or return itself.
def Type.basetype
Used internally.
def Type.rgb?
Used internally.
def Type.bool
Used internally.
def Type.float
Used internally.
def Type.scalar
Used internally.
def Type.floatscalar
Used internally.
def Type.maxint
Used internally.
def Type.byte
Used internally.
def Type.to_type( typecode, options = {} )
Decompose composite numbers, i.e.
def Type.decompose
Used internally.
def Type.boolean( other )
Used internally.
def Type.byteval( other )
Used internally.
def Type.largeint( other )
Used internally.
def Type.floating( other )
Used internally.
def Type.fit( * values )
Used internally.
def Type.match( value, context = nil )
Used internally.
def Type.align( context )
Used internally for caching JIT-methods.
def Type.cache( descriptor, * hash )
Used internally.
def Type.coerce( other )
Used internally for balancing native types.
def Type.coercion( other )
Test on identity.
def Type.===( other )
Convert data to string.
def to_s
Convert data to string.
def export
Same as to_s.
def to_str
Used internally.
def coerce( other )
Marshalling support.
def _dump( depth )
Used internally.
def element_type
Used internally.
def num_elements
Get type of elements.
def typecode
Storage size of type (number of bytes for native types, number of Ruby objects otherwise)
def typesize
Overall number of elements in array or 1 if this is not an array.
def size
Returns a boolean indicating whether this is an empty array.
def empty?
Used internally to get array stride.
def stride
Used internally to describe memory-layout of this type.
def layout
Used internally.
def contiguous?
Get number of dimensions of this array or 0 if this is not an array.
def dimension
Get array with dimensions of this array or [] if this is not an array.
def shape
Used internally.
def strides
Get width of array.
def width
Get height of array.
def height
Used internally.
def basetype
Used internally.
def rgb?
Used internally to check for correct size of arguments.
def check_size( * args )
Used internally to check for correct shape of arguments.
def check_shape( * args )
Used internally to check for correct shape of filter for correlation.
def check_filter( filter )
Used internally.
def memory
Element-wise conversion to a different type.
def to_type( type )
Used internally to typecast native data.
def typecast( target, * shape )
Create array with same data but different shape.
def reshape( * shape )
Decompose composite numbers, i.e.
def decompose
Used internally to set content of this object to specified value.
def set( value = typecode.default )
Used internally to get content of this object.
def get
Get single elements or a region of this array.
def sel( * indices )
Get single elements or a region of this array.
def at( * indices )
Get single elements or a region of this array.
def []( * indices )
Assign new values to elements.
def assign( * args )
Assign value to an element or to a region of the array.
def []=( * args )
Test on equality.
def ==( other )
Overwrite value or fill with value if this is an array.
def fill!( value = typecode.default )
Iterator to iterate over all elements.
def each
Iterator mechanism for iterating over multiple arrays at the same time.
def multi_each( * args )
Apply function to each element and return result.
def collect( target = typecode )
Apply function to each element and replace elements with result.
def collect!
Iterator mechanism for iterating over multiple arrays at the same time.
def multi_collect( type, * args )
Used internally to perform element-wise operations (map operations).
def op( * args )
Used internally to perform element-wise operations (map operations).
def op_( * args )
Similar to Array::inject.
def inject( * args )
Used internally to perform injections (reduce operations).
def inject_( * args )
Fill with index values.
def indgen!( offset = 0, increment = 1 )
Fill with random numbers.
def random!( n = 1 )
Swap red and blue channel.
def swap_rgb
Select elements from a or b depending whether this value is true or false.
def conditional( a, b )
Apply element-wise look-up to array.
def map( lut, options = { :safe => true } )
Compute histogram of the array.
def hist( size, options = { :target => UINT, :safe => true } )
Compute weighted histogram of the array.
def hist_weighted( size, weights, options = { :safe => true } )
Used internally to perform correlations.
def muladd
Used internally to perform correlations.
def muladd_
Optimized n-dimensional correlation for small filters.
def correlate( filter )
Compute integral of n-dimensional array.
def integral
Used internally.
def integrate( other )
Used internally.
def knot( arr, args, comp, labels, rank, default, options = {} )
Used internally.
def integrate_( other )
Compute divergence of n-dimensional array.
def divergence
Converts the elements of self and each argument to arrays and concatenates them.
def zip( * arrs )
Get real part of complex number(s).
def real
Set real part of complex number(s).
def real=
Get imaginary part of complex number(s).
def imag
Set imaginary part of complex numbers(s).
def imag=
Get red channel.
def r
Set red channel.
def r=
Get green channel.
def g
Set green channel.
def g=
Get blue channel.
def b
Set blue channel.
def b=
Compare with zero.
def zero?
Compute additive inverse.
def -@
Does nothing.
def +@
Compute absolute value.
def abs
Compute complex argument.
def arg
Compute complex conjugate.
def conj
Round to largest integer not greater than this value.
def floor
Round to smallest integer not smaller than this value.
def ceil
Compute boolean “not”.
def not
Compute bitwise “not”.
def ~
Round to nearest integer.
def round
Boolean “and”.
def and( other )
Boolean “or”.
def or( other )
Bitwise “and”.
def &( other )
Bitwise “or”.
def |( other )
Bitwise “xor”.
def ^( other )
Comparison operator.
def <=>( other )
Addition.
def +( other )
Subtraction.
def -( other )
Multiplication.
def *( other )
Division.
def /( other )
Power.
def **( other )
Equal-to comparison.
def eq( other )
Not-equal-to comparison.
def ne( other )
Same as >=
def ge( other )
Same as >
def gt( other )
Same as <=
def le( other )
Same as <
def lt( other )
Choose larger value of two.
def major( other )
Choose smaller value of two.
def minor( other )
N-dimensional connected component labeling.
def components( default = typecode.default, target = UINT )