public class Matrix extends Object
Modifier and Type | Field and Description |
---|---|
static int |
INT_ENTRIES |
static int |
LONG_ENTRIES |
Constructor and Description |
---|
Matrix(String filename) |
Matrix(String filename,
int numberOfRows,
int numberOfColumns,
boolean rowFormat,
int entriesType) |
Modifier and Type | Method and Description |
---|---|
int[] |
createDenseIntColumn(int numberOfRows) |
int[] |
createDenseIntRow() |
int |
getEntriesType() |
int |
getMetadataLength() |
int |
getNumberOfColumns() |
int |
getNumberOfRows() |
boolean |
isColumnMajorFormat() |
boolean |
isRowMajorFormat() |
static void |
main(String[] args) |
int[][] |
readIntMatrix()
Read a matrix that has been written to a file (specified in the
constructor) based on the specified rows and columns.
|
int[] |
readIntMatrixColumn(int columnId)
This method reads a specified column from the matrix that has been
written to a file.
|
int |
readIntMatrixElement(int rowId,
int columnId)
Reads a matrix element from the underlying file based on the specified
[rowId, columId] . |
int[] |
readIntMatrixRow(int rowId)
This method reads the specified row of a matrix that has been written to
a file.
|
long[][] |
readLongMatrix()
Read a matrix that has been written to a file (specified in the
constructor) based on the specified rows and columns.
|
long[] |
readLongMatrixColumn(int columnId)
This method reads a specified column from the matrix that has been
written to a file.
|
long |
readLongMatrixElement(int rowId,
int columnId)
Reads a matrix element from the underlying file based on the specified
[rowId, columId] . |
long[] |
readLongMatrixRow(int rowId)
This method reads the specified row of a matrix that has been written to
a file.
|
long |
size() |
void |
writeIntMatrixColumn(int columnId,
int[] columnValues)
Write a column of the matrix to the underlying file.
|
void |
writeIntMatrixElement(int rowId,
int columnId,
int value)
Write a specific matrix element code>[rowId, columnId] to the
file.
|
void |
writeIntMatrixRow(int rowId,
int[] rowValues)
Write a row of the matrix to the underlying file.
|
void |
writeLongMatrixColumn(int columnId,
long[] columnValues)
Write a column of the matrix to the underlying file.
|
void |
writeLongMatrixElement(int rowId,
int columnId,
long value)
Write a specific matrix element code>[rowId, columnId] to the
file.
|
void |
writeLongMatrixRow(int rowId,
long[] rowValues)
Write a row of the matrix to the underlying file.
|
public static final int INT_ENTRIES
public static final int LONG_ENTRIES
public Matrix(String filename, int numberOfRows, int numberOfColumns, boolean rowFormat, int entriesType) throws IOException
IOException
public Matrix(String filename) throws IOException
IOException
public long size() throws IOException
IOException
public int getMetadataLength()
public boolean isRowMajorFormat()
public boolean isColumnMajorFormat()
public int getNumberOfRows()
public int getNumberOfColumns()
public int getEntriesType()
public long[] readLongMatrixRow(int rowId) throws IOException
rowId
- The matrix row that needs to be retrievedIOException
- If there are problems locating the file or reading its
contents.public long[] readLongMatrixColumn(int columnId) throws IOException
columnId
- The matrix column that needs to be retrievedIOException
- If there are problems locating the file or reading its
contents.public long readLongMatrixElement(int rowId, int columnId) throws IOException
[rowId, columId]
.rowId
- The rowId for the matrix elementcolumnId
- The columnId for the matrix elementmatrix[rowId, columnId]
element.IOException
- If there are problems reading the file.public long[][] readLongMatrix() throws IOException
OutOfMemoryError
IOException
- If there are problems reading from the file.public void writeLongMatrixElement(int rowId, int columnId, long value) throws IOException
rowId
- The row identifier for the elementcolumnId
- The column identifier for the elementvalue
- The value of the matrix element [rowId, columnId]
IOException
- If there are problems writing to the file.public void writeLongMatrixRow(int rowId, long[] rowValues) throws IOException
rowId
- The identifier of the matrix rowrowValues
- The values associated with the rowIOException
- If there are problems writing to the file.public void writeLongMatrixColumn(int columnId, long[] columnValues) throws IOException
columnId
- The columnId for the matrix columncolumnValues
- Values associated with the columnIOException
- If there are problems writing to the file.public int[] readIntMatrixRow(int rowId) throws IOException
rowId
- The matrix row that needs to be retrievedIOException
- If there are problems locating the file or reading its
contents.public int[] readIntMatrixColumn(int columnId) throws IOException
columnId
- The matrix column that needs to be retrievedIOException
- If there are problems locating the file or reading its
contents.public int readIntMatrixElement(int rowId, int columnId) throws IOException
[rowId, columId]
.rowId
- The rowId for the matrix elementcolumnId
- The columnId for the matrix elementmatrix[rowId, columnId]
element.IOException
- If there are problems reading the file.public int[][] readIntMatrix() throws IOException
OutOfMemoryError
IOException
- If there are problems reading from the file.public void writeIntMatrixElement(int rowId, int columnId, int value) throws IOException
rowId
- The row identifier for the elementcolumnId
- The column identifier for the elementvalue
- The value of the matrix element [rowId, columnId]
IOException
- If there are problems writing to the file.public void writeIntMatrixRow(int rowId, int[] rowValues) throws IOException
rowId
- The identifier of the matrix rowrowValues
- The values associated with the rowIOException
- If there are problems writing to the file.public void writeIntMatrixColumn(int columnId, int[] columnValues) throws IOException
columnId
- The columnId for the matrix columncolumnValues
- Values associated with the columnIOException
- If there are problems writing to the file.public int[] createDenseIntRow()
public int[] createDenseIntColumn(int numberOfRows)
public static void main(String[] args)
args
- Copyright © 2015. All rights reserved.