Class: Hornetseye::COMPLEX_

Inherits:
Composite show all
Defined in:
docs/multiarray/lib/multiarray/complex.rb

Overview

Class for representing native complex values

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Element

fetch

Methods inherited from Node

#<=>, ===, #[], #[]=, #allocate, #b=, #b_with_decompose, #basetype, #between?, bool, #check_shape, #clip, coercion_bool, coercion_byte, coercion_maxint, #collect, #components, cond, #conditional, #convolve, #decompose, #dilate, dimension, #dimension, #downsample, #each, #empty?, #eq_with_multiarray, #erode, #fill!, #flip, float_scalar, floating, #fmod_with_float, #g=, #g_with_decompose, #gauss_blur, #gauss_gradient, #height, #histogram, #histogram_with_rgb, #if, #if_else, #imag=, #imag_with_decompose, indgen, #inject, #inspect, #integral, #lut, #lut_with_rgb, #mask, #matched?, #max, #mean, #memorise, #memory, #min, #normalise, #orig_to_cvmat, #orig_to_type_with_frame, #prod, #r=, #r_with_decompose, #range, #real=, #real_with_decompose, #reshape, rgb?, #rgb?, #roll, #save_dfloat, #save_dfloatrgb, #save_magick, #save_openexr, #save_sfloat, #save_sfloatrgb, #save_ubyte, #save_ubytergb, #save_uint, #save_uintrgb, #save_usint, #save_usintrgb, scalar, shape, #shape, #shift, #show, #size, #sobel, #stretch, #sum, #swap_rgb_with_scalar, #to_a, #to_cvmat, #to_magick, #to_narray, to_type, #to_type, #to_type_with_frame, #to_type_with_identity, #to_type_with_rgb, #transpose, typecode, #typecode, #unmask, #unroll, #warp, #width

Constructor Details

#initialize(value = self.class.default) ⇒ COMPLEX_

Constructor for native complex number

Parameters:

  • value (Complex, InternalComplex) (defaults to: self.class.default)

    Complex number.



857
858
859
860
861
862
863
864
865
866
# File 'docs/multiarray/lib/multiarray/complex.rb', line 857

def initialize( value = self.class.default )
  if Thread.current[ :function ].nil? or
    [ value.real, value.imag ].all? { |c| c.is_a? GCCValue }
    @value = value
  else
    real = GCCValue.new Thread.current[ :function ], value.real.to_s
    imag = GCCValue.new Thread.current[ :function ], value.imag.to_s
    @value = InternalComplex.new real, imag
  end
end

Class Method Details

.==(other) ⇒ Boolean

Test equality of classes

Parameters:

  • other (Object)

    Object to compare with.

Returns:

  • (Boolean)

    Boolean indicating whether classes are equal.



827
828
829
830
# File 'docs/multiarray/lib/multiarray/complex.rb', line 827

def ==(other)
  other.is_a? Class and other < COMPLEX_ and
    element_type == other.element_type
end

.inherit(element_type) ⇒ Object



716
717
718
719
720
# File 'docs/multiarray/lib/multiarray/complex.rb', line 716

def inherit(element_type)
  retval = Class.new self
  retval.element_type = element_type
  retval
end

.inspectString

Display information about this class

Returns:

  • (String)

    Returns string with information about this class (e.g. “SCOMPLEX”).



762
763
764
765
766
767
768
# File 'docs/multiarray/lib/multiarray/complex.rb', line 762

def inspect
  unless element_type.nil?
    IDENTIFIER[ element_type ] || "COMPLEX(#{element_type.inspect})"
  else
    super
  end
end

Instance Method Details

#dupCOMPLEX_

Duplicate object

Returns:



871
872
873
874
875
876
877
878
879
880
881
# File 'docs/multiarray/lib/multiarray/complex.rb', line 871

def dup
  if Thread.current[ :function ]
    real = Thread.current[ :function ].variable self.class.element_type, 'v'
    imag = Thread.current[ :function ].variable self.class.element_type, 'v'
    real.assign @value.real
    imag.assign @value.imag
    self.class.new InternalComplex.new( real, imag )
  else
    self.class.new get
  end
end