com.multicorebsp.util
Class MMfile

java.lang.Object
  extended by com.multicorebsp.util.MMfile

public class MMfile
extends java.lang.Object

Models, and parses, a matrix-market file. Also has support for the Extended Matrix-Market format.


Nested Class Summary
static class MMfile.VERSION
          Used to differentiate between original matrix-market and extended matrix market.
 
Field Summary
static MMfile.VERSION OVERRIDE
          Set to a version type to ignore banner errors and try to read with default values of MMmatrix.
 
Constructor Summary
MMfile(java.lang.String fn)
          Reads in a matrix market object from file.
MMfile(java.lang.String fn, java.util.Collection<java.lang.String> skip)
          Reads in a matrix market object from file.
 
Method Summary
 java.lang.String getFilename()
           
 MMobject getFileObject()
           
 MMobject getFileObject(java.lang.String name)
          Scans read-in objects for one with a given name, and returns this object.
 java.util.ArrayList<MMobject> getFileObjects()
           
 MMfile.VERSION getVersion()
           
 boolean isSuccessfully_read()
           
protected  void mm_read_banner(java.util.Scanner s, MMobject matrix, MMfile.VERSION force_compatibility, boolean main)
          Interprets the very first line of a matrix-market input file.
protected  void mm_read_mtx_crd_entry(java.util.Scanner s, int at, MMobject matrix)
          Reads in a single value from a matrix market file.
protected  void mm_read_mtx_crd_size(java.util.Scanner s, MMobject matrix)
          Reads in the matrix dimensions and number of nonzeroes.
protected  void mm_read_mtx_pstart_entry(java.util.Scanner s, int i, MMobject matrix)
          Reads in an element from the Pstart vector.
protected  boolean mm_read_object(java.util.Scanner s, boolean first, java.util.Collection<java.lang.String> skip)
          Reads in a matrix-market object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OVERRIDE

public static MMfile.VERSION OVERRIDE
Set to a version type to ignore banner errors and try to read with default values of MMmatrix. If the value is null, no override takes place on banner errors.

See Also:
MMobject
Constructor Detail

MMfile

public MMfile(java.lang.String fn)
       throws java.io.IOException
Reads in a matrix market object from file.

Parameters:
fn - Name of file to read.
Throws:
java.io.IOException

MMfile

public MMfile(java.lang.String fn,
              java.util.Collection<java.lang.String> skip)
       throws java.io.IOException
Reads in a matrix market object from file.

Parameters:
fn - Name of file to read.
skip - Names of objects in the file to skip.
Throws:
java.io.IOException
Method Detail

mm_read_banner

protected void mm_read_banner(java.util.Scanner s,
                              MMobject matrix,
                              MMfile.VERSION force_compatibility,
                              boolean main)
                       throws java.io.IOException
Interprets the very first line of a matrix-market input file.

Parameters:
s - A handle to the scanner reading the input file
matrix - Where to store the matrix
force_compatibility - Used to force a certain MatrixMarket version, null will infer from file.
main - If this is the main object read in
Throws:
java.io.IOException

mm_read_mtx_crd_size

protected void mm_read_mtx_crd_size(java.util.Scanner s,
                                    MMobject matrix)
Reads in the matrix dimensions and number of nonzeroes. (Corresponds to the second line in a MMmatrix desription file.)

Parameters:
s - Handle to the file scanner
matrix - Where to store the matrix data

mm_read_mtx_crd_entry

protected void mm_read_mtx_crd_entry(java.util.Scanner s,
                                     int at,
                                     MMobject matrix)
                              throws java.io.IOException
Reads in a single value from a matrix market file.

Parameters:
s - Handle to the file scanner
at - Which nonzero number is being read in
matrix - Handle to where to store the matrix
Throws:
java.io.IOException

mm_read_mtx_pstart_entry

protected void mm_read_mtx_pstart_entry(java.util.Scanner s,
                                        int i,
                                        MMobject matrix)
Reads in an element from the Pstart vector.

Parameters:
s - Handle to the file scanner
i - Current element nr. being processed
matrix - Where to store the matrix

mm_read_object

protected boolean mm_read_object(java.util.Scanner s,
                                 boolean first,
                                 java.util.Collection<java.lang.String> skip)
                          throws java.io.IOException
Reads in a matrix-market object.

Parameters:
s - Handle to the file scanner
first - If this is the first object to be read in
skip - Collection of object names to skip reading in
Throws:
java.io.IOException

getFilename

public java.lang.String getFilename()
Returns:
The filename of the current MM file.

isSuccessfully_read

public boolean isSuccessfully_read()
Returns:
Whether parsing was successful

getVersion

public MMfile.VERSION getVersion()
Returns:
File version

getFileObject

public MMobject getFileObject(java.lang.String name)
Scans read-in objects for one with a given name, and returns this object. Warning: this method ignores case when comparing matrix names.

Parameters:
name - Object name to search for.
Returns:
The requested matrix object.

getFileObjects

public java.util.ArrayList<MMobject> getFileObjects()
Returns:
Returns all read-in matrix objects.

getFileObject

public MMobject getFileObject()
Returns:
The matrix first read in (usually the main matrix).