JaRMoS  1.1
Java Reduced Model Simulations
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
jarmos.io.MathObjectReader Class Reference

Reading matrices and vectors with a bunch of convenient overloads for different sources and output formats. More...

Classes

enum  MachineFormats
 Enum for both known machine formats. More...
 
class  MathReaderException
 

Public Member Functions

RealMatrix readMatrix (InputStream in) throws IOException
 Reads a matrix from an InputStream, pointing to a binary file. More...
 
RealMatrix readMatrix (String file) throws IOException, FileNotFoundException
 Reads a matrix from a given binary file in the file system (accessible via java.io, i.e. More...
 
double[][] readRawDoubleMatrix (InputStream in) throws IOException
 Reads a real matrix as double[][] array from a given binary input stream, including dimension detection. More...
 
double[][] readRawDoubleMatrix (InputStream in, int rows, int cols) throws IOException
 Reads a double matrix of size rows*cols from the input stream. More...
 
double[] readRawDoubleVector (InputStream in) throws IOException
 Reads a real vector from a binary input stream, including dimension detection. More...
 
float[] readRawFloatVector (InputStream in) throws IOException
 
float[] readRawFloatVector (InputStream in, int size) throws IOException
 This method exists due to compatibility with the old rbAppMIT models. More...
 
RealVector readVector (InputStream in) throws IOException
 Reads a real vector including dimension from a given input stream which points to a binary file. More...
 
short[] readRawShortVector (InputStream in) throws IOException
 Reads a short array/vector from the given input stream, autodetecting its size from the first bytes read as (4byte-)integer. More...
 
RealVector readVector (String filename) throws FileNotFoundException, IOException
 Reads a real vector including dimension from a given binary file. More...
 

Public Attributes

MachineFormats MachineFormat = MachineFormats.BigEndian
 Determines which machine format to use. More...
 

Detailed Description

Reading matrices and vectors with a bunch of convenient overloads for different sources and output formats.

All methods operate on binary files, which can be written using either the BIG ENDIAN machine format, (Java natively supports this format in the DataInputStream class) or the LITTLE ENDIAN machine format. The property MachineFormat determines which format is to be assumed when reading the binary file.

When matrices or vectors are read by methods NOT taking the dimensions explicitly, the MathObjectReader will read the first (two) 32-bit integer value(s) as the dimensions of the vector (matrix).

Author
Daniel Wirtz

Definition at line 30 of file MathObjectReader.java.

Member Function Documentation

RealMatrix jarmos.io.MathObjectReader.readMatrix ( InputStream  in) throws IOException

Reads a matrix from an InputStream, pointing to a binary file.

Closes the input stream after reading.

Parameters
in
Returns
Exceptions
IOException

Definition at line 94 of file MathObjectReader.java.

RealMatrix jarmos.io.MathObjectReader.readMatrix ( String  file) throws IOException, FileNotFoundException

Reads a matrix from a given binary file in the file system (accessible via java.io, i.e.

FileStream) including its dimensions.

Parameters
filePath to a binary file
Returns
Exceptions
IOException
FileNotFoundException

Definition at line 108 of file MathObjectReader.java.

double [][] jarmos.io.MathObjectReader.readRawDoubleMatrix ( InputStream  in) throws IOException

Reads a real matrix as double[][] array from a given binary input stream, including dimension detection.

Closes the stream after reading.

Parameters
in
Returns
Exceptions
IOException

Definition at line 129 of file MathObjectReader.java.

double [][] jarmos.io.MathObjectReader.readRawDoubleMatrix ( InputStream  in,
int  rows,
int  cols 
) throws IOException

Reads a double matrix of size rows*cols from the input stream.

Does NOT close the stream after reading to enable reading of more data from it.

Parameters
in
rows
cols
Returns
Exceptions
IOException
Deprecated:
Use binary files that contain the matrix size in first 8 bytes.

Definition at line 156 of file MathObjectReader.java.

double [] jarmos.io.MathObjectReader.readRawDoubleVector ( InputStream  in) throws IOException

Reads a real vector from a binary input stream, including dimension detection.

Closes the stream after reading.

Parameters
in
Returns
Exceptions
IOException

Definition at line 177 of file MathObjectReader.java.

float [] jarmos.io.MathObjectReader.readRawFloatVector ( InputStream  in) throws IOException

Definition at line 196 of file MathObjectReader.java.

float [] jarmos.io.MathObjectReader.readRawFloatVector ( InputStream  in,
int  size 
) throws IOException

This method exists due to compatibility with the old rbAppMIT models.

Does NOT close the stream after reading to allow reading of more data.

Parameters
in
size
Returns
Exceptions
IOException
Deprecated:
Binary files should include the array size for themselves (in first bytes)

Definition at line 218 of file MathObjectReader.java.

short [] jarmos.io.MathObjectReader.readRawShortVector ( InputStream  in) throws IOException

Reads a short array/vector from the given input stream, autodetecting its size from the first bytes read as (4byte-)integer.

Closes the stream after reading.

Parameters
in
Returns
Exceptions
IOException

Definition at line 246 of file MathObjectReader.java.

RealVector jarmos.io.MathObjectReader.readVector ( InputStream  in) throws IOException

Reads a real vector including dimension from a given input stream which points to a binary file.

Closes the input stream after reading.

Parameters
inInputStream of a binary file
Returns
Exceptions
IOException

Definition at line 232 of file MathObjectReader.java.

RealVector jarmos.io.MathObjectReader.readVector ( String  filename) throws FileNotFoundException, IOException

Reads a real vector including dimension from a given binary file.

Parameters
filenameName of a binary file
Returns
Exceptions
IOException
FileNotFoundException

Definition at line 274 of file MathObjectReader.java.

Member Data Documentation

MachineFormats jarmos.io.MathObjectReader.MachineFormat = MachineFormats.BigEndian

Determines which machine format to use.

Default: MachineFormats.BigEndian (native JVM format)

Definition at line 66 of file MathObjectReader.java.


The documentation for this class was generated from the following file: