public SampledData getSampledData() { // get generators active power MLDouble pGen = (MLDouble) matFileContent.get("PGEN"); double[][] generatorsActivePower = null; if (pGen != null) { generatorsActivePower = pGen.getArray(); } // get loads active power MLDouble pLoad = (MLDouble) matFileContent.get("PLOAD"); double[][] loadsActivePower = null; if (pLoad != null) { loadsActivePower = pLoad.getArray(); } // get loads reactive power MLDouble qLoad = (MLDouble) matFileContent.get("QLOAD"); double[][] loadsReactivePower = null; if (qLoad != null) { loadsReactivePower = qLoad.getArray(); } SampledData sampledData = new SampledData(generatorsActivePower, loadsActivePower, loadsReactivePower); return sampledData; }
public static double[][] readDoublesMatrixFromMat(Path matFile, String doublesMatrixName) throws IOException { Objects.requireNonNull(matFile, "mat file is null"); MatFileReader matFileReader = new MatFileReader(); Map<String, MLArray> matFileContent = matFileReader.read(matFile.toFile()); MLDouble doublesMatrix = (MLDouble) matFileContent.get(doublesMatrixName); double[][] doubles = null; if (doublesMatrix != null) { doubles = doublesMatrix.getArray(); } return doubles; }
final double[] filterIndexArr = keepIndex.getArray()[0];
private void parseAnnotations(FileObject annotationFile) throws IOException { if (!annotationFile.exists()) { return; } final MatFileReader reader = new MatFileReader(annotationFile.getContent().getInputStream()); final MLDouble boxes = (MLDouble) reader.getMLArray("box_coord"); this.bounds = new Rectangle( (float) (double) boxes.getReal(2) - 1, (float) (double) boxes.getReal(0) - 1, (float) (boxes.getReal(3) - boxes.getReal(2)) - 1, (float) (boxes.getReal(1) - boxes.getReal(0)) - 1); final double[][] contourData = ((MLDouble) reader.getMLArray("obj_contour")).getArray(); this.contour = new Polygon(); for (int i = 0; i < contourData[0].length; i++) { contour.points.add( new Point2dImpl((float) contourData[0][i] + bounds.x - 1, (float) contourData[1][i] + bounds.y - 1) ); } contour.close(); }
private void parseAnnotations(FileObject annotationFile) throws IOException { if (!annotationFile.exists()) { return; } final MatFileReader reader = new MatFileReader(annotationFile.getContent().getInputStream()); final MLDouble boxes = (MLDouble) reader.getMLArray("box_coord"); this.bounds = new Rectangle( (float) (double) boxes.getReal(2) - 1, (float) (double) boxes.getReal(0) - 1, (float) (boxes.getReal(3) - boxes.getReal(2)) - 1, (float) (boxes.getReal(1) - boxes.getReal(0)) - 1); final double[][] contourData = ((MLDouble) reader.getMLArray("obj_contour")).getArray(); this.contour = new Polygon(); for (int i = 0; i < contourData[0].length; i++) { contour.points.add( new Point2dImpl((float) contourData[0][i] + bounds.x - 1, (float) contourData[1][i] + bounds.y - 1) ); } contour.close(); }
boolean result = Arrays.equals(src2D[i], ((MLDouble) mlArrayRetrived).getArray()[i]); assertEquals("2D array match", true, result);