From ecdb394ec0d9a7bdf699e72ff0a9b7e9fd5e7d39 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Fri, 17 Jan 2025 10:51:31 -0800 Subject: [PATCH] Replace nested loop in VariableMatrix constructor (#690) --- include/sleipnir/autodiff/VariableMatrix.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/sleipnir/autodiff/VariableMatrix.hpp b/include/sleipnir/autodiff/VariableMatrix.hpp index 6f8c30d4..3458a9c4 100644 --- a/include/sleipnir/autodiff/VariableMatrix.hpp +++ b/include/sleipnir/autodiff/VariableMatrix.hpp @@ -52,10 +52,8 @@ class SLEIPNIR_DLLEXPORT VariableMatrix { */ VariableMatrix(int rows, int cols) : m_rows{rows}, m_cols{cols} { m_storage.reserve(Rows() * Cols()); - for (int row = 0; row < Rows(); ++row) { - for (int col = 0; col < Cols(); ++col) { - m_storage.emplace_back(); - } + for (int index = 0; index < Rows() * Cols(); ++index) { + m_storage.emplace_back(); } }