public class MatrixIO extends Object
MatrixIO.Format,
Matrix,
Matrix.Type| Modifier and Type | Class and Description |
|---|---|
static class |
MatrixIO.Format
An enum that specifies the formatting used for the matrix that is
serialized in a file.
|
| Modifier and Type | Method and Description |
|---|---|
static File |
convertFormat(File matrix,
MatrixIO.Format current,
MatrixIO.Format desired)
Converts the format of the input
matrix, returning a temporary
file containing the matrix's data in the desired format. |
static File |
convertFormat(File matrix,
MatrixIO.Format current,
MatrixIO.Format desired,
boolean transpose)
Converts the format of the input
matrix, returning a temporary
file containing the matrix's data in the desired format. |
static FileTransformer |
fileTransformer(MatrixIO.Format format)
|
static Iterator<MatrixEntry> |
getMatrixFileIterator(File matrixFile,
MatrixIO.Format fileFormat)
Returns an iterator over the matrix entries in the data file.
|
static Matrix |
readMatrix(File matrix,
MatrixIO.Format format)
Converts the contents of a matrix file as a
Matrix object, using
the provided format as a hint for what kind to create. |
static Matrix |
readMatrix(File matrix,
MatrixIO.Format format,
Matrix.Type matrixType)
Converts the contents of a matrix file as a
Matrix object, using
the provided type description as a hint for what kind to create. |
static Matrix |
readMatrix(File matrix,
MatrixIO.Format format,
Matrix.Type matrixType,
boolean transposeOnRead)
Converts the contents of a matrix file as a
Matrix object, using
the provided type description as a hint for what kind to create. |
static double[][] |
readMatrixArray(File input,
MatrixIO.Format format)
Deprecated.
|
static void |
writeMatrix(Matrix matrix,
File output,
MatrixIO.Format format)
Writes the matrix to the specified output file in the provided format
|
static void |
writeMatrixArray(double[][] matrix,
File output)
Deprecated.
|
public static File convertFormat(File matrix, MatrixIO.Format current, MatrixIO.Format desired) throws IOException
matrix, returning a temporary
file containing the matrix's data in the desired format.matrix - a file containing a matrix to convertcurrent - the format of the matrix filedesired - the format of the returned matrix fileIOException - if any error occurs while reading the input matrix or
wring the output matrixpublic static File convertFormat(File matrix, MatrixIO.Format current, MatrixIO.Format desired, boolean transpose) throws IOException
matrix, returning a temporary
file containing the matrix's data in the desired format.matrix - a file containing a matrix to convertcurrent - the format of the matrix filedesired - the format of the returned matrix filetranspose - true if data in the input matrix should be
transposed while converting formats to the output matrix.IOException - if any error occurs while reading the input matrix or
wring the output matrixpublic static Iterator<MatrixEntry> getMatrixFileIterator(File matrixFile, MatrixIO.Format fileFormat) throws IOException
matrixFile - the file containing matrix data in the specified formatfileFormat - the format of the matrix fileIOExceptionpublic static FileTransformer fileTransformer(MatrixIO.Format format)
format - the format of a Matrix that will be transformedFileTransformer for the given format@Deprecated public static double[][] readMatrixArray(File input, MatrixIO.Format format) throws IOException
Matrix
objects for all operations. If a Java array is needed, the Matrix#toArray() method may be used to generate one.IOExceptionpublic static Matrix readMatrix(File matrix, MatrixIO.Format format) throws IOException
Matrix object, using
the provided format as a hint for what kind to create. The
type of Matrix object created will assuming that the entire
matrix can fit in memory based on the format of the file speicfied
Note that the returned Matrix instance is not backed by the data
on file; changes to the Matrix will not be reflected in
the original file's data.matrix - a file contain matrix dataformat - the format of the fileMatrix instance that contains the data in the
provided fileIOExceptionpublic static Matrix readMatrix(File matrix, MatrixIO.Format format, Matrix.Type matrixType) throws IOException
Matrix object, using
the provided type description as a hint for what kind to create. The
type of Matrix object created will be based on an estimate of
whether the data will fit into the available memory. Note that the
returned Matrix instance is not backed by the data on file;
changes to the Matrix will not be reflected in the
original file's data.matrix - a file contain matrix dataformat - the format of the filematrixType - the expected type and behavior of the matrix in
relation to memory. This value will be used as a hint for what
kind of Matrix instance to createMatrix instance that contains the data in the
provided fileIOExceptionpublic static Matrix readMatrix(File matrix, MatrixIO.Format format, Matrix.Type matrixType, boolean transposeOnRead) throws IOException
Matrix object, using
the provided type description as a hint for what kind to create. The
type of Matrix object created will be based on an estimate of
whether the data will fit into the available memory. Note that the
returned Matrix instance is not backed by the data on file;
changes to the Matrix will not be reflected in the
original file's data.matrix - a file contain matrix dataformat - the format of the filematrixType - the expected type and behavior of the matrix in
relation to memory. This value will be used as a hint for what
kind of Matrix instance to createtransposeOnRead - true if the matrix should be transposed as
its data is read in. For certain formats, this is more efficient
than reading the data in and then transposing it directly.Matrix instance that contains the data in the
provided file, optionally transposed from its original formatIOException - if any error occurs while reading in the matrix datapublic static void writeMatrix(Matrix matrix, File output, MatrixIO.Format format) throws IOException
matrix - the matrix to be writtenoutput - the file in which the matrix should be writtenformat - the data format in which the matrix's data should be
writtenIllegalArgumentException - if the input matrix is 0-dimensionalIOException - if an error occurs while writing to the output file@Deprecated public static void writeMatrixArray(double[][] matrix, File output) throws IOException
IOExceptionCopyright © 2012. All Rights Reserved.