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/8] Replace std::views::zip()
|
|
|
|
---
|
|
include/sleipnir/autodiff/adjoint_expression_graph.hpp | 5 ++++-
|
|
include/sleipnir/optimization/problem.hpp | 8 +++++---
|
|
2 files changed, 9 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/include/sleipnir/autodiff/adjoint_expression_graph.hpp b/include/sleipnir/autodiff/adjoint_expression_graph.hpp
|
|
index 16bea7efeeca78d25b34b0b1242ca19cbd05a482..a77323eee9277fc3c77a11ab57ab5003d9ed4543 100644
|
|
--- a/include/sleipnir/autodiff/adjoint_expression_graph.hpp
|
|
+++ b/include/sleipnir/autodiff/adjoint_expression_graph.hpp
|
|
@@ -171,7 +171,10 @@ class AdjointExpressionGraph {
|
|
}
|
|
}
|
|
} 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 d20777a5b1912754dda5504313549197e867d34b..5256d08e5f9d8642049d8bb8323d76c7b3bbbef7 100644
|
|
--- a/include/sleipnir/optimization/problem.hpp
|
|
+++ b/include/sleipnir/optimization/problem.hpp
|
|
@@ -726,9 +726,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);
|
|
}
|