Skip to content

Commit baae551

Browse files
SteveBronderstan-buildbotWardBrian
authored
Encapsulate std::complex functions (#3122)
* testing encapsulation of std complex * fix all headers in rev * add docs for all new functions * fix conj * fix complex conj * [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 * fix double header includes * fix docs * update fwd includes * update includes for fwd to always prefer fwd version before prim version. * update includes for fwd to always prefer fwd version before prim version. * Docstring duplication and edits * update header includes * [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 * update header includes * fix headers * update headers * [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 * cpplint fix --------- Co-authored-by: Stan Jenkins <mc.stanislaw@gmail.com> Co-authored-by: Brian Ward <bward@flatironinstitute.org>
1 parent 4a812be commit baae551

281 files changed

Lines changed: 1240 additions & 782 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

stan/math/fwd/fun/Phi.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include <stan/math/fwd/meta.hpp>
55
#include <stan/math/fwd/core.hpp>
6+
#include <stan/math/fwd/fun/pow.hpp>
7+
#include <stan/math/fwd/fun/exp.hpp>
68
#include <stan/math/prim/fun/constants.hpp>
79
#include <stan/math/prim/fun/Phi.hpp>
810
#include <cmath>
@@ -12,8 +14,6 @@ namespace math {
1214

1315
template <typename T>
1416
inline fvar<T> Phi(const fvar<T>& x) {
15-
using std::exp;
16-
using std::sqrt;
1717
T xv = x.val_;
1818
return fvar<T>(Phi(xv), x.d_ * exp(xv * xv / -2.0) * INV_SQRT_TWO_PI);
1919
}

stan/math/fwd/fun/Phi_approx.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
#include <stan/math/fwd/meta.hpp>
55
#include <stan/math/fwd/core.hpp>
6-
#include <stan/math/prim/fun/inv_logit.hpp>
6+
#include <stan/math/fwd/fun/inv_logit.hpp>
7+
#include <stan/math/fwd/fun/pow.hpp>
8+
#include <stan/math/prim/fun/Phi_approx.hpp>
79
#include <cmath>
810

911
namespace stan {
@@ -21,7 +23,6 @@ namespace math {
2123
*/
2224
template <typename T>
2325
inline fvar<T> Phi_approx(const fvar<T>& x) {
24-
using std::pow;
2526
return inv_logit(0.07056 * pow(x, 3.0) + 1.5976 * x);
2627
}
2728

stan/math/fwd/fun/abs.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
#include <stan/math/fwd/meta.hpp>
55
#include <stan/math/fwd/core.hpp>
6-
#include <stan/math/prim/fun/abs.hpp>
6+
#include <stan/math/fwd/fun/value_of.hpp>
77
#include <stan/math/prim/fun/constants.hpp>
8-
#include <stan/math/prim/fun/value_of.hpp>
8+
#include <stan/math/prim/fun/abs.hpp>
99
#include <complex>
1010

1111
namespace stan {

stan/math/fwd/fun/acos.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
#include <stan/math/fwd/core.hpp>
55
#include <stan/math/fwd/meta.hpp>
6-
#include <stan/math/prim/fun/square.hpp>
6+
#include <stan/math/fwd/fun/sqrt.hpp>
7+
#include <stan/math/fwd/fun/square.hpp>
78
#include <stan/math/prim/fun/acos.hpp>
89
#include <cmath>
910
#include <complex>
@@ -13,8 +14,6 @@ namespace math {
1314

1415
template <typename T>
1516
inline fvar<T> acos(const fvar<T>& x) {
16-
using std::acos;
17-
using std::sqrt;
1817
return fvar<T>(acos(x.val_), x.d_ / -sqrt(1 - square(x.val_)));
1918
}
2019

stan/math/fwd/fun/acosh.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
#include <stan/math/fwd/meta.hpp>
55
#include <stan/math/fwd/core.hpp>
6+
#include <stan/math/fwd/fun/sqrt.hpp>
7+
#include <stan/math/fwd/fun/square.hpp>
68
#include <stan/math/prim/fun/acosh.hpp>
7-
#include <stan/math/prim/fun/square.hpp>
8-
#include <stan/math/prim/fun/sqrt.hpp>
99
#include <cmath>
1010
#include <complex>
1111

@@ -14,7 +14,6 @@ namespace math {
1414

1515
template <typename T>
1616
inline fvar<T> acosh(const fvar<T>& x) {
17-
using std::sqrt;
1817
return fvar<T>(acosh(x.val_), x.d_ / sqrt(square(x.val_) - 1));
1918
}
2019

stan/math/fwd/fun/asin.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
#include <stan/math/fwd/meta.hpp>
55
#include <stan/math/fwd/core.hpp>
6+
#include <stan/math/fwd/fun/sqrt.hpp>
7+
#include <stan/math/fwd/fun/square.hpp>
68
#include <stan/math/prim/fun/asin.hpp>
7-
#include <stan/math/prim/fun/square.hpp>
89
#include <cmath>
910
#include <complex>
1011

@@ -13,8 +14,6 @@ namespace math {
1314

1415
template <typename T>
1516
inline fvar<T> asin(const fvar<T>& x) {
16-
using std::asin;
17-
using std::sqrt;
1817
return fvar<T>(asin(x.val_), x.d_ / sqrt(1 - square(x.val_)));
1918
}
2019

stan/math/fwd/fun/asinh.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
#include <stan/math/fwd/core.hpp>
55
#include <stan/math/fwd/meta.hpp>
6+
#include <stan/math/fwd/fun/sqrt.hpp>
7+
#include <stan/math/fwd/fun/square.hpp>
68
#include <stan/math/prim/fun/asinh.hpp>
7-
#include <stan/math/prim/fun/square.hpp>
89
#include <cmath>
910
#include <complex>
1011

@@ -13,7 +14,6 @@ namespace math {
1314

1415
template <typename T>
1516
inline fvar<T> asinh(const fvar<T>& x) {
16-
using std::sqrt;
1717
return fvar<T>(asinh(x.val_), x.d_ / sqrt(square(x.val_) + 1));
1818
}
1919

stan/math/fwd/fun/atan.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
#include <stan/math/fwd/core.hpp>
55
#include <stan/math/fwd/meta.hpp>
6+
#include <stan/math/fwd/fun/atanh.hpp>
7+
#include <stan/math/fwd/fun/square.hpp>
68
#include <stan/math/prim/fun/atan.hpp>
7-
#include <stan/math/prim/fun/square.hpp>
89
#include <cmath>
910
#include <complex>
1011

@@ -13,7 +14,6 @@ namespace math {
1314

1415
template <typename T>
1516
inline fvar<T> atan(const fvar<T>& x) {
16-
using std::atan;
1717
return fvar<T>(atan(x.val_), x.d_ / (1 + square(x.val_)));
1818
}
1919

stan/math/fwd/fun/atan2.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,28 @@
33

44
#include <stan/math/fwd/meta.hpp>
55
#include <stan/math/fwd/core.hpp>
6-
#include <stan/math/prim/fun/square.hpp>
6+
#include <stan/math/fwd/fun/square.hpp>
7+
#include <stan/math/prim/fun/atan2.hpp>
78
#include <cmath>
89

910
namespace stan {
1011
namespace math {
1112

1213
template <typename T>
1314
inline fvar<T> atan2(const fvar<T>& x1, const fvar<T>& x2) {
14-
using std::atan2;
1515
return fvar<T>(atan2(x1.val_, x2.val_),
1616
(x1.d_ * x2.val_ - x1.val_ * x2.d_)
1717
/ (square(x2.val_) + square(x1.val_)));
1818
}
1919

2020
template <typename T>
2121
inline fvar<T> atan2(double x1, const fvar<T>& x2) {
22-
using std::atan2;
2322
return fvar<T>(atan2(x1, x2.val_),
2423
(-x1 * x2.d_) / (square(x1) + square(x2.val_)));
2524
}
2625

2726
template <typename T>
2827
inline fvar<T> atan2(const fvar<T>& x1, double x2) {
29-
using std::atan2;
3028
return fvar<T>(atan2(x1.val_, x2),
3129
(x1.d_ * x2) / (square(x2) + square(x1.val_)));
3230
}

stan/math/fwd/fun/atanh.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33

44
#include <stan/math/fwd/core.hpp>
55
#include <stan/math/fwd/meta.hpp>
6+
#include <stan/math/fwd/fun/log.hpp>
7+
#include <stan/math/fwd/fun/square.hpp>
8+
#include <stan/math/fwd/fun/value_of_rec.hpp>
69
#include <stan/math/prim/fun/atanh.hpp>
7-
#include <stan/math/prim/fun/square.hpp>
810
#include <cmath>
911
#include <complex>
1012

0 commit comments

Comments
 (0)