Module: Hornetseye

Defined in:
lib/multiarray.rb,
lib/multiarray/int.rb,
lib/multiarray/lut.rb,
lib/multiarray/rgb.rb,
lib/multiarray/rgb.rb,
lib/multiarray/bool.rb,
lib/multiarray/list.rb,
lib/multiarray/mask.rb,
lib/multiarray/node.rb,
lib/multiarray/field.rb,
lib/multiarray/float.rb,
lib/multiarray/index.rb,
lib/multiarray/store.rb,
lib/multiarray/inject.rb,
lib/multiarray/lambda.rb,
lib/multiarray/lookup.rb,
lib/multiarray/malloc.rb,
lib/multiarray/object.rb,
lib/multiarray/random.rb,
lib/multiarray/unmask.rb,
lib/multiarray/complex.rb,
lib/multiarray/complex.rb,
lib/multiarray/element.rb,
lib/multiarray/gcctype.rb,
lib/multiarray/methods.rb,
lib/multiarray/pointer.rb,
lib/multiarray/diagonal.rb,
lib/multiarray/gcccache.rb,
lib/multiarray/gccvalue.rb,
lib/multiarray/integral.rb,
lib/multiarray/sequence.rb,
lib/multiarray/variable.rb,
lib/multiarray/composite.rb,
lib/multiarray/histogram.rb,
lib/multiarray/shortcuts.rb,
lib/multiarray/components.rb,
lib/multiarray/gcccontext.rb,
lib/multiarray/multiarray.rb,
lib/multiarray/operations.rb,
lib/multiarray/elementwise.rb,
lib/multiarray/gccfunction.rb

Overview

Namespace of Hornetseye computer vision library

Defined Under Namespace

Modules: Methods, MultiArrayConstructor, MultiArrayConversion, ReaderConversion Classes: BOOL, COMPLEX_, Components, Composite, Diagonal, Element, ElementWise_, FLOAT_, Field_, GCCCache, GCCContext, GCCFunction, GCCType, GCCValue, Histogram, INDEX_, INT_, Inject, Integral, InternalComplex, Lambda, List, Lookup, Lut, Malloc, Mask, MultiArray, Node, OBJECT, Pointer_, RGB, RGB_, Random, Sequence, Store, Unmask, Variable

Constant Summary collapse

SINGLE =

Boolean constant to use as a parameter for creating floating point classes

The value is false.

See Also:

  • #FLOAT
false
DOUBLE =

Boolean constant to use as a parameter for creating floating point classes

The value is true.

See Also:

  • #FLOAT
true
SFLOAT =

Single-precision floating-point number

FLOAT SINGLE
DFLOAT =

Double-precision floating-point number

FLOAT DOUBLE
SCOMPLEX =

Convenience shortcut for single-precision floating-point complex numbers

COMPLEX SFLOAT
DCOMPLEX =

Convenience shortcut for double-precision floating-point complex numbers

COMPLEX DFLOAT
BYTERGB =

24-bit unsigned RGB-triplet

RGB BYTE
UBYTERGB =

24-bit signed RGB-triplet

RGB UBYTE
SINTRGB =

48-bit unsigned RGB-triplet

RGB SINT
USINTRGB =

48-bit signed RGB-triplet

RGB USINT
INTRGB =

96-bit unsigned RGB-triplet

RGB INT
UINTRGB =

96-bit signed RGB-triplet

RGB UINT
LONGRGB =

192-bit unsigned RGB-triplet

RGB LONG
ULONGRGB =

192-bit signed RGB-triplet

RGB ULONG
SFLOATRGB =

single precision RGB-triplet

RGB SFLOAT
DFLOATRGB =

double precision RGB-triplet

RGB DFLOAT
UNSIGNED =

Boolean constant to use as a parameter for creating integer classes

The value is false.

See Also:

  • #INT
false
SIGNED =

Boolean constant to use as a parameter for creating integer classes

The value is true.

See Also:

  • #INT
true
BYTE =

8-bit signed integer

INT  8, SIGNED
UBYTE =

8-bit unsigned integer

INT  8, UNSIGNED
SINT =

16-bit signed integer

INT 16, SIGNED
USINT =

16-bit unsigned integer

