summaryrefslogtreecommitdiff
path: root/numpy/core/src/scalarmathmodule.c.src
blob: ec210d42e9aa04e24a766eb77d58d5e7d254e49d (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* The purpose of this module is to add faster math for array scalars
    that does not go through the ufunc machinery

    NOT FINISHED
 */

#include "numpy/arrayobject.h"
#include "numpy/ufuncobject.h"


/**begin repeat
name=bool,

**/
static PyNumberMethods @name@_as_number = {
        (binaryfunc)@name@_add,                    /*nb_add*/
        (binaryfunc)@name@_subtract,               /*nb_subtract*/
        (binaryfunc)@name@_multiply,               /*nb_multiply*/
        (binaryfunc)@name@_divide,                 /*nb_divide*/
        (binaryfunc)@name@_remainder,              /*nb_remainder*/
        (binaryfunc)@name@_divmod,                 /*nb_divmod*/
        (ternaryfunc)@name@_power,                 /*nb_power*/
        (unaryfunc)@name@_negative,
        (unaryfunc)@name@_copy,                    /*nb_pos*/
        (unaryfunc)@name@_absolute,                /*nb_abs*/
        (inquiry)@name@_nonzero_number,            /*nb_nonzero*/
        (unaryfunc)@name@_invert,                  /*nb_invert*/
        (binaryfunc)@name@_lshift,                /*nb_lshift*/
        (binaryfunc)@name@_rshift,                /*nb_rshift*/
        (binaryfunc)@name@_and,                  /*nb_and*/
        (binaryfunc)@name@_xor,                  /*nb_xor*/
        (binaryfunc)@name@_or,                   /*nb_or*/
        0,                                      /*nb_coerce*/
        (unaryfunc)@name@_int,                   /*nb_int*/
        (unaryfunc)@name@_long,                  /*nb_long*/
        (unaryfunc)@name@_float,                 /*nb_float*/
        (unaryfunc)@name@_oct,                   /*nb_oct*/
        (unaryfunc)@name@_hex,                  /*nb_hex*/
        0,                                     /*inplace_add*/
        0,                                     /*inplace_subtract*/
        0,                                     /*inplace_multiply*/
        0,                                     /*inplace_divide*/
        0,                                    /*inplace_remainder*/
        0,                              /*inplace_power*/
        0,                            /*inplace_lshift*/
        0,                            /*inplace_rshift*/
        0,                            /*inplace_and*/
        0,                            /*inplace_xor*/
        0,                            /*inplace_or*/
        (binaryfunc)@name@_floor_divide,            /*nb_floor_divide*/
        (binaryfunc)@name@_true_divide,             /*nb_true_divide*/
        0,                                         /*nb_inplace_floor_divide*/
        0,                                         /*nb_inplace_true_divide*/

};

/**end repeat**/


/**begin repeat

**/

static PyObject*
@name@_richcompare(PyObject *self, PyObject *other, int cmp_op)
{
}
/**end repeat**/



static void
add_scalarmath(void)
{
/**begin repeat
name=bool,
NAME=Bool
**/
	PyArr@NAME@Type_Type.tp_as_number = @name@_as_number;
	PyArr@NAME@Type_Type.tp_richcompare = @name@_richcompare;
/**end repeat**/
}



static struct PyMethodDef methods[] = {
	{"alter_pyscalars", (PyCFunction) alter_pyscalars,
	 METH_VARARGS , doc_alterpyscalars},
	{NULL, NULL, 0}
};

DL_EXPORT(void) initscalarmath(void) {
	PyObject *m;

	m = Py_initModule("scalarmath", methods);
	
	if (import_array() < 0) return;
	if (import_umath() < 0) return;

	add_scalarmath();
	
	return;
}