clad icon indicating copy to clipboard operation
clad copied to clipboard

Same variable redefinition in gradient when different loops have the same counter variable name

Open parth-07 opened this issue 1 year ago • 2 comments

Gradient function contains variable redefinition error when different loops have the same counter variable name.

Reproducible example:

#include "clad/Differentiator/Differentiator.h"

double fn(double u, double v) {
    double res = 0;
    for (int i = 0; i < 5; ++i) {
      res += i;
    }
    for (int i = 0; i < 5; ++i) {
      res += i;
    }
    return res;
}

int main() {
    auto fn_grad = clad::gradient(fn);
}

_d_i is defined two times in the gradient function fn_grad.

parth-07 avatar Dec 09 '23 15:12 parth-07

Hii! I would like to work on this issue. KIndly assign it to me.

muskangupta-02 avatar Mar 29 '24 11:03 muskangupta-02

Hi @muskangupta-02, Please feel free to raise a pull-request for this issue.

parth-07 avatar Mar 29 '24 13:03 parth-07