INT 16, UNSIGNED
INT =

32-bit signed integer

INT 32, SIGNED
UINT =

32-bit unsigned integer

INT 32, UNSIGNED
LONG =

64-bit signed integer

INT 64, SIGNED
ULONG =

64-bit unsigned integer

INT 64, UNSIGNED

Class Method Summary collapse

Class Method Details

.BOOL(value) ⇒ BOOL

Shortcut for constructor

The method calls BOOL.new.

Parameters:

  • value (Boolean)

    Boolean value.

Returns:

  • (BOOL)

    The wrapped boolean value.



148
149
150
# File 'lib/multiarray/bool.rb', line 148

def BOOL( value )
  BOOL.new value
end

.BYTE(value) ⇒ BYTE

Shortcut for constructor

The method calls BYTE.new.

Parameters:

  • value (Integer)

    Integer value.

Returns:

  • (BYTE)

    The wrapped integer value.



350
351
352
# File 'lib/multiarray/int.rb', line 350

def BYTE( value )
  BYTE.new value
end

.BYTERGB(value) ⇒ BYTERGB

Shortcut for constructor

The method calls BYTERGB.new.

Parameters:

  • value (RGB)

    RGB value.

Returns:

  • (BYTERGB)

    The wrapped RGB value.



746
747
748
# File 'lib/multiarray/rgb.rb', line 746

def BYTERGB(value)
  BYTERGB.new value
end

.COMPLEX(element_type) ⇒ Class

Create a class deriving from COMPLEX_

Create a class deriving from COMPLEX_. The parameter element_type is assigned to the corresponding attribute of the resulting class.

Parameters:

  • element_type (Class)

    The native type of the complex components.

Returns:

  • (Class)

    A class deriving from COMPLEX_.

See Also:



1064
1065
1066
# File 'lib/multiarray/complex.rb', line 1064

def COMPLEX( element_type )
  COMPLEX_.inherit element_type
end

.DCOMPLEX(value) ⇒ DCOMPLEX

Shortcut for constructor

The method calls DCOMPLEX.new.

Parameters:

  • value (Complex)

    Complex value.

Returns:

  • (DCOMPLEX)

    The wrapped Complex value.



1098
1099
1100
# File 'lib/multiarray/complex.rb', line 1098

def DCOMPLEX(value)
  DCOMPLEX.new value
end

.DFLOAT(value) ⇒ DFLOAT

Shortcut for constructor

The method calls DFLOAT.new.

Parameters:

  • value (Float)

    Floating point value.

Returns:

  • (DFLOAT)

    The wrapped floating point value.



278
279
280
# File 'lib/multiarray/float.rb', line 278

def DFLOAT( value )
  DFLOAT.new value
end

.DFLOATRGB(value) ⇒ DFLOATRGB

Shortcut for constructor

The method calls DFLOATRGB.new.

Parameters:

  • value (RGB)

    RGB value.

Returns:



863
864
865
# File 'lib/multiarray/rgb.rb', line 863

def DFLOATRGB(value)
  DFLOATRGB.new value
end

.ElementWise(operation, key, conversion = lambda { |t| t.send :identity }) ⇒ Class

Create a class deriving from ElementWise_

Parameters:

  • operation (Proc)

    A closure with the operation to perform.

  • key (Symbol, String)

    A unique descriptor to identify this operation.

  • conversion (Proc) (defaults to: lambda { |t| t.send :identity })

    A closure for performing the type conversion.

Returns:

  • (Class)

    A class deriving from ElementWise_.

See Also:



230
231
232
233
234
235
236
# File 'lib/multiarray/elementwise.rb', line 230

def ElementWise( operation, key, conversion = lambda { |t| t.send :identity } )
  retval = Class.new ElementWise_
  retval.operation = operation
  retval.key = key
  retval.conversion = conversion
  retval
end

.finalise(*shape) { ... } ⇒ Object, Node

Method for performing a lazy computation and then forcing the result

attempts to infer the shape if not specified.

Parameters:

  • *shape (Array<Integer>)

    Optional shape of result. The method

Yields:

  • Operation computing array elements.

Returns:



805
806
807
808
809
810
811
812
813
814
# File 'lib/multiarray.rb', line 805

