Skip to content

Commit

Permalink
Add Blaze integration
Browse files Browse the repository at this point in the history
closes #2
  • Loading branch information
alugowski committed Jan 19, 2023
1 parent d44e1b2 commit 568cfcc
Show file tree
Hide file tree
Showing 8 changed files with 694 additions and 5 deletions.
41 changes: 41 additions & 0 deletions README.Blaze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Blaze (blaze-lib) Matrix Market

`fast_matrix_market` provides read/write methods for [Blaze](https://bitbucket.org/blaze-lib/blaze) sparse and dense matrices and vectors.

# Usage

```c++
#include <fast_matrix_market/app/Blaze.hpp>
```

```c++
blaze::CompressedMatrix<double> A;
// or
blaze::DynamicMatrix<double> A;
// or
blaze::CompressedVector<double> A;
// or
blaze::DynamicVector<double> A;
```
### Reading
```c++
std::ifstream f("input.mtx");

fast_matrix_market::read_matrix_market_blaze(f, A);
```
**Note:** if `A` is a Vector type then the Matrix Market file must be either a vector or a
1-by-N row or M-by-1 column matrix. Any other matrix will cause an exception to be thrown.
### Writing
```c++
std::ofstream f("output.mtx");
fast_matrix_market::write_matrix_market_blaze(f, A);
```


**Compatibility Note:** Blaze Vector objects are written as vector Matrix Market files.
Many MatrixMarket loaders cannot read vector files. If this is a problem write the vector
as a 1-by-N or M-by-1 matrix.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ cs_dl *A;
fast_matrix_market::read_matrix_market_cxsparse(input_stream, &A, cs_dl_spalloc);
```

## Blaze
[Blaze](https://bitbucket.org/blaze-lib/blaze) sparse and dense matrices and vectors are supported. See [Blaze README](README.Blaze.md).
```c++
blaze::CompressedMatrix<double> A;
fast_matrix_market::read_matrix_market_blaze(input_stream, A);
```
## Your Own
Simply provide `parse_handler` and `formatter` classes to read and write from/to any datastructure, respectively. The class you need is likely already in the library.
Expand Down
10 changes: 10 additions & 0 deletions cmake/Blaze.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Fetch from git
include(FetchContent)

FetchContent_Declare(
blaze
GIT_REPOSITORY https://bitbucket.org/blaze-lib/blaze.git
GIT_TAG v3.8.1
GIT_SHALLOW TRUE)

FetchContent_MakeAvailable(blaze)
Loading

0 comments on commit 568cfcc

Please sign in to comment.