Class: Hornetseye::Lut

Inherits:
Node show all
Defined in:
lib/multiarray/lut.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, 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, #histogram_with_composite, #imag=, #imag_with_decompose, #inject, #integral, #lut, #lut_with_composite, #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(source, table, n) ⇒ Lut

Returns a new instance of Lut.



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

def initialize( source, table, n )
  @source, @table = source, table
  @n = n || @source.shape.first
end

Class Method Details

.finalised?Boolean

Returns:

  • (Boolean)


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

def finalised?
  false
end

Instance Method Details

#array_typeObject



38
39
40
41
# File 'lib/multiarray/lut.rb', line 38

def array_type
  shape = @table.shape.first( @table.dimension - @n ) + @source.shape[ 1 .. -1 ]
  Hornetseye::MultiArray @table.typecode, *shape
end

#compilable?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/multiarray/lut.rb', line 95

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

#decomposeObject



91
92
93
# File 'lib/multiarray/lut.rb', line 91

def decompose
  self.class.new @source, @table.decompose, @n
end

#demandObject



43
44
45
# File 'lib/multiarray/lut.rb', line 43

def demand
  @source.lut @table, :n => @n, :safe => false
end

#descriptor(hash) ⇒ Object



34
35
36
# File 'lib/multiarray/lut.rb', line 34

def descriptor( hash )
  "Lut(#{@source.descriptor( hash )},#{@table.descriptor( hash )},#{@n})"
end

#element(i) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/multiarray/lut.rb', line 65

def element( i )
  source, table = @source, @table
  if source.dimension > 1
    source = source.element i
    self.class.new source, table, @n
  elsif table.dimension > @n
    self.class.new source, table.unroll( @n ).element( i ).roll( @n ), @n
  else
    super i
  end
end

#skip(index, start) ⇒ Object



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

def skip( index, start )
  self.class.new @source.skip( index, start ), @table.skip( index, start ), @n
end

#slice(start, length) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/multiarray/lut.rb', line 77

def slice( start, length )
  source, table = @source, @table
  if source.dimension > 1
    source = source.slice( start, length ).roll
    self.class.new( source, table, @n ).unroll
  elsif table.dimension > @n
    self.class.new( source,
                    table.unroll( @n ).slice( start, length ).roll( @n + 1 ),
                    @n ).unroll
  else
    super i
  end
end

#stripObject



55
56
57
58
59
# File 'lib/multiarray/lut.rb', line 55

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

#subst(hash) ⇒ Object



47
48
49
# File 'lib/multiarray/lut.rb', line 47

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

#variablesObject



51
52
53
# File 'lib/multiarray/lut.rb', line 51

def variables
  @source.variables + @table.variables
end