Skip to content

Commit ea97e94

Browse files
committed
Update matrix views with structure
1 parent 4042ccf commit ea97e94

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

examples/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# your system and export them to your environment or
55
# define them here.
66

7-
CXX ?= clang++
7+
CXX ?= g++-13
88

99
# Binsparse (this should be fine unless you do an
1010
# out-of-source build)

examples/c_style.cpp

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/convert_binsparse.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,13 @@ int main(int argc, char** argv) {
7070
format = "COO";
7171
}
7272

73-
auto [m, n, nnz, type, comment] = binsparse::mmread_metadata(input_file);
73+
auto [m, n, nnz, type, structure, comment] =
74+
binsparse::mmread_metadata(input_file);
7475

7576
std::cout << "Matrix is " << m << " x " << n << " with " << nnz
7677
<< " values.\n";
7778
std::cout << "Type: " << type << std::endl;
79+
std::cout << "Structure: " << structure << std::endl;
7880
std::cout << "Comment:\n";
7981
std::cout << comment;
8082

include/binsparse/containers/matrices.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ struct column_major {
2424
}
2525
};
2626

27+
enum structure_t { general, symmetric, skew_symmetric, hermitian };
28+
2729
template <typename T, typename I>
2830
struct csr_matrix {
2931
T* values;
3032
I* colind;
3133
I* row_ptr;
3234

3335
I m, n, nnz;
36+
structure_t structure = general;
3437
};
3538

3639
template <typename T, typename I>
@@ -40,6 +43,7 @@ struct csc_matrix {
4043
I* col_ptr;
4144

4245
I m, n, nnz;
46+
structure_t structure = general;
4347
};
4448

4549
template <typename T, typename I>
@@ -49,13 +53,15 @@ struct coo_matrix {
4953
I* colind;
5054

5155
I m, n, nnz;
56+
structure_t structure = general;
5257
};
5358

5459
template <typename T, typename I = std::size_t, typename Order = row_major>
5560
struct dense_matrix {
5661
T* values;
5762

5863
I m, n;
64+
structure_t structure = general;
5965

6066
using order = Order;
6167
};

include/binsparse/matrix_market/matrix_market_inspector.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ namespace binsparse {
1313
// 1 - number of columns in matrix
1414
// 2 - number of values in matrix
1515
// 3 - type of the matrix (real / integer / complex / pattern)
16-
// 4 - comments
16+
// 4 - structure of the matrix (general / symmetric / skew-symmetric /
17+
// Hermitian) 5 - comments
1718
inline auto mmread_metadata(std::string file_path) {
18-
std::string type;
19+
std::string type, structure;
1920

2021
std::ifstream f;
2122

@@ -57,6 +58,7 @@ inline auto mmread_metadata(std::string file_path) {
5758

5859
// Read in general / symmetric / skew-symmetric / Hermitian
5960
ss >> item;
61+
structure = item;
6062

6163
std::string comment;
6264

@@ -77,7 +79,7 @@ inline auto mmread_metadata(std::string file_path) {
7779
ss.str(buf);
7880
ss >> m >> n >> nnz;
7981

80-
return std::tuple(m, n, nnz, type, comment);
82+
return std::tuple(m, n, nnz, type, structure, comment);
8183
}
8284

8385
} // namespace binsparse

0 commit comments

Comments
 (0)