Mat5Writer { public Mat5Writer writeMat(MatFile matFile) throws IOException { if (matFile instanceof Mat5File) { return writeMat((Mat5File) matFile); } throw new IllegalArgumentException("MatFile does not support the MAT5 format"); } Mat5Writer(Sink sink); Mat5Writer setDeflateLevel(int deflateLevel); Mat5Writer enableConcurrentCompression(ExecutorService executorService); Mat5Writer enableConcurrentCompression(ExecutorService executorService, BufferAllocator bufferAllocator); Mat5Writer writeMat(MatFile matFile); Mat5Writer writeEntry(MatFile.Entry entry); Mat5Writer writeArray(final String name, final Array value); Mat5Writer writeArray(final String name, final boolean isGlobal, final Array array); Mat5Writer flush();  }
@Test public void computeSerializedSizeOfComplexMatFile() throws Exception { MatFile matFile = MatTestUtil.readMat("arrays/cell.mat"); long calculatedSize = matFile.getUncompressedSerializedSize(); rawWriter.writeMat(matFile); long actualSize = buffer.position(); Assert.assertEquals("Uncompressed File", calculatedSize, actualSize); }
@Test public void readWriteDoubleNDim() throws Exception { MatFile input = MatTestUtil.readMat("arrays/multiDimMatrix.mat"); compressedWriter.writeMat(input); buffer.flip(); MatFile output = Mat5.newReader(Sources.wrap(buffer)).readMat(); Matrix expected = input.getArray("in"); Matrix actual = output.getArray("in"); Assert.assertEquals(expected.getType(), actual.getType()); Assert.assertArrayEquals(expected.getDimensions(), actual.getDimensions()); int numElements = expected.getNumElements(); for (int i = 0; i < numElements; i++) { Assert.assertEquals(expected.getDouble(i), actual.getDouble(i), 0); } }