Class: NArray

Inherits:
Object
  • Object
show all
Defined in:
lib/gs2crmod/gsl_data_3d.rb,
lib/gs2crmod/gsl_tools.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

._load(buf) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/gs2crmod/gsl_data_3d.rb', line 6

def self._load buf
 h = Marshal.load buf
 typecode = h[:typecode]
 shape = h[:shape]
 data = h[:data]
 to_na data, typecode, *shape
end

Instance Method Details

#_dump(*ignored) ⇒ Object



3
4
5
# File 'lib/gs2crmod/gsl_data_3d.rb', line 3

def _dump *ignored
 Marshal.dump :typecode => typecode, :shape => shape, :data => to_s
end

#expand(*new_shape, empty_value) ⇒ Object



213
214
215
216
217
218
219
# File 'lib/gs2crmod/gsl_tools.rb', line 213

def expand(*new_shape, empty_value)
  na = NArray.new(self.typecode,*new_shape)
na[true] = empty_value 
  range = self.shape.map{|n| 0...n}
  na[*range] = self
  return na
end

#inspectObject



13
14
15
16
# File 'lib/gs2crmod/gsl_data_3d.rb', line 13

def inspect
 #ep "called inspect"
 "#{self.class}.to_narray(#{self.to_a.inspect})"
end