Skip to content

Commit

Permalink
Fix constructor definitions in demos and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vaithak authored and vgvassilev committed Apr 11, 2024
1 parent bccf0ad commit 99f0b17
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
10 changes: 3 additions & 7 deletions demos/Functor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@ class Equation {
double m_x, m_y;

public:
Equation(double x, double y) : m_x(x), m_y(y) {}
double operator()(double i, double j) {
return m_x*i*j + m_y*i*j;
}
void setX(double x) {
m_x = x;
}
Equation(double x = 0, double y = 0) : m_x(x), m_y(y) {}
double operator()(double i, double j) { return m_x * i * j + m_y * i * j; }
void setX(double x) { m_x = x; }
};

int main() {
Expand Down
2 changes: 1 addition & 1 deletion demos/Jupyter/Intro.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@
" double m_x, m_y;\n",
"\n",
" public:\n",
" Equation(double x, double y) : m_x(x), m_y(y) {}\n",
" Equation(double x = 0, double y = 0) : m_x(x), m_y(y) {}\n",
" double operator()(double i, double j) {\n",
" return m_x*i*j + m_y*i*j;\n",
" }\n",
Expand Down
4 changes: 2 additions & 2 deletions demos/Templates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ template <class T> class Equation {
T m_x, m_y;

public:
Equation(T x, T y) : m_x(x), m_y(y) {}
Equation(T x = 0, T y = 0) : m_x(x), m_y(y) {}
T operator()(T i, T j) { return m_x * i * i + m_y * j * j; }
};

template <> class Equation<long double> {
long double m_x, m_y;

public:
Equation(long double x, long double y) : m_x(x), m_y(y) {}
Equation(long double x = 0, long double y = 0) : m_x(x), m_y(y) {}
long double operator()(long double i, long double j) {
return 2 * m_x * i * i + 2 * m_y * j * j;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/userDocs/source/user/UsingClad.rst
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ An example that demonstrates the differentiation of functors::
double m_x, m_y;
public:
Equation(double x, double y) : m_x(x), m_y(y) {}
Equation(double x = 0, double y = 0) : m_x(x), m_y(y) {}
double operator()(double i, double j) {
return m_x*i*j + m_y*i*j;
}
Expand Down

0 comments on commit 99f0b17

Please sign in to comment.