Exemple #1
0
 @Test
 public void testSizes() {
   MXArray a = createDoubleMatrix(123, 456);
   assertEquals(8L, MXLibrary.INSTANCE.mxGetElementSize(a).longValue());
   assertEquals(123L, MXLibrary.INSTANCE.mxGetM(a).longValue());
   assertEquals(456L, MXLibrary.INSTANCE.mxGetN(a).longValue());
   assertEquals(2L, MXLibrary.INSTANCE.mxGetNumberOfDimensions(a).longValue());
   assertEquals(123L * 456L, MXLibrary.INSTANCE.mxGetNumberOfElements(a).longValue());
   Pointer dims = MXLibrary.INSTANCE.mxGetDimensions(a);
   assertEquals(123L, dims.getNativeLong(0).longValue());
   assertEquals(456L, dims.getNativeLong(NativeLong.SIZE).longValue());
   NativeLong[] subs = null;
   NativeLong singleSub = null;
   // check single subscript of first element
   subs = toNativeLongs(0, 0);
   singleSub = MXLibrary.INSTANCE.mxCalcSingleSubscript(a, new NativeLong(subs.length), subs);
   assertEquals(0L, singleSub.longValue());
   // check single subscript of second element (MATLAB always uses
   // column-major order)
   subs = toNativeLongs(1, 0);
   singleSub = MXLibrary.INSTANCE.mxCalcSingleSubscript(a, new NativeLong(subs.length), subs);
   assertEquals(1L, singleSub.longValue());
   // check single subscript of first element in second row
   subs = toNativeLongs(0, 1);
   singleSub = MXLibrary.INSTANCE.mxCalcSingleSubscript(a, new NativeLong(subs.length), subs);
   assertEquals(123L, singleSub.longValue());
   // check single subscript of last element
   subs = toNativeLongs(122, 455);
   singleSub = MXLibrary.INSTANCE.mxCalcSingleSubscript(a, new NativeLong(subs.length), subs);
   assertEquals(123L * 456L - 1, singleSub.longValue());
   destroy(a);
 }
 public final long getNativeLong(long offset) {
   checkBounds(offset, Platform.getPlatform().longSize() >> 3);
   return ptr.getNativeLong(offset).longValue();
 }