Skip to content

Commit

Permalink
Replace nested loop in VariableMatrix constructor (#690)
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul authored Jan 17, 2025
1 parent 59d55f1 commit ecdb394
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions include/sleipnir/autodiff/VariableMatrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down

0 comments on commit ecdb394

Please sign in to comment.