Skip to content

Commit

Permalink
Add comment for dependent variable warning
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul committed Dec 15, 2023
1 parent 13b4f01 commit 4220991
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/autodiff/Variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Variable& Variable::SetValue(double value) {
if (detail::IsZero(expr)) {
expr = detail::MakeExpressionPtr(value);
} else {
// We only need to check the first argument since unary and binary operators
// both use it
if (!detail::IsZero(expr->args[0])) {
fmt::print(stderr,
"WARNING: {}:{}: Modified the value of a dependent variable\n",
Expand All @@ -48,6 +50,8 @@ Variable& Variable::SetValue(int value) {
if (detail::IsZero(expr)) {
expr = detail::MakeExpressionPtr(value);
} else {
// We only need to check the first argument since unary and binary operators
// both use it
if (!detail::IsZero(expr->args[0])) {
fmt::print(stderr,
"WARNING: {}:{}: Modified the value of a dependent variable\n",
Expand Down

0 comments on commit 4220991

Please sign in to comment.