mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
46 lines
2.2 KiB
Diff
46 lines
2.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Tyler Veness <calcmogul@gmail.com>
|
|
Date: Sat, 8 Feb 2025 13:42:36 -0800
|
|
Subject: [PATCH 5/9] Replace std::views::zip()
|
|
|
|
---
|
|
include/sleipnir/autodiff/gradient_expression_graph.hpp | 5 ++++-
|
|
include/sleipnir/optimization/problem.hpp | 8 +++++---
|
|
2 files changed, 9 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/include/sleipnir/autodiff/gradient_expression_graph.hpp b/include/sleipnir/autodiff/gradient_expression_graph.hpp
|
|
index 414b98971580a6e3209eabfffd082de1dd5711c7..d21c1b5ad1b2f79ac4ec4e525e9b7fe7789a0461 100644
|
|
--- a/include/sleipnir/autodiff/gradient_expression_graph.hpp
|
|
+++ b/include/sleipnir/autodiff/gradient_expression_graph.hpp
|
|
@@ -161,7 +161,10 @@ class GradientExpressionGraph {
|
|
}
|
|
}
|
|
} else {
|
|
- for (const auto& [col, node] : std::views::zip(m_col_list, m_top_list)) {
|
|
+ for (size_t i = 0; i < m_top_list.size(); ++i) {
|
|
+ const auto& col = m_col_list[i];
|
|
+ const auto& node = m_top_list[i];
|
|
+
|
|
// Append adjoints of wrt to sparse matrix triplets
|
|
if (col != -1 && node->adjoint != Scalar(0)) {
|
|
triplets.emplace_back(row, col, node->adjoint);
|
|
diff --git a/include/sleipnir/optimization/problem.hpp b/include/sleipnir/optimization/problem.hpp
|
|
index 22e7cdaa945648e2b9effcc30533d6602c839c22..70955fdc7148e5af737d3094a5602024df790b3d 100644
|
|
--- a/include/sleipnir/optimization/problem.hpp
|
|
+++ b/include/sleipnir/optimization/problem.hpp
|
|
@@ -675,9 +675,11 @@ class Problem {
|
|
for (const auto& constraint : constraints) {
|
|
++counts[static_cast<uint8_t>(constraint.type())];
|
|
}
|
|
- for (const auto& [count, name] :
|
|
- std::views::zip(counts, std::array{"empty", "constant", "linear",
|
|
- "quadratic", "nonlinear"})) {
|
|
+ for (size_t i = 0; i < counts.size(); ++i) {
|
|
+ constexpr std::array names{"empty", "constant", "linear",
|
|
+ "quadratic", "nonlinear"};
|
|
+ const auto& count = counts[i];
|
|
+ const auto& name = names[i];
|
|
if (count > 0) {
|
|
slp::println(" ↳ {} {}", count, name);
|
|
}
|