Skip to content

Commit 689103a

Browse files
committed
Simplified mapping
1 parent 815a6c9 commit 689103a

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

stan/math/prim/fun/inv_Phi.hpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,35 +76,34 @@ inline double inv_Phi_lambda(double p) {
7676
return 0;
7777
}
7878

79-
double val;
8079
double inner_r;
8180
double pre_mult;
82-
using Vector8d = Eigen::Matrix<double, 8, 1>;
83-
Eigen::Map<const Vector8d> numerator_map(NULL);
84-
Eigen::Map<const Vector8d> denonimator_map(NULL);
81+
const double* num_ptr;
82+
const double* den_ptr;
8583

8684
if (std::fabs(q) <= .425) {
8785
inner_r = .180625 - square(q);
8886
pre_mult = q;
8987

90-
new (&numerator_map) Eigen::Map<const Vector8d>(a, 8);
91-
new (&denonimator_map) Eigen::Map<const Vector8d>(b, 8);
88+
num_ptr = &a[0];
89+
den_ptr = &b[0];
9290
} else {
93-
9491
double temp_r = std::sqrt(-std::log(r));
9592
if (temp_r <= 5.0) {
9693
inner_r = temp_r - 1.6;
97-
new (&numerator_map) Eigen::Map<const Vector8d>(c, 8);
98-
new (&denonimator_map) Eigen::Map<const Vector8d>(d, 8);
94+
num_ptr = &c[0];
95+
den_ptr = &d[0];
9996
} else {
10097
inner_r = temp_r - 5.0;
101-
new (&numerator_map) Eigen::Map<const Vector8d>(e, 8);
102-
new (&denonimator_map) Eigen::Map<const Vector8d>(f, 8);
98+
num_ptr = &e[0];
99+
den_ptr = &f[0];
103100
}
104101
pre_mult = q < 0 ? -1 : 1;
105102
}
106103

107104
Eigen::VectorXd r_pow = pow(inner_r, Eigen::ArrayXd::LinSpaced(8, 0, 7)) / 10.0;
105+
Eigen::Map<const Eigen::VectorXd> numerator_map(num_ptr, 8);
106+
Eigen::Map<const Eigen::VectorXd> denonimator_map(den_ptr, 8);
108107
return pre_mult * (numerator_map.dot(r_pow) * 10.0) / (denonimator_map.dot(r_pow) * 10.0);
109108
}
110109
} // namespace internal

0 commit comments

Comments
 (0)