File: _logit.c.src

package info (click to toggle)
python-scipy 0.18.1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 75,464 kB
  • ctags: 79,406
  • sloc: python: 143,495; cpp: 89,357; fortran: 81,650; ansic: 79,778; makefile: 364; sh: 265
file content (34 lines) | stat: -rw-r--r-- 472 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*-*-c-*-*/

/*
 * ufuncs to compute logit(p) = log(p/(1-p)) and
 * expit(x) = 1/(1+exp(-x))
 */

#include <Python.h>
#include <math.h>

#include "numpy/npy_math.h"
#include "_logit.h"

/*
 * Inner loops for logit and expit
 */

/**begin repeat
 * #type = npy_float, npy_double, npy_longdouble#
 * #c = f,,l#
 */

@type@ logit@c@(@type@ x)
{
    x /= 1 - x;
    return npy_log@c@(x);
}

@type@ expit@c@(@type@ x)
{
    return 1 / (1 + npy_exp@c@(-x));
}

/**end repeat**/