Type

This class is used to map Ruby objects on native datatypes and to do element-type coercions for native datatypes.

Summary
TypeThis class is used to map Ruby objects on native datatypes and to do element-type coercions for native datatypes.
Functions
Type.inspectSame as Type.to_s.
Type.to_sDisplay name of this type.
Type.to_strSame as Type.to_s.
Type._loadMarshalling support.
Type.element_typeUsed internally.
Type.num_elementsUsed internally.
Type.allocAllocate required memory for this type.
Type.empty?Check whether this is an empty array.
Type.dimensionReturns number of dimensions for arrays or 0.
Type.strideReturns stride of array or nil.
Type.contiguous?Used internally.
Type.contiguousUsed internally to get corresponding type with contiguous memory-layout.
Type.stridesReturns array of strides for arrays or [].
Type.shapeReturns array of dimensions for arrays or [].
Type.sizeRecursively compute number of elements.
Type.check_sizeUsed internally to check for correct size of arguments.
Type.check_shapeUsed internally to check for correct shape of arguments.
Type.check_filterUsed internally to check for correct shape of filter for correlation.
Type.layoutUsed internally to describe memory-layout of this type.
Type.contiguous?Returns true if the memory-layout of this type is contiguous.
Type.indgenAllocate new instance and fill with index array.
Type.typecodeRecursively get element-type for multi-dimensional arrays or return itself.
Type.basetypeRecursively get basic type for multi-dimensional arrays and composite numbers or return itself.
Type.rgb?Used internally.
Type.boolUsed internally.
Type.floatUsed internally.
Type.scalarUsed internally.
Type.floatscalarUsed internally.
Type.maxintUsed internally.
Type.byteUsed internally.
Type.to_typeUsed internally.
Type.decomposeDecompose composite numbers, i.e.
Type.booleanUsed internally.
Type.bytevalUsed internally.
Type.largeintUsed internally.
Type.floatingUsed internally.
Type.fitUsed internally.
Type.matchUsed internally.
Type.alignUsed internally.
Type.cacheUsed internally for caching JIT-methods.
Type.coerceUsed internally.
Type.coercionUsed internally for balancing native types.
Type.===Test on identity.
to_sConvert data to string.
exportConvert data to string.
to_strSame as to_s.
coerceUsed internally.
_dumpMarshalling support.
element_typeUsed internally.
num_elementsUsed internally.
typecodeGet type of elements.
typesizeStorage size of type (number of bytes for native types, number of Ruby objects otherwise)
sizeOverall number of elements in array or 1 if this is not an array.
empty?Returns a boolean indicating whether this is an empty array.
strideUsed internally to get array stride.
layoutUsed internally to describe memory-layout of this type.
contiguous?Used internally.
contiguousUsed internally to get corresponding type with contiguous memory-layout.
dimensionGet number of dimensions of this array or 0 if this is not an array.
shapeGet array with dimensions of this array or [] if this is not an array.
stridesUsed internally.
widthGet width of array.
heightGet height of array.
basetypeUsed internally.
rgb?Used internally.
check_sizeUsed internally to check for correct size of arguments.
check_shapeUsed internally to check for correct shape of arguments.
check_filterUsed internally to check for correct shape of filter for correlation.
memoryUsed internally.
to_typeElement-wise conversion to a different type.
typecastUsed internally to typecast native data.
reshapeCreate array with same data but different shape.
decomposeDecompose composite numbers, i.e.
setUsed internally to set content of this object to specified value.
getUsed internally to get content of this object.
selGet single elements or a region of this array.
atGet single elements or a region of this array.
[]Get single elements or a region of this array.
assignAssign 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.
eachIterator to iterate over all elements.
multi_eachIterator mechanism for iterating over multiple arrays at the same time.
collectApply function to each element and return result.
collect!Apply function to each element and replace elements with result.
multi_collectIterator mechanism for iterating over multiple arrays at the same time.
opUsed internally to perform element-wise operations (map operations).
op_Used internally to perform element-wise operations (map operations).
injectSimilar to Array::inject.
inject_Used internally to perform injections (reduce operations).
indgen!Fill with index values.
random!Fill with random numbers.
swap_rgbSwap red and blue channel.
conditionalSelect elements from a or b depending whether this value is true or false.
mapApply element-wise look-up to array.
histCompute histogram of the array.
hist_weightedCompute weighted histogram of the array.
muladdUsed internally to perform correlations.
muladd_Used internally to perform correlations.
correlateOptimized n-dimensional correlation for small filters.
integralCompute integral of n-dimensional array.
integrateUsed internally.
knotUsed internally.
integrate_Used internally.
divergenceCompute divergence of n-dimensional array.
zipConverts the elements of self and each argument to arrays and concatenates them.
realGet real part of complex number(s).
real=Set real part of complex number(s).
imagGet imaginary part of complex number(s).
imag=Set imaginary part of complex numbers(s).
rGet red channel.
r=Set red channel.
gGet green channel.
g=Set green channel.
bGet blue channel.
b=Set blue channel.
zero?Compare with zero.
zero?Compare with zero.
-@Compute additive inverse.
+@Does nothing.
absCompute absolute value.
argCompute complex argument.
conjCompute complex conjugate.
floorRound to largest integer not greater than this value.
ceilRound to smallest integer not smaller than this value.
notCompute boolean “not”.
~Compute bitwise “not”.
roundRound to nearest integer.
andBoolean “and”.
orBoolean “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.
eqEqual-to comparison.
neNot-equal-to comparison.
geSame as >=
gtSame as >
leSame as <=
ltSame as <
majorChoose larger value of two.
minorChoose smaller value of two.

