Class: Hornetseye::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/hornetseye-narray/node.rb

Instance Method Summary collapse

Instance Method Details

#to_narrayObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/hornetseye-narray/node.rb', line 20

def to_narray
  case typecode
  when UBYTE
    target = NArray::BYTE
  when SINT
    target = NArray::SINT
  when INT
    target = NArray::INT
  when SFLOAT
    target = NArray::SFLOAT
  when DFLOAT
    target = NArray::DFLOAT
  when SCOMPLEX
    target = NArray::SCOMPLEX
  when DCOMPLEX
    target = NArray::DCOMPLEX
  else
    target = NArray::OBJECT
  end
  if target == NArray::OBJECT
    NArray.to_na to_a
  else
    data = memorise.memory
    NArray.to_na memorise.memory.export, target, *shape
  end
end