@@ -84,7 +84,7 @@ requires std::invocable<unaryOP, vector_t<scalar_t>> struct vector_unaryOP_bm
8484 // Run the benchmark
8585 for (auto _ : state) {
8686 for (std::size_t i{0 }; i < n_samples; ++i) {
87- const result_t result = unaryOP{}(this ->a [i]);
87+ result_t result = unaryOP{}(this ->a [i]);
8888 ::benchmark::DoNotOptimize (result);
8989 }
9090 }
@@ -119,7 +119,7 @@ requires std::invocable<binaryOP, vector_t<scalar_t>,
119119 // Run the benchmark
120120 for (auto _ : state) {
121121 for (std::size_t i{0 }; i < n_samples; ++i) {
122- const result_t result = binaryOP{}(this ->a [i], this ->b [i]);
122+ result_t result = binaryOP{}(this ->a [i], this ->b [i]);
123123 ::benchmark::DoNotOptimize (result);
124124 }
125125 }
@@ -132,48 +132,49 @@ namespace bench_op {
132132struct add {
133133 inline static const std::string name{" add" };
134134 template <concepts::vector vector_t >
135- auto operator ()(const vector_t &a, const vector_t &b) const {
135+ vector_t operator ()(const vector_t &a, const vector_t &b) const {
136136 return a + b;
137137 }
138138};
139139struct sub {
140140 inline static const std::string name{" sub" };
141141 template <concepts::vector vector_t >
142- auto operator ()(const vector_t &a, const vector_t &b) const {
142+ vector_t operator ()(const vector_t &a, const vector_t &b) const {
143143 return a - b;
144144 }
145145};
146146struct dot {
147147 inline static const std::string name{" dot" };
148148 template <concepts::vector vector_t >
149- auto operator ()(const vector_t &a, const vector_t &b) const {
149+ algebra::traits::scalar_t <vector_t > operator ()(const vector_t &a,
150+ const vector_t &b) const {
150151 return algebra::vector::dot (a, b);
151152 }
152153};
153154struct cross {
154155 inline static const std::string name{" cross" };
155156 template <concepts::vector vector_t >
156- auto operator ()(const vector_t &a, const vector_t &b) const {
157+ vector_t operator ()(const vector_t &a, const vector_t &b) const {
157158 return algebra::vector::cross (a, b);
158159 }
159160};
160161
161162// Macro for declaring vector unary ops
162- #define ALGEBRA_PLUGINS_BENCH_VECTOR (OP ) \
163+ #define ALGEBRA_PLUGINS_BENCH_VECTOR (OP, RES ) \
163164 struct OP { \
164165 inline static const std::string name{#OP}; \
165166 template <concepts::vector vector_t > \
166- auto operator ()(const vector_t &a) const { \
167+ RES operator ()(const vector_t &a) const { \
167168 return algebra::vector::OP (a); \
168169 } \
169170 };
170171
171- ALGEBRA_PLUGINS_BENCH_VECTOR (phi)
172- ALGEBRA_PLUGINS_BENCH_VECTOR (theta)
173- ALGEBRA_PLUGINS_BENCH_VECTOR (eta)
174- ALGEBRA_PLUGINS_BENCH_VECTOR (perp)
175- ALGEBRA_PLUGINS_BENCH_VECTOR (norm)
176- ALGEBRA_PLUGINS_BENCH_VECTOR (normalize)
172+ ALGEBRA_PLUGINS_BENCH_VECTOR (phi, algebra::traits:: scalar_t < vector_t > )
173+ ALGEBRA_PLUGINS_BENCH_VECTOR (theta, algebra::traits:: scalar_t < vector_t > )
174+ ALGEBRA_PLUGINS_BENCH_VECTOR (eta, algebra::traits:: scalar_t < vector_t > )
175+ ALGEBRA_PLUGINS_BENCH_VECTOR (perp, algebra::traits:: scalar_t < vector_t > )
176+ ALGEBRA_PLUGINS_BENCH_VECTOR (norm, algebra::traits:: scalar_t < vector_t > )
177+ ALGEBRA_PLUGINS_BENCH_VECTOR (normalize, vector_t )
177178
178179} // namespace bench_op
179180
0 commit comments