Class: OMX::OMXData
- Inherits:
-
Object
- Object
- OMX::OMXData
- Extended by:
- FFI::Library
- Defined in:
- lib/OpenMatriX.rb
Overview
Class to read the data from the OMX file
Defined Under Namespace
Classes: InvalidFile
Instance Method Summary collapse
- #getI(zone) ⇒ Object
- #getIJ(i, j) ⇒ Object
- #getJ(j) ⇒ Object
-
#initialize(file, table, zones) ⇒ OMXData
constructor
A new instance of OMXData.
Constructor Details
#initialize(file, table, zones) ⇒ OMXData
Returns a new instance of OMXData.
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
# File 'lib/OpenMatriX.rb', line 320 def initialize(file, table, zones) @id = file.id @gId = OMXTables::gOpen(@id,"data",0) @zones = zones b = basic_open(@gId,table) filespace = h5dspace(b) rank = h5sN(filespace) dims = FFI::MemoryPointer.new(H5Types.hsize_t) maxdims = FFI::MemoryPointer.new(H5Types.hsize_t) status_n = h5sD(filespace,dims,maxdims) cparms = h5dpl(b) if h5pLayout(cparms) chunk_dims = FFI::MemoryPointer.new(H5Types.hsize_t) rank_chunk = h5pGetChunk(cparms, maxdims.read_int(), chunk_dims) end memspace = h5sCreate(2, dims, nil) type = h5dtype(b) buffer = FFI::MemoryPointer.new(type,2) c = h5dRead(b, type, memspace, filespace, 0, buffer) ask_zones = zones * zones @outAry = buffer.get_array_of_double(0,ask_zones) end |
Instance Method Details
#getI(zone) ⇒ Object
343 344 345 |
# File 'lib/OpenMatriX.rb', line 343 def getI(zone) return(@outAry[(zone-1)*@zones,@zones]) end |
#getIJ(i, j) ⇒ Object
347 348 349 350 |
# File 'lib/OpenMatriX.rb', line 347 def getIJ(i,j) a = @outAry[(i-1)*@zones,@zones] return(a[j-1]) end |
#getJ(j) ⇒ Object
352 353 354 355 356 357 358 359 |
# File 'lib/OpenMatriX.rb', line 352 def getJ(j) out ||= [] for i in 0..@zones-1 x = @outAry[i*@zones,j] out << x[j-1] end return(out) end |