Functions

Type.inspect

def Type.inspect

Same as Type.to_s.

Type.to_s

def Type.to_s

Display name of this type.

Type.to_str

def Type.to_str

Same as Type.to_s.

Type._load

def Type._load(str)

Marshalling support.

Type.element_type

def Type.element_type

Used internally.  Returns type of element for arrays or itself.

Type.num_elements

def Type.num_elements

Used internally.  Returns number of elements for arrays or 1.

Type.alloc

def Type.alloc(n =  1)

Allocate required memory for this type.

Parameters

nNumber of instances required (optional)

Type.empty?

def Type.empty?

Check whether this is an empty array.

Returns

true if num_elements is zero

Type.dimension

def Type.dimension

Returns number of dimensions for arrays or 0.

Type.stride

def Type.stride

Returns stride of array or nil.

Type.contiguous?

def Type.contiguous?

Used internally.  Returns true if the data is stored contiguously.

Type.contiguous

def Type.contiguous

Used internally to get corresponding type with contiguous memory-layout.

Type.strides

def Type.strides

Returns array of strides for arrays or [].

Type.shape

def Type.shape

Returns array of dimensions for arrays or [].

Type.size

def Type.size

Recursively compute number of elements.

Type.check_size

def Type.check_size(*args)

Used internally to check for correct size of arguments.

Type.check_shape

def Type.check_shape(*args)

Used internally to check for correct shape of arguments.

Type.check_filter

def Type.check_filter(filter)

Used internally to check for correct shape of filter for correlation.

Type.layout

def Type.layout

Used internally to describe memory-layout of this type.

Type.contiguous?

def Type.contiguous?

Returns true if the memory-layout of this type is contiguous.

Type.indgen

def Type.indgen(offset =  0,
increment =  1)

Allocate new instance and fill with index array.  Use indgen! instead.

Type.typecode

def Type.typecode

Recursively get element-type for multi-dimensional arrays or return itself.

Type.basetype

def Type.basetype

Recursively get basic type for multi-dimensional arrays and composite numbers or return itself.

Type.rgb?

def Type.rgb?

Used internally.  Returns true if the element-type is an RGB-type.

Type.bool

def Type.bool

Used internally.  Get corresponding array type with boolean elements.

Type.float

def Type.float

Used internally.  Get corresponding array type with floating-point values.

Type.scalar

def Type.scalar

Used internally.  Get corresponding array type with element-type of composite numbers.

Type.floatscalar

def Type.floatscalar

Used internally.  Same as ‘scalar.float’.

Type.maxint

def Type.maxint

Used internally.  Get corresponding array type with 32-bit integers.

Type.byte

def Type.byte

Used internally.  Get corresponding array type with 8-bit integers.

Type.to_type

def Type.to_type(typecode,  
options =  {})

Used internally.  Get corresponding array type with other element-type.

Type.decompose

def Type.decompose

