Clang-format tests, examples, libraries, benchmarks, etc.

This commit is contained in:
Antonio Sánchez
2023-12-05 21:22:55 +00:00
committed by Rasmus Munk Larsen
parent 3252ecc7a4
commit 46e9cdb7fe
876 changed files with 33453 additions and 37795 deletions

View File

@@ -16,23 +16,20 @@
#include <utility>
template <typename MatrixType>
void copy_matrix(MatrixType& m)
{
void copy_matrix(MatrixType& m) {
MatrixType tmp(m);
m = tmp;
}
template <typename MatrixType>
void move_matrix(MatrixType&& m)
{
void move_matrix(MatrixType&& m) {
MatrixType tmp(std::move(m));
m = std::move(tmp);
}
template<typename Scalar>
void bench(const std::string& label)
{
using MatrixType = Eigen::Matrix<Eigen::MovableScalar<Scalar>,1,10>;
template <typename Scalar>
void bench(const std::string& label) {
using MatrixType = Eigen::Matrix<Eigen::MovableScalar<Scalar>, 1, 10>;
Eigen::BenchTimer t;
int tries = 10;
@@ -42,16 +39,14 @@ void bench(const std::string& label)
MatrixType dest;
BENCH(t, tries, rep, copy_matrix(data));
std::cout << label << " copy semantics: " << 1e3*t.best(Eigen::CPU_TIMER) << " ms" << std::endl;
std::cout << label << " copy semantics: " << 1e3 * t.best(Eigen::CPU_TIMER) << " ms" << std::endl;
BENCH(t, tries, rep, move_matrix(std::move(data)));
std::cout << label << " move semantics: " << 1e3*t.best(Eigen::CPU_TIMER) << " ms" << std::endl;
std::cout << label << " move semantics: " << 1e3 * t.best(Eigen::CPU_TIMER) << " ms" << std::endl;
}
int main()
{
int main() {
bench<float>("float");
bench<double>("double");
return 0;
}