def finalise( *shape, &action )
  previous = Thread.current[ :lazy ]
  Thread.current[ :lazy ] = false
  begin
    retval = lazy *shape, &action
    retval.matched? ? retval.force : retval
  ensure
    Thread.current[ :lazy ] = previous
  end
end

.FLOAT(double) ⇒ Class

Create a class deriving from FLOAT_

Create a class deriving from FLOAT_. The parameters double is assigned to the corresponding attributes of the resulting class.

Parameters:

  • double (Boolean)

    Specify SINGLE or DOUBLE here.

Returns:

  • (Class)

    A class deriving from FLOAT_.

See Also:



242
243
244
# File 'lib/multiarray/float.rb', line 242

def FLOAT(double)
  FLOAT_.inherit double
end

.INDEX(size) ⇒ Class

Instantiate the type of an array index

Parameters:

Returns:

  • (Class)

    Returns a class deriving from INDEX_.



115
116
117
118
119
120
# File 'lib/multiarray/index.rb', line 115

def INDEX( size )
  retval = Class.new INDEX_
  size = INT.new(size) unless size.matched?
  retval.size = size
  retval
end

.INT(bits, signed) ⇒ Class .INT(value) ⇒ INT

Create a class deriving from INT_ or instantiate an INT object

Overloads:

  • .INT(bits, signed) ⇒ Class

    Create a class deriving from INT_. The parameters bits and signed are assigned to the corresponding attributes of the resulting class.

    Parameters:

    • bits (Integer)

      Number of bits of native integer.

    • signed (Boolean)

      Specify UNSIGNED or SIGNED here.

    Returns:

    • (Class)

      A class deriving from INT_.

  • .INT(value) ⇒ INT

    This is a shortcut for INT.new( value ).

    Parameters:

    • value (Integer)

      Initial value for integer object.

    Returns:

    • (INT)

      Wrapped integer value.

Returns:

  • (Class, INT)

    A class deriving from INT_ or a wrapped integer value.

See Also:



307
308
309
310
311
312
313
# File 'lib/multiarray/int.rb', line 307

def INT( arg, signed = nil )
  if signed.nil?
    INT.new arg
  else
    INT_.inherit arg, signed
  end
end

.INTRGB(value) ⇒ INTRGB

Shortcut for constructor

The method calls INTRGB.new.

Parameters:

  • value (RGB)

    RGB value.

Returns:

  • (INTRGB)

    The wrapped RGB value.



798
799
800
# File 'lib/multiarray/rgb.rb', line 798

def INTRGB(value)
  INTRGB.new value
end

.lazy(*shape) { ... } ⇒ Object, Node

Method for performing computations in lazy mode resulting in a lazy expression

attempts to infer the shape if not specified.

Parameters:

  • *shape (Array<Integer>)

    Optional shape of result. The method

Yields:

  • Operation to compute array elements lazily.

Returns:



774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
# File 'lib/multiarray.rb', line 774

def lazy( *shape, &action )
  previous = Thread.current[ :lazy ]
  Thread.current[ :lazy ] = true
  begin
    options = shape.last.is_a?( Hash ) ? shape.pop : {}
    arity = options[ :arity ] || [ action.arity, shape.size ].max
    if arity <= 0
      action.call
    else
      index = Variable.new shape.empty? ? Hornetseye::INDEX( nil ) :
                                          Hornetseye::INDEX( shape.pop )
      term = lazy *( shape + [ :arity => arity - 1 ] ) do |*args|
        action.call *( args + [ index ] )
      end
      term = Node.match(term).new term unless term.matched?
      Lambda.new index, term.sexp
    end
  ensure
    Thread.current[ :lazy ] = previous
  end
end

.LONG(value) ⇒ LONG

Shortcut for constructor

The method calls LONG.new.

Parameters:

  • value (Integer)

    Integer value.

Returns:

  • (LONG)

    The wrapped integer value.



415
416
417
# File 'lib/multiarray/int.rb', line 415

def LONG( value )
  LONG.new value
end

.LONGRGB(value) ⇒ LONGRGB

Shortcut for constructor

The method calls LONGRGB.new.

Parameters:

  • value (RGB)

    RGB value.