Decompose composite numbers, i.e. typecast them to arrays.

Type.boolean

def Type.boolean(other)

Used internally.  Same as ‘coercion( other ).bool’.

Type.byteval

def Type.byteval(other)

Used internally.  Same as ‘coercion( other ).byte’.

Type.largeint

def Type.largeint(other)

Used internally.  Same as ‘coercion( other ).maxint’.

Type.floating

def Type.floating(other)

Used internally.  Same as ‘coercion( other ).float’.

Type.fit

def Type.fit(*values)

Used internally.  Find type which matches a set of Ruby values.

Parameters

valuesset of Ruby values to find native type for

Type.match

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).

Parameters

valueRuby value to find native type for
contextPreferred type (optional)

Type.align

def Type.align(context)

Used internally.  Align type depending on context.

Type.cache

def Type.cache(descriptor,
*hash)

Used internally for caching JIT-methods.

Type.coerce

def Type.coerce(other)

Used internally.  Implementation of Ruby’s coercion mechanism.

Type.coercion

def Type.coercion(other)

Used internally for balancing native types.

Type.===

def Type.===(other)

Test on identity.

to_s

def to_s

Convert data to string.

See also

export

def export

Convert data to string.  If data consists of Ruby objects, return an array of Ruby objects instead.

to_str

def to_str

Same as to_s.

coerce

def coerce(other)

Used internally.  Implementation of Ruby’s coercion mechanism.

_dump

def _dump(depth)

Marshalling support.

element_type

def element_type

Used internally.  Returns type of element for arrays or itself.

num_elements

def num_elements

Used internally.  Returns number of elements for arrays or 1.

typecode

def typecode

Get type of elements.

typesize

def typesize

Storage size of type (number of bytes for native types, number of Ruby objects otherwise)

size

def size

Overall number of elements in array or 1 if this is not an array.

empty?

def empty?

Returns a boolean indicating whether this is an empty array.

stride

def stride

Used internally to get array stride.

layout

def layout

Used internally to describe memory-layout of this type.

See also

contiguous?

def contiguous?

Used internally.  Returns true if the data is stored contiguously.

See also

contiguous

def contiguous

Used internally to get corresponding type with contiguous memory-layout.

See also

dimension

def dimension

Get number of dimensions of this array or 0 if this is not an array.

shape

def shape

Get array with dimensions of this array or [] if this is not an array.

See also

strides

def strides

Used internally.  Returns array of strides for arrays or [].

width

def width

Get width of array.  Same as

shape[ 0 ]

See also

height

def height

Get height of array.  Same as

shape[ 1 ]

See also

basetype

def basetype

Used internally.  Returns basic type if this is a composite type.  Otherwise the type itself is returned.

rgb?

def rgb?

Used internally.  Returns true if the element-type is an RGB-type.

check_size

def check_size(*args)

Used internally to check for correct size of arguments.

check_shape

def check_shape(*args)

Used internally to check for correct shape of arguments.

check_filter

def check_filter(filter)

Used internally to check for correct shape of filter for correlation.

memory

def memory

Used internally.  Returns the memory object which is used to store the data of instance.

to_type

def to_type(type)

Element-wise conversion to a different type.  Note that the data is only copied if necessary.  If possible a typecast is used instead.

typecast

def typecast(target,
*shape)

Used internally to typecast native data.  The target of the typecast must have the same memory size and the layout of the memory must match.

Parameters

targetResulting type of casted data
shapeShape of an array (optional)

See also

reshape

def reshape(*shape)

Create array with same data but different shape.

decompose

def decompose

Decompose composite numbers, i.e. typecast them to arrays.

set

def set(value =  typecode.default)

Used internally to set content of this object to specified value.

Parameters

valueRuby object, Ruby array, or object of class Sequence_

get

def get

Used internally to get content of this object.

Returns

Ruby object or object of class Sequence_

sel

def sel(*indices)

Get single elements or a region of this array.  Use []- or []=-operator instead.

See also

at

def at(*indices)

Get single elements or a region of this array.  Use []-operator instead.

See also

[]

def [](*indices)

Get single elements or a region of this array.

Parameters

indicesInteger-values and/or -ranges.

See also

assign

def assign(*args)

Assign new values to elements.  Use []=-operator instead.

