Class: MDArray
- Inherits:
-
Object
- Object
- MDArray
- Defined in:
- lib/JRubyR/as_mdarray.rb,
lib/JRubyR/index.rb
Overview
Class Method Summary collapse
-
.build(type, shape, storage = nil, layout = :row) ⇒ Object
———————————————————————————— Builds a new MDArray ————————————————————————————.
-
.index_factory(shape) ⇒ Object
———————————————————————————— Creates new index with the given shape and column-major layout ————————————————————————————.
Instance Method Summary collapse
-
#pp ⇒ Object
—————————————————————————————-.
-
#z ⇒ Object
—————————————————————————————-.
Class Method Details
.build(type, shape, storage = nil, layout = :row) ⇒ Object
Builds a new MDArray
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/JRubyR/index.rb', line 53 def self.build(type, shape, storage = nil, layout = :row) if !@LAYOUT.include?(layout) raise "Unknown layout #{layout}" end if (shape.is_a? String) # building from csv # using shape as filename # using storage as flag for headers storage = (storage)? storage : false parameters = Csv.read_numeric(shape, storage) shape=[parameters[0], parameters[1]] storage = parameters[2] end if (storage) # nc_array = Java::UcarMa2.Array.factory(dtype, jshape, jstorage) nc_array = make_nc_array(type, shape, storage, layout) else nc_array = Java::UcarMa2.Array .factory(DataType.valueOf(type.upcase), shape.to_java(:int)) end klass = Object.const_get("#{type.capitalize}MDArray") return klass.new(type, nc_array) end |
.index_factory(shape) ⇒ Object
Creates new index with the given shape and column-major layout
86 87 88 89 90 91 92 93 94 |
# File 'lib/JRubyR/index.rb', line 86 def self.index_factory(shape) stride = comp_stride(shape) index = Java::UcarMa2.Index.factory(shape.to_java(:int)) index.stride = stride.to_java(:int) index.precalc index end |
Instance Method Details
#pp ⇒ Object
43 44 45 |
# File 'lib/JRubyR/as_mdarray.rb', line 43 def pp print end |
#z ⇒ Object
35 36 37 |
# File 'lib/JRubyR/as_mdarray.rb', line 35 def z self[0] end |