public MatrixInfo readMatrixInfo ( ) throws IOException { String [ ] component = readTrimmedLine ( ) . split ( " +" ) ; if ( component . length != 5 ) throw new IOException ( "Current line unparsable. It must consist of 5 tokens" ) ; // Read header if ( ! component [ 0 ] . equalsIgnoreCase ( "%%MatrixMarket" ) ) throw new IOException ( "Not in Matrix Market exchange format" ) ; // This will always be "matrix" if ( ! component [ 1 ] . equalsIgnoreCase ( "matrix" ) ) throw new IOException ( "Expected \"matrix\", got " + component [ 1 ] ) ; // Sparse or dense? boolean sparse = false ; if ( component [ 2 ] . equalsIgnoreCase ( "coordinate" ) ) sparse = true ; else if ( component [ 2 ] . equalsIgnoreCase ( "array" ) ) sparse = false ; else throw new IOException ( "Unknown layout " + component [ 2 ] ) ; // Dataformat MatrixInfo . MatrixField field = null ; if ( component [ 3 ] . equalsIgnoreCase ( "real" ) ) field = MatrixInfo . MatrixField . Real ; else if ( component [ 3 ] . equalsIgnoreCase ( "integer" ) ) field = MatrixInfo . MatrixField . Integer ; else if ( component [ 3 ] . equalsIgnoreCase ( "complex" ) ) field = MatrixInfo . MatrixField . Complex ; else if ( component [ 3 ] . equalsIgnoreCase ( "pattern" ) ) field = MatrixInfo . MatrixField . Pattern ; else throw new IOException ( "Unknown field specification " + component [ 3 ] ) ; // Matrix pattern MatrixInfo . MatrixSymmetry symmetry = null ; if ( component [ 4 ] . equalsIgnoreCase ( "general" ) ) symmetry = MatrixInfo . MatrixSymmetry . General ; else if ( component [ 4 ] . equalsIgnoreCase ( "symmetric" ) ) symmetry = MatrixInfo . MatrixSymmetry . Symmetric ; else if ( component [ 4 ] . equalsIgnoreCase ( "skew-symmetric" ) ) symmetry = MatrixInfo . MatrixSymmetry . SkewSymmetric ; else if ( component [ 4 ] . equalsIgnoreCase ( "Hermitian" ) ) symmetry = MatrixInfo . MatrixSymmetry . Hermitian ; else throw new IOException ( "Unknown symmetry specification " + component [ 4 ] ) ; // Pack together. This also verifies the format return new MatrixInfo ( sparse , field , symmetry ) ; }
Reads the matrix info for the Matrix Market exchange format . The line must consist of exactly 5 space - separated entries the first being %%MatrixMarket