See also

  • []=

[]=

def []=(*args)

Assign value to an element or to a region of the array.  It is also possible to multi-dimensional assignments by specifying multiple indices and ranges.

Parameters

argsinteger-values and/or -ranges, last argument is the new value of the array element

See also

==

def ==(other)

Test on equality.

fill!

def fill!(value =  typecode.default)

Overwrite value or fill with value if this is an array.

each

def each

Iterator to iterate over all elements.  Requires a code-block as argument.

multi_each

def multi_each(*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.

Parameters

argsOther array objects(s)

collect

def collect(target =  typecode)

Apply function to each element and return result.  Requires a code block with the function to apply.

Parameters

targetelement type of resulting array (optional)

Returns

Array with results.

collect!

def collect!

Apply function to each element and replace elements with result.  Requires a code block with the function to apply.

multi_collect

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.

Parameters

typeElement type of resulting array (optional)
argsthe other array(s)

Returns

Array with return values.

See also

op

def op(*args)

Used internally to perform element-wise operations (map operations).  Requires a code block with the operation to perform.

Parameters

argsOther arguments involved in the operation.

op_

def op_(*args)

Used internally to perform element-wise operations (map operations).  Requires a code block with the operation to perform.

Parameters

argsOther arguments involved in the operation.

inject

def inject(*args)

Similar to Array::inject.  Requires a code block with the function to apply.

Parameters

argsinitial value for first iteration (optional) and further arguments to be iterated over.

inject_

def inject_(*args)

Used internally to perform injections (reduce operations).

Parameters

argsInitial value for injection followed by secondary arguments (both optional)

See also

indgen!

def indgen!(offset =  0,
increment =  1)

Fill with index values.

Parameters

offsetvalue for first element.
incrementincrement for the next element.

random!

def random!(n =  1)

Fill with random numbers.  Random numbers are uniformly distributed and will be between 0 and n (excluding n in the case of integers).

Parameters

nu

See also

  • <JITTerm.lrand48>
  • <JITTerm.drand48>

swap_rgb

def swap_rgb

Swap red and blue channel.

conditional

def conditional(a,
b)

Select elements from a or b depending whether this value is true or false.

Parameteres

aReturn value if this mask is true
bReturn value if this mask is false

map

def map(lut,  
options =  { :safe => true })

Apply element-wise look-up to array.  The elements of the look-up table can be arrays as well.

Parameters

lutArray containing look-up table.
safeDo range checks to avoid segmentation fault

Returns

Array with result of look-up.

See also

  • <warp>

hist

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.

Parameters

sizeSize of histogram
targetElement-type of new histogram
safeDo range checks to avoid segmentation fault

Returns

Sequence object containing the histogram.

hist_weighted

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.

Parameters

sizeSize of histogram
weightsWeights for individual samples
safeDo range checks to avoid segmentation fault

Returns

Sequence object containing the weighted histogram.

muladd

def muladd

Used internally to perform correlations.

See also

muladd_

def muladd_

Used internally to perform correlations.

See also

correlate

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.

integral

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.

See also

integrate

def integrate(other)

Used internally.  Call integral instead.

See also

knot

def knot(arr,  
args,  
comp,  
labels,  
rank,  
default,  
options =  {})

Used internally.  Call Sequence_.components instead.

See also

integrate_

def integrate_(other)

Used internally.  Call integral instead.

See also

divergence

def divergence

Compute divergence of n-dimensional array.  This method is the inverse function of the integral method.

See also

zip

def zip(*arrs)

Converts the elements of self and each argument to arrays and concatenates them.  Similar to Array#zip, which is part of the Ruby core.

See also

real

def real

Get real part of complex number(s).

real=

def real=

Set real part of complex number(s).

imag

def imag

Get imaginary part of complex number(s).

imag=

def imag=

Set imaginary part of complex numbers(s).

r

def r

Get red channel.

r=

def r=

Set red channel.

g

def g

Get green channel.

g=

def g=

Set green channel.

b

def b

Get blue channel.

b=

def b=

Set blue channel.

zero?

def zero?

Compare with zero.

Returns

true if equal to zero.

zero?

def nonzero?

Compare with zero.

Returns

true if not equal to zero.

-@

def -@

Compute additive inverse.

+@

def +@

Does nothing.  Returns this object itself.

abs

def abs

Compute absolute value.

arg

def arg

Compute complex argument.

conj

def conj

Compute complex conjugate.

floor

def floor

Round to largest integer not greater than this value.

ceil

def ceil

Round to smallest integer not smaller than this value.

not

def not

Compute boolean “not”.

~

def ~

Compute bitwise “not”.

round

def round

Round to nearest integer.

and

def and(other)

Boolean “and”.

Parameters

othersecond argument

or

def or(other)

Boolean “or”.

Parameters

othersecond argument

&

def &(other)

Bitwise “and”.

Parameters

othersecond argument

|

def |(other)

Bitwise “or”.

Parameters

othersecond argument

^

def ^(other)

Bitwise “xor”.

Parameters

othersecond argument

<<

Shift bits to the left.

Parameters

othersecond argument

>>

def >>(other)

Shift bits to the right.

Parameters

otheranother array or a scalar

<=>

def <=>(other)

Comparison operator.

Parameters

othersecond argument

+

def +(other)

Addition.

Parameters

othersecond argument

-

def -(other)

Subtraction.

Parameters

othersecond argument

*

def *(other)

Multiplication.

Parameters

othersecond argument

/

def /(other)

Division.

Parameters

othersecond argument

%

def %(other)

Remainder.

Parameters

othersecond argument

**

def **(other)

Power.

Parameters

othersecond argument

<

Lower-than comparison.

Parameters

othersecond argument

<=

Lower-than-or-equal-to comparison.

Parameters

othersecond argument

>

def >(other)

Greater-than comparison.

Parameters

othersecond argument

>=

def >=(other)

Greater-than-or-equal-to comparison.

Parameters

othersecond argument

eq

def eq(other)

Equal-to comparison.

ne

def ne(other)

Not-equal-to comparison.

ge

def ge(other)

Same as >=

gt

def gt(other)

Same as >

le

def le(other)

Same as <=

lt

def lt(other)

Same as <

major

def major(other)

Choose larger value of two.

Parameters

othersecond argument

minor

def minor(other)

Choose smaller value of two.

Parameters

othersecond argument
def Type.inspect
Same as Type.to_s.
def Type.to_s
Display name of this type.
def Type.to_str
Same as Type.to_s.
def Type._load(str)
Marshalling support.
def Type.element_type
Used internally.
def Type.num_elements
Used internally.
def Type.alloc(n =  1)
Allocate required memory for this type.
def Type.empty?
Check whether this is an empty array.
def Type.dimension
Returns number of dimensions for arrays or 0.
def Type.stride
Returns stride of array or nil.
def Type.contiguous?
Used internally.
def Type.strides
Returns array of strides for arrays or [].
def Type.shape
Returns array of dimensions for arrays or [].
def Type.size
Recursively compute number of elements.
def Type.check_size(*args)
Used internally to check for correct size of arguments.
def Type.check_shape(*args)
Used internally to check for correct shape of arguments.
def Type.check_filter(filter)
Used internally to check for correct shape of filter for correlation.
def Type.layout
Used internally to describe memory-layout of this type.
def Type.indgen(offset =  0,
increment =  1)
Allocate new instance and fill with index array.
def Type.typecode
Recursively get element-type for multi-dimensional arrays or return itself.
def Type.basetype
Recursively get basic type for multi-dimensional arrays and composite numbers or return itself.
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 =  {})
Used internally.
def Type.decompose
Decompose composite numbers, i.e.
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.
def Type.cache(descriptor,
*hash)
Used internally for caching JIT-methods.
def Type.coerce(other)
Used internally.
def Type.coercion(other)
Used internally for balancing native types.
def Type.===(other)
Test on identity.
def to_s
Convert data to string.
def export
Convert data to string.
def to_str
Same as to_s.
def coerce(other)
Used internally.
def _dump(depth)
Marshalling support.
def element_type
Used internally.
def num_elements
Used internally.
def typecode
Get type of elements.
def typesize
Storage size of type (number of bytes for native types, number of Ruby objects otherwise)
def size
Overall number of elements in array or 1 if this is not an array.
def empty?
Returns a boolean indicating whether this is an empty array.
def stride
Used internally to get array stride.
def layout
Used internally to describe memory-layout of this type.
def contiguous?
Used internally.
def dimension
Get number of dimensions of this array or 0 if this is not an array.
def shape
Get array with dimensions of this array or [] if this is not an array.
def strides
Used internally.
def width
Get width of array.
def height
Get height of array.
def basetype
Used internally.
def rgb?
Used internally.
def check_size(*args)
Used internally to check for correct size of arguments.
def check_shape(*args)
Used internally to check for correct shape of arguments.
def check_filter(filter)
Used internally to check for correct shape of filter for correlation.
def memory
Used internally.
def to_type(type)
Element-wise conversion to a different type.
def typecast(target,
*shape)
Used internally to typecast native data.
def reshape(*shape)
Create array with same data but different shape.
def decompose
Decompose composite numbers, i.e.
def set(value =  typecode.default)
Used internally to set content of this object to specified value.
def get
Used internally to get content of this object.
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)
Get single elements or a region of this array.
def assign(*args)
Assign new values to elements.
def []=(*args)
Assign value to an element or to a region of the array.
def ==(other)
Test on equality.
def fill!(value =  typecode.default)
Overwrite value or fill with value if this is an array.
def each
Iterator to iterate over all elements.
def multi_each(*args)
Iterator mechanism for iterating over multiple arrays at the same time.
def collect(target =  typecode)
Apply function to each element and return result.
def collect!
Apply function to each element and replace elements with result.
def multi_collect(type,
*args)
Iterator mechanism for iterating over multiple arrays at the same time.
def op(*args)
Used internally to perform element-wise operations (map operations).
def op_(*args)
Used internally to perform element-wise operations (map operations).
def inject(*args)
Similar to Array::inject.
def inject_(*args)
Used internally to perform injections (reduce operations).
def indgen!(offset =  0,
increment =  1)
Fill with index values.
def random!(n =  1)
Fill with random numbers.
def swap_rgb
Swap red and blue channel.
def conditional(a,
b)
Select elements from a or b depending whether this value is true or false.
def map(lut,  
options =  { :safe => true })
Apply element-wise look-up to array.
def hist(size,  
options =  { :target => UINT, :safe => true })
Compute histogram of the array.
def hist_weighted(size,  
weights,  
options =  { :safe => true })
Compute weighted histogram of the array.
def muladd
Used internally to perform correlations.
def muladd_
Used internally to perform correlations.
def correlate(filter)
Optimized n-dimensional correlation for small filters.
def integral
Compute integral of n-dimensional array.
def integrate(other)
Used internally.
def knot(arr,  
args,  
comp,  
labels,  
rank,  
default,  
options =  {})
Used internally.
def integrate_(other)
Used internally.
def divergence
Compute divergence of n-dimensional array.
def zip(*arrs)
Converts the elements of self and each argument to arrays and concatenates them.
def real
Get real part of complex number(s).
def real=
Set real part of complex number(s).
def imag
Get imaginary part of complex number(s).
def imag=
Set imaginary part of complex numbers(s).
def r
Get red channel.
def r=
Set red channel.
def g
Get green channel.
def g=
Set green channel.
def b
Get blue channel.
def b=
Set blue channel.
def zero?
Compare with zero.
def -@
Compute additive inverse.
def +@
Does nothing.
def abs
Compute absolute value.
def arg
Compute complex argument.
def conj
Compute complex conjugate.
def floor
Round to largest integer not greater than this value.
def ceil
Round to smallest integer not smaller than this value.
def not
Compute boolean “not”.
def ~
Compute bitwise “not”.
def round
Round to nearest integer.
def and(other)
Boolean “and”.
def or(other)
Boolean “or”.
def &(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 eq(other)
Equal-to comparison.
def ne(other)
Not-equal-to comparison.
def ge(other)
Same as >=
def gt(other)
Same as >
def le(other)
Same as <=
def lt(other)
Same as <
def major(other)
Choose larger value of two.
def minor(other)
Choose smaller value of two.
Single-precision floating-point number.
This class provides fast (multi-dimensional) Ruby arrays where all elements are of the same type.
Here is an example session with interactive Ruby (irb).
This class is used to map Ruby objects on native datatypes and to do element-type coercions for native datatypes.
def components(default =  typecode.default,
target =  UINT)
N-dimensional connected component labeling.
Close