public float [ ] DM_UNPK ( DMPart part , int [ ] ibitst ) { int nparms = part . kparms ; int nwordp = part . kwordp ; int npack = ( ibitst . length - 1 ) / nwordp + 1 ; if ( npack * nwordp != ibitst . length ) { //logError("number of packed records not correct"); // System.out.println("number of packed records not correct: " // + npack * nwordp + " vs. " + ibitst.length); return null ; } float [ ] data = new float [ nparms * npack ] ; PackingInfo pkinf = part . packInfo ; int ir = 0 ; int ii = 0 ; for ( int pack = 0 ; pack < npack ; pack ++ ) { // // Move bitstring into internal words. TODO: necessary? // int [ ] jdata = new int [ nwordp ] ; System . arraycopy ( ibitst , ii , jdata , 0 , nwordp ) ; // // Extract each data value. // for ( int idata = 0 ; idata < nparms ; idata ++ ) { // // Extract correct bits from words using shift and mask // operations. // int jbit = pkinf . nbitsc [ idata ] ; int jsbit = pkinf . isbitc [ idata ] ; int jshift = 1 - jsbit ; int jsword = pkinf . iswrdc [ idata ] ; int jword = jdata [ jsword ] ; // use >>> to shift avoid carrying sign along int mask = mskpat >>> ( 32 - jbit ) ; int ifield = jword >>> Math . abs ( jshift ) ; ifield = ifield & mask ; if ( ( jsbit + jbit - 1 ) > 32 ) { jword = jdata [ jsword + 1 ] ; jshift = jshift + 32 ; int iword = jword << jshift ; iword = iword & mask ; ifield = ifield | iword ; } // // The integer data is now in ifield. Use the scaling and // offset terms to convert to REAL data. // if ( ifield == pkinf . imissc [ idata ] ) { data [ ir + idata ] = RMISSD ; } else { data [ ir + idata ] = ( ifield + pkinf . koffst [ idata ] ) * ( float ) pkinf . scalec [ idata ] ; } } ir += nparms ; ii += nwordp ; } return data ; }
Unpack an array of packed integers .