Class: Hornetseye::Histogram

Inherits:
Node show all
Defined in:
lib/multiarray/histogram.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

===, #[], #[]=, array_type, basetype, #basetype, bool, byte, #check_shape, #coerce, coercion_bool, coercion_byte, coercion_maxint, compilable?, cond, contiguous, #decompose, descriptor, dimension, #dimension, #dup, empty?, #empty?, #finalised?, float, float_scalar, floating, #force, #get, height, #height, indgen, #inspect, match, maxint, #memory, #pointer_type, pointer_type, rgb?, #rgb?, scalar, #shape, shape, #simplify, size, #size, #storage_size, strip, subst, #to_a, #to_s, to_s, to_type, #typecode, typecode, typecodes, variables, #width, width

Methods included from FLOAT_::Match

#align, #fit

Methods included from OBJECT::Match

#align, #fit

Methods included from COMPLEX_::Match

#align, #fit

Methods included from Sequence_::Match

#align, #fit

Methods included from BOOL::Match

#fit

Methods included from RGB_::Match

#align, #fit

Methods included from INT_::Match

#fit

Methods included from Operations

#+@, #<=>, #b=, #b_with_decompose, #collect, #conditional, #convolve, define_binary_op, define_unary_op, #diagonal, #eq_with_multiarray, #fill!, #g=, #g_with_decompose, #histogram, #imag=, #imag_with_decompose, #inject, #integral, #lut, #max, #min, #normalise, #product, #r=, #r_with_decompose, #range, #real=, #real_with_decompose, #roll, #sum, #to_type, #to_type_with_rgb, #transpose, #unroll

Constructor Details

#initialize(dest, source) ⇒ Histogram

Returns a new instance of Histogram.



29
30
31
# File 'lib/multiarray/histogram.rb', line 29

def initialize( dest, source )
  @dest, @source = dest, source
end

Class Method Details

.finalised?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/multiarray/histogram.rb', line 23

def finalised?
  false
end

Instance Method Details

#array_typeObject



37
38
39
# File 'lib/multiarray/histogram.rb', line 37

def array_type
  @dest.array_type
end

#compilable?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/multiarray/histogram.rb', line 75

def compilable?
  @dest.compilable? and @source.compilable?
end

#demandObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/multiarray/histogram.rb', line 41

def demand
  if variables.empty?
    if @source.dimension > 1
      @source.shape.last.times do |i|
        source = @source.element INT.new( i )
        Histogram.new( @dest, source ).demand
      end
    else
      dest = @dest
      ( @dest.dimension - 1 ).downto( 0 ) do |i|
        dest = dest.element @source.element( INT.new( i ) ).demand
      end
      dest.store dest + 1
    end
    @dest
  else
    super
  end
end

#descriptor(hash) ⇒ Object



33
34
35
# File 'lib/multiarray/histogram.rb', line 33

def descriptor( hash )
  "Histogram(#{@dest.descriptor( hash )},#{@source.descriptor( hash )})"
end

#stripObject



69
70
71
72
73
# File 'lib/multiarray/histogram.rb', line 69

def strip
  vars1, values1, term1 = @dest.strip
  vars2, values2, term2 = @source.strip
  return vars1 + vars2, values1 + values2, self.class.new( term1, term2 )
end

#subst(hash) ⇒ Object



61
62
63
# File 'lib/multiarray/histogram.rb', line 61

def subst( hash )
  self.class.new @dest.subst( hash ), @source.subst( hash )
end

#variablesObject



65
66
67
# File 'lib/multiarray/histogram.rb', line 65

def variables
  @dest.variables + @source.variables
end