Skip to content

Commit

Permalink
Clarify types in README
Browse files Browse the repository at this point in the history
  • Loading branch information
alugowski committed Apr 7, 2023
1 parent c325509 commit a37a329
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
6 changes: 4 additions & 2 deletions README.Armadillo.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Armadillo (blaze-lib) Matrix Market
# Armadillo Matrix Market

`fast_matrix_market` provides read/write methods for [Armadillo](https://arma.sourceforge.net/) sparse and dense matrices.

Expand All @@ -14,6 +14,8 @@ arma::Mat<double> A;
arma::SpMat<double> A;
```

Not restricted to `double` matrices. Any type supported by Armadillo that makes sense in Matrix Market is also supported, such as `int64_t`, `float`, `std::complex<double>`, etc.

### Reading
```c++
std::ifstream f("input.mtx");
Expand All @@ -22,7 +24,7 @@ fast_matrix_market::read_matrix_market_arma(f, A);
```
**Note:** Armadillo versions older than 10.5 [did not zero-initialize memory](https://arma.sourceforge.net/docs.html#changelog).
On those versions loading a sparse Matrix Market file into a dense `Mat` is not supported.
On those versions reading any Matrix Market file into a dense `arma::Mat` is not supported.
### Writing
Expand Down
3 changes: 3 additions & 0 deletions README.Blaze.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ blaze::CompressedVector<double> A;
// or
blaze::DynamicVector<double> A;
```

Not restricted to `double` matrices. Any type supported by Blaze that makes sense in Matrix Market is also supported, such as `int64_t`, `float`, `std::complex<double>`, etc.

### Reading
```c++
std::ifstream f("input.mtx");
Expand Down
4 changes: 2 additions & 2 deletions README.CXSparse.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ cs_dl *A;
std::ifstream f("input.mtx");
fast_matrix_market::read_matrix_market_cxsparse(f, &A, cs_dl_spalloc);
```
Note the last argument. It is the `cs_spalloc` routine that matches the type
Note the last argument. It is the `cs_*_spalloc` routine that matches the type
of `A`. It must be specified explicitly because it is impractical to autodetect due to the way CXSparse
implements multiple index and value types.
implements multiple index and value types. All CXSparse types are supported, such as `cs_dl`, `cs_ci`, `cs_cl`, etc.
`read_matrix_market_cxsparse` creates a triplet version of the matrix structure. For CSC, follow up with
CXSparse's `cs_compress()`:
Expand Down
2 changes: 2 additions & 0 deletions README.Eigen.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ fast_matrix_market::write_matrix_market_eigen(f, mat);
Again, for dense matrices/vectors use `write_matrix_market_eigen_dense`.
Not restricted to `double` matrices. Any type supported by Eigen that makes sense in Matrix Market is also supported, such as `int64_t`, `float`, `std::complex<double>`, etc.
Note that Vectors are written with object type = `matrix` for compatibility reasons. Eigen's `saveMarketVector()` does the same. As of writing Eigen's loader crashes on `vector` files.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Matrix composed of row and column index vectors and a value vector. Any vector c
struct triplet_matrix {
int64_t nrows = 0, ncols = 0;
std::vector<int64_t> rows, cols;
std::vector<double> vals;
std::vector<double> vals; // or int64_t, float, std::complex<double>, etc.
} mat;

fast_matrix_market::read_matrix_market_triplet(
Expand All @@ -108,7 +108,7 @@ Be mindful of whether your code expects row or column major ordering.
```c++
struct array_matrix {
int64_t nrows = 0, ncols = 0;
std::vector<double> vals;
std::vector<double> vals; // or int64_t, float, std::complex<double>, etc.
} mat;
fast_matrix_market::read_matrix_market_array(
Expand Down

0 comments on commit a37a329

Please sign in to comment.