Returns:

  • (LONGRGB)

    The wrapped RGB value.



824
825
826
# File 'lib/multiarray/rgb.rb', line 824

def LONGRGB(value)
  LONGRGB.new value
end

.MultiArray(typecode, dimension) ⇒ Object



99
100
101
102
103
104
105
# File 'lib/multiarray/multiarray.rb', line 99

def MultiArray(typecode, dimension)
  if dimension > 0
    Field_.inherit typecode.typecode, typecode.dimension + dimension
  else
    Hornetseye::Pointer typecode
  end
end

.OBJECT(value) ⇒ OBJECT

Shortcut for constructor

The method calls OBJECT.new.

Parameters:

  • value (Object)

    Ruby object.

Returns:

  • (OBJECT)

    The wrapped Ruby object.



165
166
167
# File 'lib/multiarray/object.rb', line 165

def OBJECT( value )
  OBJECT.new value
end

.Pointer(target) ⇒ Class

Create a class deriving from Pointer_

Create a class deriving from Pointer_. The parameter target is assigned to the corresponding attribute of the resulting class.

Parameters:

  • target (Class)

    The native type of the complex components.

Returns:

  • (Class)

    A class deriving from Pointer_.

See Also:



278
279
280
281
282
# File 'lib/multiarray/pointer.rb', line 278

def Pointer( target )
  p = Class.new Pointer_
  p.target = target
  p
end

.RGB(element_type) ⇒ Class .RGB(r, g, b) ⇒ RGB

Create a class deriving from RGB_ or instantiate an RGB object

Overloads:

  • .RGB(element_type) ⇒ Class

    Create a class deriving from RGB_. The parameters element_type is assigned to the corresponding attribute of the resulting class.

    Parameters:

    • element_type (Class)

      Element type of native RGB value.

    Returns:

    • (Class)

      A class deriving from RGB_.

  • .RGB(r, g, b) ⇒ RGB

    This is a shortcut for RGB.new( r, g, b ).

    Parameters:

    • r (Object)

      Initial value for red channel.

    • g (Object)

      Initial value for green channel.

    • b (Object)

      Initial value for blue channel.

    Returns:

    • (RGB)

      The RGB value.

Returns:

  • (Class, RGB)

    A class deriving from RGB_ or an RGB value.

See Also:



697
698
699
700
701
702
703
# File 'lib/multiarray/rgb.rb', line 697

def RGB( arg, g = nil, b = nil )
  if g.nil? and b.nil?
    RGB_.inherit arg
  else
    RGB.new arg, g, b
  end
end

.SCOMPLEX(value) ⇒ SCOMPLEX

Shortcut for constructor

The method calls SCOMPLEX.new.

Parameters:

  • value (Complex)

    Complex value.

Returns:

  • (SCOMPLEX)

    The wrapped Complex value.



1085
1086
1087
# File 'lib/multiarray/complex.rb', line 1085

def SCOMPLEX(value)
  SCOMPLEX.new value
end

.Sequence(element_type) ⇒ Class

Create a class to represent one-dimensional uniform arrays

Parameters:

  • element_type (Class)

    The element type of the native array.

Returns:

  • (Class)

    A class representing a one-dimensional uniform array.



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

def Sequence(element_type)
  Hornetseye::MultiArray element_type, 1
end

.SFLOAT(value) ⇒ SFLOAT

Shortcut for constructor

The method calls SFLOAT.new.

Parameters:

  • value (Float)

    Floating point value.

Returns:

  • (SFLOAT)

    The wrapped floating point value.



263
264
265
# File 'lib/multiarray/float.rb', line 263

def SFLOAT( value )
  SFLOAT.new value
end

.SFLOATRGB(value) ⇒ SFLOATRGB

Shortcut for constructor

The method calls SFLOATRGB.new.

Parameters:

  • value (RGB)

    RGB value.

Returns:



850
851
852
# File 'lib/multiarray/rgb.rb', line 850

def SFLOATRGB(value)
  SFLOATRGB.new value
end

.SINT(value) ⇒ SINT

Shortcut for constructor

The method calls SINT.new.

Parameters:

  • value (Integer)

    Integer value.

Returns:

  • (SINT)

    The wrapped integer value.



