Skip to content

Commit 4042ccf

Browse files
committed
Update formatting
1 parent 90f1273 commit 4042ccf

File tree

7 files changed

+152
-58
lines changed

7 files changed

+152
-58
lines changed

.clang-format

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
BasedOnStyle: LLVM
33
PointerAlignment: Left
44
ColumnLimit: 80
5+
AlwaysBreakTemplateDeclarations: Yes
6+
AllowShortFunctionsOnASingleLine: Empty
57
---

examples/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ CXX ?= clang++
1111
BINSPARSE_DIR ?= ../include
1212

1313
# HDF5 library location
14-
HDF5_DIR ?= /opt/homebrew/Cellar/hdf5/1.14.2
14+
HDF5_DIR ?= /opt/homebrew/Cellar/hdf5/1.14.3
1515
HDF5_CXXFLAGS ?= -I$(HDF5_DIR)/include
1616
HDF5_LIBRARY_FLAGS ?= -L$(HDF5_DIR)/lib -lhdf5_hl_cpp -lhdf5_cpp -lhdf5_hl -lhdf5
1717

include/binsparse/c_bindings/allocator_wrapper.hpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
namespace binsparse {
44

5-
template <typename T> class allocator_wrapper {
5+
template <typename T>
6+
class allocator_wrapper {
67
public:
78
using value_type = T;
89
using pointer = T*;
@@ -29,12 +30,15 @@ template <typename T> class allocator_wrapper {
2930
return reinterpret_cast<T*>(malloc_fn_(size * sizeof(T)));
3031
}
3132

32-
void deallocate(pointer ptr, std::size_t n) { free_fn_(ptr); }
33+
void deallocate(pointer ptr, std::size_t n) {
34+
free_fn_(ptr);
35+
}
3336

3437
bool operator==(const allocator_wrapper&) const = default;
3538
bool operator!=(const allocator_wrapper&) const = default;
3639

37-
template <typename U> struct rebind {
40+
template <typename U>
41+
struct rebind {
3842
using other = allocator_wrapper<U>;
3943
};
4044

include/binsparse/containers/matrices.hpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,45 @@
55
namespace binsparse {
66

77
struct row_major {
8-
constexpr bool operator==(row_major) { return true; }
9-
template <typename T> constexpr bool operator==(T&&) { return false; }
8+
constexpr bool operator==(row_major) {
9+
return true;
10+
}
11+
template <typename T>
12+
constexpr bool operator==(T&&) {
13+
return false;
14+
}
1015
};
1116

1217
struct column_major {
13-
constexpr bool operator==(column_major) { return true; }
14-
template <typename T> constexpr bool operator==(T&&) { return false; }
18+
constexpr bool operator==(column_major) {
19+
return true;
20+
}
21+
template <typename T>
22+
constexpr bool operator==(T&&) {
23+
return false;
24+
}
1525
};
1626

17-
template <typename T, typename I> struct csr_matrix {
27+
template <typename T, typename I>
28+
struct csr_matrix {
1829
T* values;
1930
I* colind;
2031
I* row_ptr;
2132

2233
I m, n, nnz;
2334
};
2435

25-
template <typename T, typename I> struct csc_matrix {
36+
template <typename T, typename I>
37+
struct csc_matrix {
2638
T* values;
2739
I* rowind;
2840
I* col_ptr;
2941

3042
I m, n, nnz;
3143
};
3244

33-
template <typename T, typename I> struct coo_matrix {
45+
template <typename T, typename I>
46+
struct coo_matrix {
3447
T* values;
3548
I* rowind;
3649
I* colind;

include/binsparse/hdf5_tools.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
namespace hdf5_tools {
1111

12-
template <typename U> inline H5::PredType get_hdf5_native_type() {
12+
template <typename U>
13+
inline H5::PredType get_hdf5_native_type() {
1314
using T = std::decay_t<U>;
1415
if constexpr (std::is_same_v<T, char>) {
1516
return H5::PredType::NATIVE_CHAR;
@@ -42,7 +43,8 @@ template <typename U> inline H5::PredType get_hdf5_native_type() {
4243
}
4344
}
4445

45-
template <typename U> inline H5::PredType get_hdf5_standard_type() {
46+
template <typename U>
47+
inline H5::PredType get_hdf5_standard_type() {
4648
using T = std::decay_t<U>;
4749
if constexpr (std::is_same_v<T, char>) {
4850
return H5::PredType::STD_I8LE;

include/binsparse/matrix_market/matrix_market_read.hpp

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,33 @@ namespace binsparse {
88

99
namespace __detail {
1010

11-
template <typename T, typename I> class csr_matrix_owning {
11+
template <typename T, typename I>
12+
class csr_matrix_owning {
1213
public:
1314
csr_matrix_owning(std::tuple<I, I> shape) : shape_(shape) {}
1415

15-
auto values() { return std::ranges::views::all(values_); }
16-
auto rowptr() { return std::ranges::views::all(rowptr_); }
17-
auto colind() { return std::ranges::views::all(colind_); }
16+
auto values() {
17+
return std::ranges::views::all(values_);
18+
}
19+
auto rowptr() {
20+
return std::ranges::views::all(rowptr_);
21+
}
22+
auto colind() {
23+
return std::ranges::views::all(colind_);
24+
}
1825

19-
auto values() const { return std::ranges::views::all(values_); }
20-
auto rowptr() const { return std::ranges::views::all(rowptr_); }
21-
auto colind() const { return std::ranges::views::all(colind_); }
26+
auto values() const {
27+
return std::ranges::views::all(values_);
28+
}
29+
auto rowptr() const {
30+
return std::ranges::views::all(rowptr_);
31+
}
32+
auto colind() const {
33+
return std::ranges::views::all(colind_);
34+
}
2235

23-
template <typename Iter> void assign_tuples(Iter first, Iter last) {
36+
template <typename Iter>
37+
void assign_tuples(Iter first, Iter last) {
2438
std::size_t nnz = std::ranges::distance(first, last);
2539
values_.resize(nnz);
2640
colind_.resize(nnz);
@@ -58,9 +72,13 @@ template <typename T, typename I> class csr_matrix_owning {
5872
}
5973
}
6074

61-
auto shape() const { return shape_; }
75+
auto shape() const {
76+
return shape_;
77+
}
6278

63-
auto size() const { return values_.size(); }
79+
auto size() const {
80+
return values_.size();
81+
}
6482

6583
private:
6684
std::tuple<I, I> shape_;
@@ -69,17 +87,30 @@ template <typename T, typename I> class csr_matrix_owning {
6987
std::vector<I> colind_;
7088
};
7189

72-
template <typename T, typename I> class coo_matrix_owning {
90+
template <typename T, typename I>
91+
class coo_matrix_owning {
7392
public:
7493
coo_matrix_owning(std::tuple<I, I> shape) : shape_(shape) {}
7594

76-
auto values() { return std::ranges::views::all(values_); }
77-
auto rowind() { return std::ranges::views::all(rowind_); }
78-
auto colind() { return std::ranges::views::all(colind_); }
95+
auto values() {
96+
return std::ranges::views::all(values_);
97+
}
98+
auto rowind() {
99+
return std::ranges::views::all(rowind_);
100+
}
101+
auto colind() {
102+
return std::ranges::views::all(colind_);
103+
}
79104

80-
auto values() const { return std::ranges::views::all(values_); }
81-
auto rowind() const { return std::ranges::views::all(rowind_); }
82-
auto colind() const { return std::ranges::views::all(colind_); }
105+
auto values() const {
106+
return std::ranges::views::all(values_);
107+
}
108+
auto rowind() const {
109+
return std::ranges::views::all(rowind_);
110+
}
111+
auto colind() const {
112+
return std::ranges::views::all(colind_);
113+
}
83114

84115
void push_back(std::tuple<std::tuple<I, I>, T> entry) {
85116
auto&& [idx, v] = entry;
@@ -89,7 +120,8 @@ template <typename T, typename I> class coo_matrix_owning {
89120
colind_.push_back(j);
90121
}
91122

92-
template <typename Iter> void assign_tuples(Iter first, Iter last) {
123+
template <typename Iter>
124+
void assign_tuples(Iter first, Iter last) {
93125
std::size_t nnz = std::ranges::distance(first, last);
94126
for (auto iter = first; iter != last; ++iter) {
95127
auto&& [idx, v] = *iter;
@@ -104,9 +136,13 @@ template <typename T, typename I> class coo_matrix_owning {
104136
colind_.reserve(size);
105137
}
106138

107-
auto shape() const { return shape_; }
139+
auto shape() const {
140+
return shape_;
141+
}
108142

109-
auto size() const { return values_.size(); }
143+
auto size() const {
144+
return values_.size();
145+
}
110146

111147
private:
112148
std::tuple<I, I> shape_;

include/binsparse/type_info.hpp

Lines changed: 62 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
namespace binsparse {
77

8-
template <typename T> struct type_info;
8+
template <typename T>
9+
struct type_info;
910

1011
template <typename T>
1112
requires(std::is_const_v<T> || std::is_volatile_v<T>)
@@ -15,52 +16,88 @@ struct type_info<T> {
1516
}
1617
};
1718

18-
template <> struct type_info<uint8_t> {
19-
static constexpr auto label() noexcept { return "uint8"; }
19+
template <>
20+
struct type_info<uint8_t> {
21+
static constexpr auto label() noexcept {
22+
return "uint8";
23+
}
2024
};
2125

22-
template <> struct type_info<uint16_t> {
23-
static constexpr auto label() noexcept { return "uint16"; }
26+
template <>
27+
struct type_info<uint16_t> {
28+
static constexpr auto label() noexcept {
29+
return "uint16";
30+
}
2431
};
2532

26-
template <> struct type_info<uint32_t> {
27-
static constexpr auto label() noexcept { return "uint32"; }
33+
template <>
34+
struct type_info<uint32_t> {
35+
static constexpr auto label() noexcept {
36+
return "uint32";
37+
}
2838
};
2939

30-
template <> struct type_info<uint64_t> {
31-
static constexpr auto label() noexcept { return "uint64"; }
40+
template <>
41+
struct type_info<uint64_t> {
42+
static constexpr auto label() noexcept {
43+
return "uint64";
44+
}
3245
};
3346

34-
template <> struct type_info<std::size_t> {
35-
static constexpr auto label() noexcept { return "uint64"; }
47+
template <>
48+
struct type_info<std::size_t> {
49+
static constexpr auto label() noexcept {
50+
return "uint64";
51+
}
3652
};
3753

38-
template <> struct type_info<int8_t> {
39-
static constexpr auto label() noexcept { return "int8"; }
54+
template <>
55+
struct type_info<int8_t> {
56+
static constexpr auto label() noexcept {
57+
return "int8";
58+
}
4059
};
4160

42-
template <> struct type_info<int16_t> {
43-
static constexpr auto label() noexcept { return "int16"; }
61+
template <>
62+
struct type_info<int16_t> {
63+
static constexpr auto label() noexcept {
64+
return "int16";
65+
}
4466
};
4567

46-
template <> struct type_info<int32_t> {
47-
static constexpr auto label() noexcept { return "int32"; }
68+
template <>
69+
struct type_info<int32_t> {
70+
static constexpr auto label() noexcept {
71+
return "int32";
72+
}
4873
};
4974

50-
template <> struct type_info<int64_t> {
51-
static constexpr auto label() noexcept { return "int64"; }
75+
template <>
76+
struct type_info<int64_t> {
77+
static constexpr auto label() noexcept {
78+
return "int64";
79+
}
5280
};
5381

54-
template <> struct type_info<float> {
55-
static constexpr auto label() noexcept { return "float32"; }
82+
template <>
83+
struct type_info<float> {
84+
static constexpr auto label() noexcept {
85+
return "float32";
86+
}
5687
};
5788

58-
template <> struct type_info<double> {
59-
static constexpr auto label() noexcept { return "float64"; }
89+
template <>
90+
struct type_info<double> {
91+
static constexpr auto label() noexcept {
92+
return "float64";
93+
}
6094
};
6195

62-
template <> struct type_info<bool> {
63-
static constexpr auto label() noexcept { return "bint8"; }
96+
template <>
97+
struct type_info<bool> {
98+
static constexpr auto label() noexcept {
99+
return "bint8";
100+
}
64101
};
65102

66103
namespace __detail {

0 commit comments

Comments
 (0)