MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / erfcinv

Function erfcinv

dnn/src/common/elemwise/erfinv.h:271–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269}
270
271inline double erfcinv(double z) {
272 //
273 // Begin by testing for domain errors, and other special cases:
274 //
275 if ((z < 0) || (z > 2))
276 return NAN;
277 if (z == 0)
278 return INFINITY;
279 if (z == 2)
280 return -INFINITY;
281 //
282 // Normalise the input, so it's in the range [0,1], we will
283 // negate the result if z is outside that range. This is a simple
284 // application of the erfc reflection formula: erfc(-z) = 2 - erfc(z)
285 //
286 double p, q, s;
287 if (z > 1) {
288 q = 2 - z;
289 p = 1 - q;
290 s = -1;
291 } else {
292 p = 1 - z;
293 q = z;
294 s = 1;
295 }
296
297 //
298 // And get the result, negating where required:
299 //
300 return s * erfinv_imp(p, q);
301}
302
303inline double erfinv(double z) {
304 //

Callers 1

erfcinvfFunction · 0.70

Calls 1

erfinv_impFunction · 0.70

Tested by

no test coverage detected