/** * Writes MLArrays into <code>OuputSteram</code>. * * Writes MAT-file header and compressed data (<code>miCOMPRESSED</code>). * * @param output - <code>OutputStream</code> * @param data - <code>Collection</code> of <code>MLArray</code> elements * @throws IOException */ public MatFileWriter(WritableByteChannel channel, Collection<MLArray> data) throws IOException { write(channel, data); }
/** * Writes MLArrays into <code>OuputSteram</code>. * * Writes MAT-file header and compressed data (<code>miCOMPRESSED</code>). * * @param channel channel * @param data - <code>Collection</code> of <code>MLArray</code> elements * @throws IOException on underlying IOExceptions */ public MatFileWriter(WritableByteChannel channel, Collection<MLArray> data) throws IOException { write(channel, data); }
/** * Writes MLArrays into <code>OuputSteram</code>. * * Writes MAT-file header and compressed data (<code>miCOMPRESSED</code>). * * @param output - <code>OutputStream</code> * @param data - <code>Collection</code> of <code>MLArray</code> elements * @throws IOException */ public MatFileWriter(WritableByteChannel channel, Collection<MLArray> data) throws IOException { write(channel, data); }
/** * Writes MLArrays into <code>OuputSteram</code>. * * Writes MAT-file header and compressed data (<code>miCOMPRESSED</code>). * * @param output - <code>OutputStream</code> * @param data - <code>Collection</code> of <code>MLArray</code> elements * @throws IOException */ public MatFileWriter(WritableByteChannel channel, Collection<MLArray> data) throws IOException { write(channel, data); }
/** * Writes MLArrays into <code>OuputSteram</code>. * * Writes MAT-file header and compressed data (<code>miCOMPRESSED</code>). * * @param output - <code>OutputStream</code> * @param data - <code>Collection</code> of <code>MLArray</code> elements * @throws IOException */ public MatFileWriter(WritableByteChannel channel, Collection<MLArray> data) throws IOException { write(channel, data); }
/** * Writes <code>MLArrays</code> into file created from * <code>filepath</code>. * * @param filepath the absolute file path of a MAT-file to which data is written * @param data the collection of <code>{@link MLArray}</code> objects * @throws IOException if error occurred during MAT-file writing */ public synchronized void write(String filepath, Collection<MLArray> data) throws IOException { write(new File(filepath), data); }
/** * Writes <code>MLArrays</code> into file created from * <code>filepath</code>. * * @param filepath * the absolute file path of a MAT-file to which data is written * @param data * the collection of <code>{@link MLArray}</code> objects * @throws IOException * if error occurred during MAT-file writing */ public synchronized void write(String filepath, Collection<MLArray> data) throws IOException { write(new File(filepath), data); }
/** * Writes <code>MLArrays</code> into file created from * <code>filepath</code>. * * @param filepath * the absolute file path of a MAT-file to which data is written * @param data * the collection of <code>{@link MLArray}</code> objects * @throws IOException * if error occurred during MAT-file writing */ public synchronized void write(String filepath, Collection<MLArray> data) throws IOException { write(new File(filepath), data); }
/** * Writes <code>MLArrays</code> into file created from * <code>filepath</code>. * * @param filepath * the absolute file path of a MAT-file to which data is written * @param data * the collection of <code>{@link MLArray}</code> objects * @throws IOException * if error occurred during MAT-file writing */ public synchronized void write(String filepath, Collection<MLArray> data) throws IOException { write(new File(filepath), data); }
/** * Writes <code>MLArrays</code> into file created from * <code>filepath</code>. * * @param filepath * the absolute file path of a MAT-file to which data is written * @param data * the collection of <code>{@link MLArray}</code> objects * @throws IOException * if error occurred during MAT-file writing */ public synchronized void write(String filepath, Collection<MLArray> data) throws IOException { write(new File(filepath), data); }
/** * Writes <code>MLArrays</code> into <code>File</code> * * @param file * the MAT-file to which data is written * @param data * the collection of <code>{@link MLArray}</code> objects * @throws IOException * if error occurred during MAT-file writing */ public synchronized void write(File file, Collection<MLArray> data) throws IOException { FileOutputStream fos = new FileOutputStream(file); try { write(fos.getChannel(), data); } catch (IOException e) { throw e; } finally { fos.close(); } }
/** * Writes <code>MLArrays</code> into <code>File</code> * * @param file * the MAT-file to which data is written * @param data * the collection of <code>{@link MLArray}</code> objects * @throws IOException * if error occurred during MAT-file writing */ public synchronized void write(File file, Collection<MLArray> data) throws IOException { FileOutputStream fos = new FileOutputStream(file); try { write(fos.getChannel(), data); } catch (IOException e) { throw e; } finally { fos.close(); } }
/** * Writes <code>MLArrays</code> into <code>File</code> * * @param file the MAT-file to which data is written * @param data the collection of <code>{@link MLArray}</code> objects * @throws IOException if error occurred during MAT-file writing */ public synchronized void write(File file, Collection<MLArray> data) throws IOException { FileOutputStream fos = new FileOutputStream(file); try { write(fos.getChannel(), data); } catch ( IOException e ) { throw e; } finally { fos.close(); } }
public static void writeWp41ContModule1Mat(Path outputfile, double[][] matrix) throws IOException { LOGGER.debug("writeWp41ContModule1Mat - writing wp41 input X matrix data to file {}", outputfile); MLDouble data = Utils.matToMLDouble(matrix, "X"); List<MLArray> mlarray = new ArrayList<>(); mlarray.add((MLArray) data); MatFileWriter writer = new MatFileWriter(); writer.write(outputfile.toFile(), mlarray); LOGGER.debug("writeWp41ContModule1Mat - X matrix data, written."); }
public static void writeWP41BinaryIndependentSamplingInputFile(Path outputfile, double[] marginalExpectations) throws IOException { MLDouble data = Utils.vectToMLDoubleRow(marginalExpectations, "p"); List<MLArray> mlarray = new ArrayList<>(); mlarray.add((MLArray) data); MatFileWriter writer = new MatFileWriter(); writer.write(outputfile.toFile(), mlarray); }
public static void toFile(File file, Matrix matrix, Object... parameters) throws IOException { MatFileWriter writer = new MatFileWriter(); Collection<MLArray> matrixList = new ArrayList<MLArray>(); matrixList.add(new MLDenseDoubleMatrix(matrix).getWrappedObject()); writer.write(file, matrixList); }
public static void writeWP41ContinuousInputMatFile(Path outputfile, double[][] idata, int nsamples, double ir, double k) throws IOException { MLDouble dNsample = new MLDouble("N_Sample", new double[]{nsamples}, 1); MLDouble dIR = new MLDouble("IR", new double[]{ir}, 1); MLDouble dK = new MLDouble("K", new double[]{k}, 1); MLDouble data = Utils.matToMLDouble(idata, "X"); List<MLArray> mlarray = new ArrayList<>(); mlarray.add((MLArray) dNsample); mlarray.add((MLArray) dIR); mlarray.add((MLArray) dK); mlarray.add((MLArray) data); MatFileWriter writer = new MatFileWriter(); writer.write(outputfile.toFile(), mlarray); }
public void writeSamplingNetworkData(SamplingNetworkData mcNetworkSamplingData) throws IOException { Objects.requireNonNull(mcNetworkSamplingData, "sampling network data is null"); LOGGER.debug("Preparing buses mat data"); MLStructure buses = busesDataAsMLStructure(mcNetworkSamplingData.getBusesData()); LOGGER.debug("Preparing generators mat data"); MLStructure generators = generatorsDataAsMLStructure(mcNetworkSamplingData.getGeneratorsData()); LOGGER.debug("Preparing loads mat data"); MLStructure loads = loadsDataAsMLStructure(mcNetworkSamplingData.getLoadsData()); LOGGER.debug("Saving mat data into " + matFile.toString()); List<MLArray> mlarray = new ArrayList<>(); mlarray.add((MLArray) buses); mlarray.add((MLArray) generators); mlarray.add((MLArray) loads); MatFileWriter writer = new MatFileWriter(); writer.write(matFile.toFile(), mlarray); }
@Override public void performExperiment() throws Exception { final String exproot = "/Users/ss/Dropbox/TrendMiner/deliverables/year2-18month/Austrian Data/streamingExperiments/experiment_1392738388042"; final File[] folds = new File(exproot).listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.contains("fold"); } }); final int f = (folds.length - 1) / 2; final File fold = folds[f]; final File learner = fold.listFiles()[0]; final BilinearSparseOnlineLearner l = IOUtils.read(learner, BilinearSparseOnlineLearner.class); final Matrix words = l.getW(); final Matrix users = l.getU(); final String name = "fold_" + f; final MatFileWriter writ = new MatFileWriter(); final ArrayList<MLArray> col = new ArrayList<MLArray>(); col.add(new MLDouble("words_" + name, CFMatrixUtils.asJama(words).getArray())); col.add(new MLDouble("users_" + name, CFMatrixUtils.asJama(users).getArray())); writ.write(new File("/Users/ss/" + name + ".mat"), col); } }
@Test public void testMLCharUnicode() throws Exception { // array name String name = "chararr"; // file name in which array will be storred String fileName = "mlcharUTF.mat"; // create MLChar array of a name "chararr" containig one // string value "dummy" MLChar mlChar = new MLChar(name, new String[]{"\u017C\u00F3\u0142w", "\u017C\u00F3\u0142i"}); MatFileWriter writer = new MatFileWriter(); writer.write(getTempFile(fileName), Arrays.asList((MLArray) mlChar)); MatFileReader reader = new MatFileReader(getTempFile(fileName)); MLChar mlChar2 = (MLChar) reader.getMLArray(name); assertEquals("\u017C\u00F3\u0142w", mlChar.getString(0)); assertEquals("\u017C\u00F3\u0142w", mlChar2.getString(0)); assertEquals("\u017C\u00F3\u0142i", mlChar2.getString(1)); }