Skip to content
Snippets Groups Projects
Commit b78e2d90 authored by Olivier BICHLER's avatar Olivier BICHLER
Browse files

Improved coding

parent 7230dae2
No related branches found
No related tags found
2 merge requests!710.4.0,!55Improved elemwise and matmul to be fully templated
......@@ -11,12 +11,12 @@ void erf_forward (
const Input_T* __restrict inputs,
Output_T* __restrict outputs)
{
double a1 = 0.254829592;
double a2 = -0.284496736;
double a3 = 1.421413741;
double a4 = -1.453152027;
double a5 = 1.061405429;
double p = 0.3275911;
constexpr double a1 = 0.254829592;
constexpr double a2 = -0.284496736;
constexpr double a3 = 1.421413741;
constexpr double a4 = -1.453152027;
constexpr double a5 = 1.061405429;
constexpr double p = 0.3275911;
#ifdef _OPENMP
#pragma omp parallel for
......@@ -25,11 +25,11 @@ void erf_forward (
int sign = 1;
if (inputs[i] < 0)
sign = -1;
double abs_value = abs(inputs[i]);
const double abs_value = abs(inputs[i]);
// A&S formula 7.1.26
double t = 1.0/(1.0 + p*abs_value);
double y = 1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-abs_value*abs_value);
const double t = 1.0/(1.0 + p*abs_value);
const double y = 1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-abs_value*abs_value);
outputs[i] = sign*y;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment