public String contentToString() { StringBuffer sb = new StringBuffer(); sb.append(name + " = \n"); for (int m = 0; m < getM(); m++) { sb.append("\t"); for (int n = 0; n < getN(); n++) { sb.append(get(m, n)); sb.append("\t"); } sb.append("\n"); } return sb.toString(); }
public static String[] readStringsArrayFromMat(Path matFile, String stringsArrayName) throws IOException { Objects.requireNonNull(matFile, "mat file is null"); Objects.requireNonNull(stringsArrayName, "strings array name is null"); MatFileReader matFileReader = new MatFileReader(); Map<String, MLArray> matFileContent = matFileReader.read(matFile.toFile()); MLCell stringsArray = (MLCell) matFileContent.get(stringsArrayName); String[] strings = new String[stringsArray.getN()]; for (int i = 0; i < stringsArray.getN(); i++) { strings[i] = ((MLChar) stringsArray.get(0, i)).getString(0); } return strings; }
public static void main(String[] args) throws IOException { // MLCell cell = new MLCell("data", new int[]{100000,1}); // Random r = new Random(); // for (int i = 0; i < 100000; i++) { // MLCell inner = new MLCell(null, new int[]{2,1}); // inner.set(new MLChar(null,"Dummy String" + r.nextDouble()), 0, 0); // MLDouble d = new MLDouble(null, new double[][]{new // double[]{r.nextDouble()}}); // inner.set(d, 1, 0); // cell.set(inner, i,0); // } // ArrayList<MLArray> arr = new ArrayList<MLArray>(); // arr.add(cell); // new MatFileWriter( "mat_file.mat", arr); final MatFileReader reader = new MatFileReader("/Users/ss/Development/python/storm-spams/XYs.mat"); final Map<String, MLArray> content = reader.getContent(); final MLCell cell = (MLCell) content.get("XYs"); System.out.println(cell.get(0, 0)); System.out.println(cell.get(0, 1)); } }
Map<String, MLArray> mcosContent = matFile.getContent(); MLCell mcosInfo = (MLCell) ((MLStructure) mcosContent.get("@0")).getField("MCOS"); ByteBuffer mcosDataBuf = ((MLUInt8) mcosInfo.get(0)).getRealByteBuffer(); break; case 1: property = mcosInfo.get(heapIndex + 2); break; case 2: MLCell attribBag = (MLCell) mcosInfo.get(mcosInfo.getSize() - 1); // Get the grab bag. for (MatMCOSObjectInformation it : objectInfoList.values()) { MLStructure attributes = (MLStructure) attribBag.get(it.classId); Collection<String> attributeNames = attributes.getFieldNames(); Map<String, MLArray> objAttributes = it.structure;
public String contentToString() { StringBuffer sb = new StringBuffer(); sb.append(name + " = \n"); for (int m = 0; m < getM(); m++) { sb.append("\t"); for (int n = 0; n < getN(); n++) { sb.append(get(m, n)); sb.append("\t"); } sb.append("\n"); } return sb.toString(); }
public static void main(String[] args) throws IOException { // MLCell cell = new MLCell("data", new int[]{100000,1}); // Random r = new Random(); // for (int i = 0; i < 100000; i++) { // MLCell inner = new MLCell(null, new int[]{2,1}); // inner.set(new MLChar(null,"Dummy String" + r.nextDouble()), 0, 0); // MLDouble d = new MLDouble(null, new double[][]{new // double[]{r.nextDouble()}}); // inner.set(d, 1, 0); // cell.set(inner, i,0); // } // ArrayList<MLArray> arr = new ArrayList<MLArray>(); // arr.add(cell); // new MatFileWriter( "mat_file.mat", arr); final MatFileReader reader = new MatFileReader("/Users/ss/Development/python/storm-spams/XYs.mat"); final Map<String, MLArray> content = reader.getContent(); final MLCell cell = (MLCell) content.get("XYs"); System.out.println(cell.get(0, 0)); System.out.println(cell.get(0, 1)); } }
private void prepareFolds() { final MLArray setfolds = this.content.get("set_fold"); if(setfolds==null) return; if (setfolds.isCell()) { this.folds = new ArrayList<Fold>(); final MLCell foldcells = (MLCell) setfolds; final int nfolds = foldcells.getM(); System.out.println(String.format("Found %d folds", nfolds)); for (int i = 0; i < nfolds; i++) { final MLDouble training = (MLDouble) foldcells.get(i, 0); final MLDouble test = (MLDouble) foldcells.get(i, 1); final MLDouble validation = (MLDouble) foldcells.get(i, 2); final Fold f = new Fold(toIntArray(training), toIntArray(test), toIntArray(validation)); folds.add(f); } } else { throw new RuntimeException( "Can't find set_folds in expected format"); } }
public String contentToString() { StringBuffer sb = new StringBuffer(); sb.append(name + " = \n"); for ( int m = 0; m < getM(); m++ ) { sb.append("\t"); for ( int n = 0; n < getN(); n++ ) { sb.append( get(m,n) ); sb.append("\t"); } sb.append("\n"); } return sb.toString(); }
public String contentToString() { StringBuffer sb = new StringBuffer(); sb.append(name + " = \n"); for ( int m = 0; m < getM(); m++ ) { sb.append("\t"); for ( int n = 0; n < getN(); n++ ) { sb.append( get(m,n) ); sb.append("\t"); } sb.append("\n"); } return sb.toString(); }
public String contentToString() { StringBuffer sb = new StringBuffer(); sb.append(name + " = \n"); for ( int m = 0; m < getM(); m++ ) { sb.append("\t"); for ( int n = 0; n < getN(); n++ ) { sb.append( get(m,n) ); sb.append("\t"); } sb.append("\n"); } return sb.toString(); }