public VectorInfo readVectorInfo ( ) throws IOException { String [ ] component = readTrimmedLine ( ) . split ( " +" ) ; if ( component . length != 4 ) throw new IOException ( "Current line unparsable. It must consist of 4 tokens" ) ; // Read header if ( ! component [ 0 ] . equalsIgnoreCase ( "%%MatrixMarket" ) ) throw new IOException ( "Not in Matrix Market exchange format" ) ; // This will always be "vector" if ( ! component [ 1 ] . equalsIgnoreCase ( "vector" ) ) throw new IOException ( "Expected \"vector\", 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 VectorInfo . VectorField field = null ; if ( component [ 3 ] . equalsIgnoreCase ( "real" ) ) field = VectorInfo . VectorField . Real ; else if ( component [ 3 ] . equalsIgnoreCase ( "integer" ) ) field = VectorInfo . VectorField . Integer ; else if ( component [ 3 ] . equalsIgnoreCase ( "complex" ) ) field = VectorInfo . VectorField . Complex ; else if ( component [ 3 ] . equalsIgnoreCase ( "pattern" ) ) field = VectorInfo . VectorField . Pattern ; else throw new IOException ( "Unknown field specification " + component [ 3 ] ) ; // Pack together. This also verifies the format return new VectorInfo ( sparse , field ) ; }
Reads the vector info for the Matrix Market exchange format . The line must consist of exactly 4 space - separated entries the first being %%MatrixMarket