Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit 9b00575

Browse files
authored
Use the detray configuration for clang-format (#173)
Run detray clang-format
1 parent 5f37292 commit 9b00575

99 files changed

Lines changed: 7546 additions & 7395 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
BasedOnStyle: Google
3+
IndentWidth: 4
34
Language: Cpp
45
AllowShortBlocksOnASingleLine: false
56
AllowShortCaseLabelsOnASingleLine: false
@@ -8,4 +9,5 @@ AllowShortIfStatementsOnASingleLine: false
89
AllowShortLoopsOnASingleLine: false
910
PointerAlignment: Left
1011
ColumnLimit: 80
12+
AccessModifierOffset: 0
1113
KeepEmptyLinesAtTheStartOfBlocks: true

benchmarks/algebra/include/algebra/array/data_generator.hpp

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,74 +22,75 @@ namespace algebra {
2222
template <concepts::vector vector_t>
2323
inline void fill_random_vec(std::vector<vector_t> &collection) {
2424

25-
// Generate a vector of the right type with random values
26-
std::random_device rd;
27-
std::mt19937 mt(rd());
28-
std::uniform_real_distribution<typename vector_t::value_type> dist(0.f, 1.f);
25+
// Generate a vector of the right type with random values
26+
std::random_device rd;
27+
std::mt19937 mt(rd());
28+
std::uniform_real_distribution<typename vector_t::value_type> dist(0.f,
29+
1.f);
2930

30-
auto rand_obj = [&]() { return vector_t{dist(mt), dist(mt), dist(mt)}; };
31+
auto rand_obj = [&]() { return vector_t{dist(mt), dist(mt), dist(mt)}; };
3132

32-
collection.resize(collection.capacity());
33-
std::ranges::generate(collection, rand_obj);
33+
collection.resize(collection.capacity());
34+
std::ranges::generate(collection, rand_obj);
3435
}
3536

3637
/// Fill a @c std::array based transform3 with random values
3738
template <concepts::transform3D transform3_t>
3839
inline void fill_random_trf(std::vector<transform3_t> &collection) {
3940

40-
using vector_t = typename transform3_t::vector3;
41+
using vector_t = typename transform3_t::vector3;
4142

42-
// Generate a random, but valid affine transformation
43-
std::random_device rd;
44-
std::mt19937 mt(rd());
45-
std::uniform_real_distribution<typename transform3_t::scalar_type> dist(0.f,
46-
1.f);
43+
// Generate a random, but valid affine transformation
44+
std::random_device rd;
45+
std::mt19937 mt(rd());
46+
std::uniform_real_distribution<typename transform3_t::scalar_type> dist(
47+
0.f, 1.f);
4748

48-
auto rand_obj = [&]() {
49-
vector_t x_axis;
50-
vector_t z_axis;
51-
vector_t t;
49+
auto rand_obj = [&]() {
50+
vector_t x_axis;
51+
vector_t z_axis;
52+
vector_t t;
5253

53-
x_axis = vector::normalize(vector_t{dist(mt), dist(mt), dist(mt)});
54-
z_axis = {dist(mt), dist(mt), dist(mt)};
55-
t = vector::normalize(vector_t{dist(mt), dist(mt), dist(mt)});
54+
x_axis = vector::normalize(vector_t{dist(mt), dist(mt), dist(mt)});
55+
z_axis = {dist(mt), dist(mt), dist(mt)};
56+
t = vector::normalize(vector_t{dist(mt), dist(mt), dist(mt)});
5657

57-
// Gram-Schmidt projection
58-
typename transform3_t::scalar_type coeff =
59-
vector::dot(x_axis, z_axis) / vector::norm(x_axis);
60-
z_axis = x_axis - coeff * z_axis;
58+
// Gram-Schmidt projection
59+
typename transform3_t::scalar_type coeff =
60+
vector::dot(x_axis, z_axis) / vector::norm(x_axis);
61+
z_axis = x_axis - coeff * z_axis;
6162

62-
return transform3_t{t, x_axis, vector::normalize(z_axis)};
63-
};
63+
return transform3_t{t, x_axis, vector::normalize(z_axis)};
64+
};
6465

65-
collection.resize(collection.capacity());
66-
std::ranges::generate(collection, rand_obj);
66+
collection.resize(collection.capacity());
67+
std::ranges::generate(collection, rand_obj);
6768
}
6869

6970
/// Fill a @c std::array based matrix with random values
7071
template <concepts::matrix matrix_t>
7172
inline void fill_random_matrix(std::vector<matrix_t> &collection) {
7273

73-
using scalar_t = typename matrix_t::value_type::value_type;
74+
using scalar_t = typename matrix_t::value_type::value_type;
7475

75-
// Generate a random, but valid affine transformation
76-
std::random_device rd;
77-
std::mt19937 mt(rd());
78-
std::uniform_real_distribution<scalar_t> dist(0.f, 1.f);
79-
auto rand_obj = [&]() {
80-
matrix_t m;
76+
// Generate a random, but valid affine transformation
77+
std::random_device rd;
78+
std::mt19937 mt(rd());
79+
std::uniform_real_distribution<scalar_t> dist(0.f, 1.f);
80+
auto rand_obj = [&]() {
81+
matrix_t m;
8182

82-
for (std::size_t j = 0u; j < m.size(); ++j) {
83-
for (std::size_t i = 0u; i < m[0].size(); ++i) {
84-
m[j][i] = dist(mt);
85-
}
86-
}
83+
for (std::size_t j = 0u; j < m.size(); ++j) {
84+
for (std::size_t i = 0u; i < m[0].size(); ++i) {
85+
m[j][i] = dist(mt);
86+
}
87+
}
8788

88-
return m;
89-
};
89+
return m;
90+
};
9091

91-
collection.resize(collection.capacity());
92-
std::ranges::generate(collection, rand_obj);
92+
collection.resize(collection.capacity());
93+
std::ranges::generate(collection, rand_obj);
9394
}
9495

9596
} // namespace algebra

benchmarks/algebra/include/algebra/common/benchmark_base.hpp

Lines changed: 66 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -18,71 +18,72 @@ namespace algebra {
1818

1919
/// Base type for linear algebra benchmarks with google benchmark
2020
struct benchmark_base {
21-
/// Local configuration type
22-
struct configuration {
23-
/// Size of data sample to be used in benchmark
24-
std::size_t m_samples{100u};
25-
// Sleep after building data sample
26-
bool m_sleep = false;
27-
// Number of seconds to sleep
28-
std::size_t m_n_sleep{1u};
29-
30-
/// Setters
31-
/// @{
32-
configuration& n_samples(std::size_t n) {
33-
m_samples = n;
34-
return *this;
35-
}
36-
configuration& do_sleep(bool b) {
37-
m_sleep = b;
38-
return *this;
39-
}
40-
configuration& n_sleep(std::size_t n) {
41-
m_n_sleep = n;
42-
m_sleep = true;
43-
return *this;
44-
}
45-
/// @}
46-
47-
/// Getters
48-
/// @{
49-
std::size_t n_samples() const { return m_samples; }
50-
constexpr bool do_sleep() const { return m_sleep; }
51-
constexpr std::size_t n_sleep() const { return m_n_sleep; }
52-
/// @}
53-
54-
/// Print configuration
55-
friend std::ostream& operator<<(std::ostream& os,
56-
const benchmark_base::configuration& cfg) {
57-
os << " -> running:\t " << cfg.n_samples() << " samples" << std::endl;
58-
if (cfg.do_sleep()) {
59-
os << " -> cool down:\t " << cfg.n_sleep() << "s" << std::endl;
60-
}
61-
os << std::endl;
62-
return os;
63-
}
64-
};
65-
66-
/// The benchmark configuration
67-
configuration m_cfg{};
68-
69-
/// Default construction
70-
benchmark_base() = default;
71-
72-
/// Construct from an externally provided configuration @param cfg
73-
explicit benchmark_base(configuration cfg) : m_cfg{cfg} {}
74-
75-
/// @returns the benchmark configuration
76-
configuration& config() { return m_cfg; }
77-
78-
/// Default destructor
79-
virtual ~benchmark_base() = default;
80-
81-
/// @returns the benchmark name
82-
virtual constexpr std::string name() const = 0;
83-
84-
/// Benchmark case
85-
virtual void operator()(::benchmark::State&) const = 0;
21+
/// Local configuration type
22+
struct configuration {
23+
/// Size of data sample to be used in benchmark
24+
std::size_t m_samples{100u};
25+
// Sleep after building data sample
26+
bool m_sleep = false;
27+
// Number of seconds to sleep
28+
std::size_t m_n_sleep{1u};
29+
30+
/// Setters
31+
/// @{
32+
configuration& n_samples(std::size_t n) {
33+
m_samples = n;
34+
return *this;
35+
}
36+
configuration& do_sleep(bool b) {
37+
m_sleep = b;
38+
return *this;
39+
}
40+
configuration& n_sleep(std::size_t n) {
41+
m_n_sleep = n;
42+
m_sleep = true;
43+
return *this;
44+
}
45+
/// @}
46+
47+
/// Getters
48+
/// @{
49+
std::size_t n_samples() const { return m_samples; }
50+
constexpr bool do_sleep() const { return m_sleep; }
51+
constexpr std::size_t n_sleep() const { return m_n_sleep; }
52+
/// @}
53+
54+
/// Print configuration
55+
friend std::ostream& operator<<(
56+
std::ostream& os, const benchmark_base::configuration& cfg) {
57+
os << " -> running:\t " << cfg.n_samples() << " samples"
58+
<< std::endl;
59+
if (cfg.do_sleep()) {
60+
os << " -> cool down:\t " << cfg.n_sleep() << "s" << std::endl;
61+
}
62+
os << std::endl;
63+
return os;
64+
}
65+
};
66+
67+
/// The benchmark configuration
68+
configuration m_cfg{};
69+
70+
/// Default construction
71+
benchmark_base() = default;
72+
73+
/// Construct from an externally provided configuration @param cfg
74+
explicit benchmark_base(configuration cfg) : m_cfg{cfg} {}
75+
76+
/// @returns the benchmark configuration
77+
configuration& config() { return m_cfg; }
78+
79+
/// Default destructor
80+
virtual ~benchmark_base() = default;
81+
82+
/// @returns the benchmark name
83+
virtual constexpr std::string name() const = 0;
84+
85+
/// Benchmark case
86+
virtual void operator()(::benchmark::State&) const = 0;
8687
};
8788

8889
} // namespace algebra

0 commit comments

Comments
 (0)