Package eu.simuline.octave.io.impl
Class AbstractPrimitiveMatrixReader<T extends AbstractGenericMatrix<?,?>>
- java.lang.Object
-
- eu.simuline.octave.io.spi.OctaveDataReader
-
- eu.simuline.octave.io.impl.AbstractPrimitiveMatrixReader<T>
-
- Type Parameters:
T
- the type to be read in which has to extendAbstractGenericMatrix
.
- Direct Known Subclasses:
BooleanReader
,Int32MatrixReader
,Int64MatrixReader
,MatrixReader
,Uint8MatrixReader
abstract class AbstractPrimitiveMatrixReader<T extends AbstractGenericMatrix<?,?>> extends OctaveDataReader
Common Reader class for matrices of primitive java types: Boolean, Double, Integer....
-
-
Constructor Summary
Constructors Constructor Description AbstractPrimitiveMatrixReader()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) abstract T
createOctaveValue(int[] size)
T
read(BufferedReader reader)
The matrix formats, e.g.private T
read2dmatrix(BufferedReader reader, String rowsLine)
protected int[]
readSize2dmatrix(BufferedReader reader, String rowsLine)
Reads linesnum of rows
andnum of cols
and returns an array {nrows ncols}.private int[]
readSizeVectorizedMatrix(BufferedReader reader, String ndimsLine)
Reads a linenum of dims
followed by a line of dimensions: integers separated by blank and returns an array with the according entries.private T
readVectorizedMatrix(BufferedReader reader, String dimsLine)
-
Methods inherited from class eu.simuline.octave.io.spi.OctaveDataReader
getOctaveDataReader, octaveType
-
-
-
-
Field Detail
-
NDIMS
protected static final String NDIMS
- See Also:
- Constant Field Values
-
NROWS
protected static final String NROWS
- See Also:
- Constant Field Values
-
NCOLUMNS
protected static final String NCOLUMNS
- See Also:
- Constant Field Values
-
-
Method Detail
-
createOctaveValue
abstract T createOctaveValue(int[] size)
-
read
public T read(BufferedReader reader)
The matrix formats, e.g. matrix come in two variants: after line with "type" the next line either starts with- # ndims: specifying the number of dimensions
and in the next line the lengths in all these dimensions
and all the following lines the vectorized data,
each in a separate line.
This is read by
readVectorizedMatrix(BufferedReader, String)
. - # rows: specifying the number of rows
and # columns: specifying the number of columns
in the next line (which works only for matrices, i.e. up to dimension 2)
and then for each row a line follows
each of which holds the entries separated by a blank.
This is read by
read2dmatrix(BufferedReader, String)
.
- Specified by:
read
in classOctaveDataReader
- Parameters:
reader
- the Reader to read from, will not close reader- Returns:
- the object read from
reader
.
- # ndims: specifying the number of dimensions
and in the next line the lengths in all these dimensions
and all the following lines the vectorized data,
each in a separate line.
This is read by
-
readVectorizedMatrix
private T readVectorizedMatrix(BufferedReader reader, String dimsLine)
-
readSizeVectorizedMatrix
private int[] readSizeVectorizedMatrix(BufferedReader reader, String ndimsLine)
Reads a linenum of dims
followed by a line of dimensions: integers separated by blank and returns an array with the according entries. In particular the length isnum of dims
.
-
read2dmatrix
private T read2dmatrix(BufferedReader reader, String rowsLine)
-
readSize2dmatrix
protected int[] readSize2dmatrix(BufferedReader reader, String rowsLine)
Reads linesnum of rows
andnum of cols
and returns an array {nrows ncols}.
-
-