import.html 8.64 KB
 Roman Flury committed Oct 05, 2018 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89  Read External Matrix Formats — import • spam
file

the name of the file to read, as a character scalar.

Value

A sparse matrix of class spam.

Details

The names of files storing matrices in the Harwell-Boeing format usually end in ".rua" or ".rsa". Those storing matrices in the MatrixMarket format usually end in ".mtx".

Currently, only real assembled Harwell-Boeing can be read with read.HB. Reading MatrixMarket formats is more flexible. However, as entries of spam matrices are of mode double, integers matrices are coerced to doubles, patterns lead to matrices containing ones and complex are coerced to the real part thereof. In these aforementioned cases, a warning is issued.

MatrixMarket also defines an array format, in which case a (possibly) dense spam object is return (retaining only elements which are larger than options('spam.eps'). A warning is issued.

Note

The functions are based on readHB and readMM from the library Matrix to build the connection and read the raw data. At present, read.MM is more flexible than readMM.

References

http://math.nist.gov/MatrixMarket

https://sparse.tamu.edu/

Examples

# NOT RUN { image(read.MM(gzcon(url( "ftp://math.nist.gov/pub/MatrixMarket2/Harwell-Boeing/bcspwr/bcspwr01.mtx.gz")))) # }
# NOT RUN { ## Datasets supplied within Matrix str(read.MM(system.file("external/pores_1.mtx",package = "Matrix"))) str(read.HB(system.file("external/utm300.rua", package = "Matrix"))) str(read.MM(system.file("external/lund_a.mtx", package = "Matrix"))) str(read.HB(system.file("external/lund_a.rsa", package = "Matrix"))) # }