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/node.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/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/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, Operations Classes: BOOL, COMPLEX_, Composite, Diagonal, Element, ElementWise_, FLOAT_, GCCCache, GCCContext, GCCFunction, GCCType, GCCValue, Histogram, INDEX_, INT_, Inject, Integral, InternalComplex, Lambda, List, Lookup, Lut, Malloc, MultiArray, Node, OBJECT, Pointer_, RGB, RGB_, Sequence, Sequence_, Store, Variable
Constant Summary collapse
- SINGLE =
false
- DOUBLE =
true
- SFLOAT =
FLOAT SINGLE
- DFLOAT =
FLOAT DOUBLE
- SCOMPLEX =
COMPLEX SFLOAT
- DCOMPLEX =
COMPLEX DFLOAT
- BYTERGB =
RGB BYTE
- UBYTERGB =
RGB UBYTE
- SINTRGB =
RGB SINT
- USINTRGB =
RGB USINT
- INTRGB =
RGB INT
- UINTRGB =
RGB UINT
- LONGRGB =
RGB LONG
- ULONGRGB =
RGB ULONG
- SFLOATRGB =
RGB SFLOAT
- DFLOATRGB =
RGB DFLOAT
- UNSIGNED =
Boolean constant to use as a parameter for creating integer classes
The value is
false
. false
- SIGNED =
Boolean constant to use as a parameter for creating integer classes
The value is
true
. 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
-
.BOOL(value) ⇒ BOOL
Shortcut for constructor.
-
.BYTE(value) ⇒ BYTE
Shortcut for constructor.
-
.BYTERGB(value) ⇒ BYTERGB
Shortcut for constructor.
- .COMPLEX(arg) ⇒ Object
-
.DCOMPLEX(value) ⇒ DCOMPLEX
Shortcut for constructor.
-
.DFLOAT(value) ⇒ DFLOAT
Shortcut for constructor.
-
.DFLOATRGB(value) ⇒ DFLOATRGB
Shortcut for constructor.
-
.eager(*shape) { ... } ⇒ Object, Node
Method for performing computations in eager mode.
-
.ElementWise(operation, key, conversion = lambda { |t| t.send :contiguous }) ⇒ Class
Create a class deriving from
ElementWise_
. - .FLOAT(double) ⇒ Object
- .INDEX(size) ⇒ Object
-
.INT(arg, signed = nil) ⇒ Object
Create a class deriving from
INT_
or instantiate anINT
object. -
.INTRGB(value) ⇒ INTRGB
Shortcut for constructor.
-
.lazy(*shape) { ... } ⇒ Object, Node
Method for performing computations in lazy mode.
-
.LONG(value) ⇒ LONG
Shortcut for constructor.
-
.LONGRGB(value) ⇒ LONGRGB
Shortcut for constructor.
-
.MultiArray(element_type, *shape) ⇒ Class
Create multi-dimensional array type.
-
.OBJECT(value) ⇒ OBJECT
Shortcut for constructor.
- .Pointer(target) ⇒ Object
- .RGB(arg, g = nil, b = nil) ⇒ Object
-
.SCOMPLEX(value) ⇒ SCOMPLEX
Shortcut for constructor.
- .Sequence(element_type, num_elements) ⇒ Object
-
.SFLOAT(value) ⇒ SFLOAT
Shortcut for constructor.
-
.SFLOATRGB(value) ⇒ SFLOATRGB
Shortcut for constructor.
-
.SINT(value) ⇒ SINT
Shortcut for constructor.
-
.SINTRGB(value) ⇒ SINTRGB
Shortcut for constructor.
-
.sum(*shape) { ... } ⇒ Object, Node
Method for summing values.
-
.UBYTE(value) ⇒ UBYTE
Shortcut for constructor.
-
.UBYTERGB(value) ⇒ UBYTERGB
Shortcut for constructor.
-
.UINT(value) ⇒ UINT
Shortcut for constructor.
-
.UINTRGB(value) ⇒ UINTRGB
Shortcut for constructor.
-
.ULONG(value) ⇒ ULONG
Shortcut for constructor.
-
.ULONGRGB(value) ⇒ ULONGRGB
Shortcut for constructor.
-
.USINT(value) ⇒ USINT
Shortcut for constructor.
-
.USINTRGB(value) ⇒ USINTRGB
Shortcut for constructor.
Class Method Details
.BOOL(value) ⇒ BOOL
Shortcut for constructor
The method calls BOOL.new
.
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
.
319 320 321 |
# File 'lib/multiarray/int.rb', line 319 def BYTE( value ) BYTE.new value end |
.BYTERGB(value) ⇒ BYTERGB
Shortcut for constructor
The method calls BYTERGB.new
.
573 574 575 |
# File 'lib/multiarray/rgb.rb', line 573 def BYTERGB( value ) BYTERGB.new value end |
.COMPLEX(arg) ⇒ Object
747 748 749 750 751 |
# File 'lib/multiarray/complex.rb', line 747 def COMPLEX( arg ) retval = Class.new COMPLEX_ retval.element_type = arg retval end |
.DCOMPLEX(value) ⇒ DCOMPLEX
Shortcut for constructor
The method calls DCOMPLEX.new
.
781 782 783 |
# File 'lib/multiarray/complex.rb', line 781 def DCOMPLEX( value ) DCOMPLEX.new value end |
.DFLOAT(value) ⇒ DFLOAT
Shortcut for constructor
The method calls DFLOAT.new
.
238 239 240 |
# File 'lib/multiarray/float.rb', line 238 def DFLOAT( value ) DFLOAT.new value end |
.DFLOATRGB(value) ⇒ DFLOATRGB
Shortcut for constructor
The method calls DFLOATRGB.new
.
690 691 692 |
# File 'lib/multiarray/rgb.rb', line 690 def DFLOATRGB( value ) DFLOATRGB.new value end |
.eager(*shape) { ... } ⇒ Object, Node
Method for performing computations in eager mode
attempts to infer the shape if not specified.
595 596 597 598 599 600 601 602 603 604 |
# File 'lib/multiarray.rb', line 595 def eager( *shape, &action ) previous = Thread.current[ :lazy ] Thread.current[ :lazy ] = false begin retval = lazy *shape, &action retval.is_a?( Node ) ? retval.force : retval ensure Thread.current[ :lazy ] = previous end end |
.ElementWise(operation, key, conversion = lambda { |t| t.send :contiguous }) ⇒ Class
Create a class deriving from ElementWise_
225 226 227 228 229 230 231 |
# File 'lib/multiarray/elementwise.rb', line 225 def ElementWise( operation, key, conversion = lambda { |t| t.send :contiguous } ) retval = Class.new ElementWise_ retval.operation = operation retval.key = key retval.conversion = conversion retval end |
.FLOAT(double) ⇒ Object
203 204 205 206 207 |
# File 'lib/multiarray/float.rb', line 203 def FLOAT( double ) retval = Class.new FLOAT_ retval.double = double retval end |
.INDEX(size) ⇒ Object
105 106 107 108 109 110 |
# File 'lib/multiarray/index.rb', line 105 def INDEX( size ) retval = Class.new INDEX_ size = INT.new( size ) unless size.is_a? Node retval.size = size retval end |
.INT(bits, signed) ⇒ Class .INT(value) ⇒ INT
Create a class deriving from INT_
or instantiate an INT
object
273 274 275 276 277 278 279 280 281 282 |
# File 'lib/multiarray/int.rb', line 273 def INT( arg, signed = nil ) if signed.nil? INT.new arg else retval = Class.new INT_ retval.bits = arg retval.signed = signed retval end end |
.INTRGB(value) ⇒ INTRGB
Shortcut for constructor
The method calls INTRGB.new
.
625 626 627 |
# File 'lib/multiarray/rgb.rb', line 625 def INTRGB( value ) INTRGB.new value end |
.lazy(*shape) { ... } ⇒ Object, Node
Method for performing computations in lazy mode
attempts to infer the shape if not specified.
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 |
# File 'lib/multiarray.rb', line 564 def lazy( *shape, &action ) previous = Thread.current[ :lazy ] Thread.current[ :lazy ] = true begin = shape.last.is_a?( Hash ) ? shape.pop : {} arity = [ :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.is_a? Node Lambda.new index, term end ensure Thread.current[ :lazy ] = previous end end |
.LONG(value) ⇒ LONG
Shortcut for constructor
The method calls LONG.new
.
384 385 386 |
# File 'lib/multiarray/int.rb', line 384 def LONG( value ) LONG.new value end |
.LONGRGB(value) ⇒ LONGRGB
Shortcut for constructor
The method calls LONGRGB.new
.
651 652 653 |
# File 'lib/multiarray/rgb.rb', line 651 def LONGRGB( value ) LONGRGB.new value end |
.MultiArray(element_type, *shape) ⇒ Class
Create multi-dimensional array type
82 83 84 85 86 87 88 89 |
# File 'lib/multiarray/multiarray.rb', line 82 def MultiArray( element_type, *shape ) if shape.empty? element_type else Hornetseye::Sequence MultiArray( element_type, *shape[ 0 ... -1 ] ), shape.last end end |
.OBJECT(value) ⇒ OBJECT
Shortcut for constructor
The method calls OBJECT.new
.
169 170 171 |
# File 'lib/multiarray/object.rb', line 169 def OBJECT( value ) OBJECT.new value end |
.Pointer(target) ⇒ Object
231 232 233 234 235 |
# File 'lib/multiarray/pointer.rb', line 231 def Pointer( target ) p = Class.new Pointer_ p.target = target p end |
.RGB(arg, g = nil, b = nil) ⇒ Object
532 533 534 535 536 537 538 539 540 |
# File 'lib/multiarray/rgb.rb', line 532 def RGB( arg, g = nil, b = nil ) if g.nil? and b.nil? retval = Class.new RGB_ retval.element_type = arg retval else RGB.new arg, g, b end end |
.SCOMPLEX(value) ⇒ SCOMPLEX
Shortcut for constructor
The method calls SCOMPLEX.new
.
768 769 770 |
# File 'lib/multiarray/complex.rb', line 768 def SCOMPLEX( value ) SCOMPLEX.new value end |
.Sequence(element_type, num_elements) ⇒ Object
383 384 385 386 387 388 |
# File 'lib/multiarray/sequence.rb', line 383 def Sequence( element_type, num_elements ) retval = Class.new Sequence_ retval.element_type = element_type retval.num_elements = num_elements retval end |
.SFLOAT(value) ⇒ SFLOAT
Shortcut for constructor
The method calls SFLOAT.new
.
223 224 225 |
# File 'lib/multiarray/float.rb', line 223 def SFLOAT( value ) SFLOAT.new value end |
.SFLOATRGB(value) ⇒ SFLOATRGB
Shortcut for constructor
The method calls SFLOATRGB.new
.
677 678 679 |
# File 'lib/multiarray/rgb.rb', line 677 def SFLOATRGB( value ) SFLOATRGB.new value end |
.SINT(value) ⇒ SINT
Shortcut for constructor
The method calls SINT.new
.
345 346 347 |
# File 'lib/multiarray/int.rb', line 345 def SINT( value ) SINT.new value end |
.SINTRGB(value) ⇒ SINTRGB
Shortcut for constructor
The method calls SINTRGB.new
.
599 600 601 |
# File 'lib/multiarray/rgb.rb', line 599 def SINTRGB( value ) SINTRGB.new value end |
.sum(*shape) { ... } ⇒ Object, Node
Method for summing values
attempts to infer the shape if not specified.
615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 |
# File 'lib/multiarray.rb', line 615 def sum( *shape, &action ) = shape.last.is_a?( Hash ) ? shape.pop : {} arity = [ :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 = 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
.
332 333 334 |
# File 'lib/multiarray/int.rb', line 332 def UBYTE( value ) UBYTE.new value end |
.UBYTERGB(value) ⇒ UBYTERGB
Shortcut for constructor
The method calls UBYTERGB.new
.
586 587 588 |
# File 'lib/multiarray/rgb.rb', line 586 def UBYTERGB( value ) UBYTERGB.new value end |
.UINT(value) ⇒ UINT
Shortcut for constructor
The method calls UINT.new
.
371 372 373 |
# File 'lib/multiarray/int.rb', line 371 def UINT( value ) UINT.new value end |
.UINTRGB(value) ⇒ UINTRGB
Shortcut for constructor
The method calls UINTRGB.new
.
638 639 640 |
# File 'lib/multiarray/rgb.rb', line 638 def UINTRGB( value ) UINTRGB.new value end |
.ULONG(value) ⇒ ULONG
Shortcut for constructor
The method calls ULONG.new
.
397 398 399 |
# File 'lib/multiarray/int.rb', line 397 def ULONG( value ) ULONG.new value end |
.ULONGRGB(value) ⇒ ULONGRGB
Shortcut for constructor
The method calls ULONGRGB.new
.
664 665 666 |
# File 'lib/multiarray/rgb.rb', line 664 def ULONGRGB( value ) ULONGRGB.new value end |