From 03faa623a6c00c919e57fa7f2b8e8afe37e486b4 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Wed, 3 Jul 2024 16:37:04 -0700 Subject: [PATCH] Change SetValue() return type to void --- include/sleipnir/autodiff/Variable.hpp | 3 +-- include/sleipnir/autodiff/VariableBlock.hpp | 8 ++------ include/sleipnir/autodiff/VariableMatrix.hpp | 4 +--- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/include/sleipnir/autodiff/Variable.hpp b/include/sleipnir/autodiff/Variable.hpp index 80e9d993..b176d91d 100644 --- a/include/sleipnir/autodiff/Variable.hpp +++ b/include/sleipnir/autodiff/Variable.hpp @@ -62,7 +62,7 @@ class SLEIPNIR_DLLEXPORT Variable { * * @param value The value of the Variable. */ - Variable& SetValue(double value) { + void SetValue(double value) { if (expr->IsConstant(0.0)) { expr = detail::MakeExpressionPtr(value); } else { @@ -76,7 +76,6 @@ class SLEIPNIR_DLLEXPORT Variable { } expr->value = value; } - return *this; } /** diff --git a/include/sleipnir/autodiff/VariableBlock.hpp b/include/sleipnir/autodiff/VariableBlock.hpp index faac4219..03a1eb65 100644 --- a/include/sleipnir/autodiff/VariableBlock.hpp +++ b/include/sleipnir/autodiff/VariableBlock.hpp @@ -131,12 +131,10 @@ class VariableBlock { * * @param value Value to assign. */ - VariableBlock& SetValue(double value) { + void SetValue(double value) { Assert(Rows() == 1 && Cols() == 1); (*this)(0, 0).SetValue(value); - - return *this; } /** @@ -165,7 +163,7 @@ class VariableBlock { */ template requires std::same_as - VariableBlock& SetValue(const Eigen::MatrixBase& values) { + void SetValue(const Eigen::MatrixBase& values) { Assert(Rows() == values.rows()); Assert(Cols() == values.cols()); @@ -174,8 +172,6 @@ class VariableBlock { (*this)(row, col).SetValue(values(row, col)); } } - - return *this; } /** diff --git a/include/sleipnir/autodiff/VariableMatrix.hpp b/include/sleipnir/autodiff/VariableMatrix.hpp index a7e89e5d..5fa7e9f4 100644 --- a/include/sleipnir/autodiff/VariableMatrix.hpp +++ b/include/sleipnir/autodiff/VariableMatrix.hpp @@ -200,7 +200,7 @@ class SLEIPNIR_DLLEXPORT VariableMatrix { */ template requires std::same_as - VariableMatrix& SetValue(const Eigen::MatrixBase& values) { + void SetValue(const Eigen::MatrixBase& values) { Assert(Rows() == values.rows()); Assert(Cols() == values.cols()); @@ -209,8 +209,6 @@ class SLEIPNIR_DLLEXPORT VariableMatrix { (*this)(row, col).SetValue(values(row, col)); } } - - return *this; } /**