xhtml.newline(); for (Map.Entry<String, MLArray> entry : mfr.getContent().entrySet()) { String varName = entry.getKey(); MLArray varData = entry.getValue();
public MatlabFileDataGenerator(File matfile) throws IOException { MatFileReader reader = new MatFileReader(matfile); Map<String, MLArray> content = reader.getContent(); this.data= (MLCell) content.get("XYs"); this.index = 0; }
/** * @param matfile the file from which to read * @throws IOException */ public MatlabFileInitStrat(File matfile) throws IOException { MatFileReader reader = new MatFileReader(matfile); Map<String, MLArray> content = reader.getContent(); this.data= CFMatrixUtils.asMat(content.get("arr")); }
/** Reads a full set of bytes (including the header). */ public static MatFile readFull(ByteBuffer buf, MatFileType type) throws IOException { MatFileReader reader = new MatFileReader(type); reader.readHeader(buf); while (buf.remaining() > 0) { reader.readData(buf); } return new MatFile(reader.getMatFileHeader(), reader.getContent()); }
/** Reads a full set of bytes (including the header). */ public static MatFile readFull(ByteBuffer buf, MatFileType type) throws IOException { MatFileReader reader = new MatFileReader(type); reader.readHeader(buf); while (buf.remaining() > 0) { reader.readData(buf); } return new MatFile(reader.getMatFileHeader(), reader.getContent()); }
private static LargeMarginDimensionalityReduction loadMatlabLMDR() throws IOException { final LargeMarginDimensionalityReduction lmdr = new LargeMarginDimensionalityReduction(128); final MatFileReader reader = new MatFileReader(new File("/Users/jon/lmdr.mat")); final MLSingle W = (MLSingle) reader.getContent().get("W"); final MLSingle b = (MLSingle) reader.getContent().get("b"); lmdr.setBias(b.get(0, 0)); final Matrix proj = new Matrix(W.getM(), W.getN()); for (int j = 0; j < W.getN(); j++) { for (int i = 0; i < W.getM(); i++) { proj.set(i, j, W.get(i, j)); } } lmdr.setTransform(proj); return lmdr; }
private static LargeMarginDimensionalityReduction loadMatlabLMDR() throws IOException { final LargeMarginDimensionalityReduction lmdr = new LargeMarginDimensionalityReduction(128); final MatFileReader reader = new MatFileReader(new File("/Users/jon/lmdr.mat")); final MLSingle W = (MLSingle) reader.getContent().get("W"); final MLSingle b = (MLSingle) reader.getContent().get("b"); lmdr.setBias(b.get(0, 0)); final Matrix proj = new Matrix(W.getM(), W.getN()); for (int j = 0; j < W.getN(); j++) { for (int i = 0; i < W.getM(); i++) { proj.set(i, j, W.get(i, j)); } } lmdr.setTransform(proj); return lmdr; }
public static PrincipalComponentAnalysis loadPCA(File f) throws IOException { final MatFileReader reader = new MatFileReader(f); final MLSingle mean = (MLSingle) reader.getContent().get("mu"); final MLSingle eigvec = (MLSingle) reader.getContent().get("proj"); final Matrix basis = new Matrix(eigvec.getM(), eigvec.getN()); final double[] meand = new double[eigvec.getN()]; for (int j = 0; j < eigvec.getN(); j++) { // meand[i] = mean.get(i,0); ignore the means meand[j] = 0; for (int i = 0; i < eigvec.getM(); i++) { basis.set(i, j, eigvec.get(i, j)); } } final PrincipalComponentAnalysis ret = new LoadedPCA(basis.transpose(), meand); return ret; }
private static MemoryLocalFeatureList<FloatDSIFTKeypoint> loadDSIFTPCA(String faceFile) throws IOException { final File f = new File(faceFile); final MatFileReader reader = new MatFileReader(f); final MLSingle feats = (MLSingle) reader.getContent().get("feats"); final int nfeats = feats.getN(); final MemoryLocalFeatureList<FloatDSIFTKeypoint> ret = new MemoryLocalFeatureList<FloatDSIFTKeypoint>(); for (int i = 0; i < nfeats; i++) { final FloatDSIFTKeypoint feature = new FloatDSIFTKeypoint(); feature.descriptor = new float[feats.getM()]; for (int j = 0; j < feature.descriptor.length; j++) { feature.descriptor[j] = feats.get(j, i); } ret.add(feature); } return ret; }
public static PrincipalComponentAnalysis loadPCA(File f) throws IOException { final MatFileReader reader = new MatFileReader(f); final MLSingle mean = (MLSingle) reader.getContent().get("mu"); final MLSingle eigvec = (MLSingle) reader.getContent().get("proj"); final Matrix basis = new Matrix(eigvec.getM(), eigvec.getN()); final double[] meand = new double[eigvec.getN()]; for (int j = 0; j < eigvec.getN(); j++) { // meand[i] = mean.get(i,0); ignore the means meand[j] = 0; for (int i = 0; i < eigvec.getM(); i++) { basis.set(i, j, eigvec.get(i, j)); } } final PrincipalComponentAnalysis ret = new LoadedPCA(basis.transpose(), meand); return ret; }
private static MemoryLocalFeatureList<FloatDSIFTKeypoint> loadDSIFTPCA(String faceFile) throws IOException { final File f = new File(faceFile); final MatFileReader reader = new MatFileReader(f); final MLSingle feats = (MLSingle) reader.getContent().get("feats"); final int nfeats = feats.getN(); final MemoryLocalFeatureList<FloatDSIFTKeypoint> ret = new MemoryLocalFeatureList<FloatDSIFTKeypoint>(); for (int i = 0; i < nfeats; i++) { final FloatDSIFTKeypoint feature = new FloatDSIFTKeypoint(); feature.descriptor = new float[feats.getM()]; for (int j = 0; j < feature.descriptor.length; j++) { feature.descriptor[j] = feats.get(j, i); } ret.add(feature); } return ret; }
/** Reads a full set of bytes (including the header). */ public static MatFile readFull(RandomAccessFile file) throws IOException { MatFileReader reader = new MatFileReader(); reader.read(file, new MatFileFilter(), MatFileReader.HEAP_BYTE_BUFFER); return new MatFile(reader.getMatFileHeader(), reader.getContent()); } }
/** Reads a full set of bytes (including the header). */ public static MatFile readFull(RandomAccessFile file) throws IOException { MatFileReader reader = new MatFileReader(); reader.read(file, new MatFileFilter(), MatFileReader.HEAP_BYTE_BUFFER); return new MatFile(reader.getMatFileHeader(), reader.getContent()); } }
private static LargeMarginDimensionalityReduction loadMatlabPCAW() throws IOException { final LargeMarginDimensionalityReduction lmdr = new LargeMarginDimensionalityReduction(128); final MatFileReader reader = new MatFileReader(new File("/Users/jon/pcaw.mat")); final MLSingle W = (MLSingle) reader.getContent().get("proj"); lmdr.setBias(169.6264190673828); final Matrix proj = new Matrix(W.getM(), W.getN()); for (int j = 0; j < W.getN(); j++) { for (int i = 0; i < W.getM(); i++) { proj.set(i, j, W.get(i, j)); } } lmdr.setTransform(proj); return lmdr; } }
@Test public void testParsingSimpleEmptyMCOS() throws IOException { File file = fileFromStream("/mcos/simpleempty.mat"); MatFileReader reader = new MatFileReader(file); Map<String, MLArray> content = reader.getContent(); assertThat(content.size(), equalTo(1)); MLObject obj = (MLObject) content.get("obj"); assertThat(obj, notNullValue()); assertThat(obj.getName(), equalTo("obj")); assertThat(obj.getClassName(), equalTo("SimpleEmpty")); assertThat(obj.getFieldNames().size(), equalTo(0)); }
@Test public void testParsingSimpleSingleTextUnmodifiedMCOS() throws IOException { File file = fileFromStream("/mcos/simplesingletext_unmodified.mat"); MatFileReader reader = new MatFileReader(file); Map<String, MLArray> content = reader.getContent(); assertThat(content.size(), equalTo(1)); MLObject obj = (MLObject) content.get("obj"); assertThat(obj, notNullValue()); assertThat(obj.getName(), equalTo("obj")); assertThat(obj.getClassName(), equalTo("SimpleSingleText")); Map<String, MLArray> fields = obj.getFields(0); assertThat(fields.size(), equalTo(1)); MLChar field = (MLChar) fields.get("test_text"); assertThat(field.getString(0), equalTo("Default text")); }
@Test public void testParsingTETInSimulinkEncoding() throws IOException { String input = " %)30 . > 8 ( $0 ! $ ! !-0T]3 0 $ $1A=&$. 2 8 ( #0 % \" 8 ! 0 & & -T\" 0 $ ! !0 X \"H/@ !@ @ ) 4 ( 0 '@^ ! ( !X/@ %)30 . V#T 8 ( @ % \" $ ! 0 % 0 !0 $ % 34-/4P . D#T 8 ( $0 ! $ ! !-0T]3 0 T !&:6QE5W)A<'!E<E]? #@ % ] & \" $ !0 @ !X 0 $ #@ +@+ & \" D !0 @ \"(\"P 0 $ @ (@+ \" + -@! X @ . ( ) $ # \"@ B L 1W)I9# 0V5L;', 0V5L;#$ 8V]N9%]T97AT &-E;&Q?:6YD97@ <&%R96YT7V=R:60 8V5L;', 1W)I9 !P87)E;G1?8V5L; !S<&QI=%]P8@!N=6U?8V5L;', 9W)I9%]I;F1E> !R1W)I9 !N97=?8V5L;%]P8@!D96QE=&5?8V5L;%]P8@!P8E]F;&%G $-E;&P <W5B9W)I9 !C;VYD '=I9'1H &AE:6=H= !G<FED7W!B &-O;&]R &-O;F1I=&EO;E]T97AT7W=I9'1H &-O;F1I=&EO;E]T97AT7VAE:6=H= !C;VYD:71I;VY?=&5X=%]X &-O;F1I=&EO;E]T97AT7WD 8V]N9&ET:6]N7W1E>'1?;V9F<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 4 ( ! D #@ # & \" 8 !0 @ $ \"0 . , 8 ( !@ % \" 0 ) X P !@ @ & 4 ( ! D #@ # & \" 8 !0 @ $ \"0 . B 8 ( \"0 % \" $ !8 0 \" 6 !24T #@ $@ & \" ( !0 @ ! 0 $ !0 $ 4 ! !0 $U#3U, #@ "; InputStream decoder = new SimulinkDecoder(input); MatFileReader reader = new MatFileReader(decoder, new MatFileFilter(), MatFileType.ReducedHeader); MLObject data = (MLObject) reader.getContent().get("@"); // Just check that the root element is basically correct. assertThat(data, notNullValue()); assertThat(data.getClassName(), equalTo("Data")); assertThat(data.getSize(), equalTo(1)); }
@Test public void testMultipleMCOSInArray() throws IOException { File file = fileFromStream("/mcos/simplesingletext_multiplearray.mat"); MatFileReader reader = new MatFileReader(file); Map<String, MLArray> content = reader.getContent(); assertThat(content.size(), equalTo(1)); MLObject obj = (MLObject) content.get("a"); assertThat(obj, notNullValue()); assertThat(obj.getName(), equalTo("a")); assertThat(obj.getClassName(), equalTo("SimpleSingleText")); assertThat(((MLDouble) obj.getFields(0).get("test_text")).get(0), equalTo(1.0)); assertThat(((MLDouble) obj.getFields(1).get("test_text")).get(0), equalTo(2.0)); assertThat(((MLDouble) obj.getFields(2).get("test_text")).get(0), equalTo(3.0)); assertThat(((MLDouble) obj.getFields(3).get("test_text")).get(0), equalTo(4.0)); }
@Test public void testMultipleEmptyNames() throws IOException { File f = getTestFile("emptyname.mat"); MatFileReader r = new MatFileReader(f); Map<String, MLArray> content = r.getContent(); // There are 3 elements in that file, should have 4 in the array (the first value under @, and the three values under @*) assertEquals(4, content.size()); // Check the three values came through alright. Order is fixed as they are read in in file order. Also check @. assertEquals(1.0, ((MLDouble) content.get("@")).get(0), .0001); assertEquals(1.0, ((MLDouble) content.get("@0")).get(0), .0001); assertEquals(2.0, ((MLDouble) content.get("@1")).get(0), .0001); assertEquals(3.0, ((MLDouble) content.get("@2")).get(0), .0001); }
@Test public void testUTF() throws IOException { // read array form file MatFileReader mfr = new MatFileReader(getTestFile("utf.mat")); Map<String, MLArray> map = mfr.getContent(); MLStructure val = (MLStructure) map.get("val"); // extract each utf MLChar utf8 = (MLChar) val.getField("utf8"); MLChar utf16 = (MLChar) val.getField("utf16"); MLChar utf32 = (MLChar) val.getField("utf32"); // assert the content String expected = "\uD841\uDF0E"; Assert.assertEquals(expected, utf8.getString(0)); Assert.assertEquals(expected, utf16.getString(0)); Assert.assertEquals(expected, utf32.getString(0)); }