376
377
378
# File 'lib/multiarray/int.rb', line 376

def SINT( value )
  SINT.new value
end

.SINTRGB(value) ⇒ SINTRGB

Shortcut for constructor

The method calls SINTRGB.new.

Parameters:

  • value (RGB)

    RGB value.

Returns:

  • (SINTRGB)

    The wrapped RGB value.



772
773
774
# File 'lib/multiarray/rgb.rb', line 772

def SINTRGB(value)
  SINTRGB.new value
end

.sum(*shape) { ... } ⇒ Object, Node

Method for summing values

attempts to infer the shape if not specified.

Parameters:

  • *shape (Array<Integer>)

    Optional shape of result. The method

Yields:

  • Operation returning array elements.

Returns:



825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
# File 'lib/multiarray.rb', line 825

def sum( *shape, &action )
  options = shape.last.is_a?( Hash ) ? shape.pop : {}
  arity = options[ :arity ] || [ action.arity, shape.size ].max
  if arity <= 0
    term = action.call
    term.matched? ? term.to_type(term.typecode.maxint) : term
  else
    index = Variable.new shape.empty? ? Hornetseye::INDEX( nil ) :
                         Hornetseye::INDEX( shape.pop )
    term = sum *( shape + [ :arity => arity - 1 ] ) do |*args|
      action.call *( args + [ index ] )
    end
    var1 = Variable.new term.typecode
    var2 = Variable.new term.typecode
    Inject.new( term, index, nil, var1 + var2, var1, var2 ).force
  end
end

.UBYTE(value) ⇒ UBYTE

Shortcut for constructor

The method calls UBYTE.new.

Parameters:

  • value (Integer)

    Integer value.

Returns:

  • (UBYTE)

    The wrapped integer value.



363
364
365
# File 'lib/multiarray/int.rb', line 363

def UBYTE( value )
  UBYTE.new value
end

.UBYTERGB(value) ⇒ UBYTERGB

Shortcut for constructor

The method calls UBYTERGB.new.

Parameters:

  • value (RGB)

    RGB value.

Returns:



759
760
761
# File 'lib/multiarray/rgb.rb', line 759

def UBYTERGB(value)
  UBYTERGB.new value
end

.UINT(value) ⇒ UINT

Shortcut for constructor

The method calls UINT.new.

Parameters:

  • value (Integer)

    Integer value.

Returns:

  • (UINT)

    The wrapped integer value.



402
403
404
# File 'lib/multiarray/int.rb', line 402

def UINT( value )
  UINT.new value
end

.UINTRGB(value) ⇒ UINTRGB

Shortcut for constructor

The method calls UINTRGB.new.

Parameters:

  • value (RGB)

    RGB value.

Returns:

  • (UINTRGB)

    The wrapped RGB value.



811
812
813
# File 'lib/multiarray/rgb.rb', line 811

def UINTRGB(value)
  UINTRGB.new value
end

.ULONG(value) ⇒ ULONG

Shortcut for constructor

The method calls ULONG.new.

Parameters:

  • value (Integer)

    Integer value.

Returns:

  • (ULONG)

    The wrapped integer value.



428
429
430
# File 'lib/multiarray/int.rb', line 428

def ULONG( value )
  ULONG.new value
end

.ULONGRGB(value) ⇒ ULONGRGB

Shortcut for constructor

The method calls ULONGRGB.new.

Parameters:

  • value (RGB)

    RGB value.

Returns:



837
838
839
# File 'lib/multiarray/rgb.rb', line 837

def ULONGRGB(value)
  ULONGRGB.new value
end

.USINT(value) ⇒ USINT

Shortcut for constructor

The method calls USINT.new.

Parameters:

  • value (Integer)

    Integer value.

Returns:

  • (USINT)

    The wrapped integer value.



389
390
391
# File 'lib/multiarray/int.rb', line 389

def USINT( value )
  USINT.new value
end

.USINTRGB(value) ⇒ USINTRGB

Shortcut for constructor

The method calls USINTRGB.new.

Parameters:

  • value (RGB)

    RGB value.

Returns:



785
786
787
# File 'lib/multiarray/rgb.rb', line 785

def USINTRGB(value)
  USINTRGB.new value
end