Sharedwww / talks / pyrex / mult2.cOpen in CoCalc
Author: William A. Stein
1
/* Generated by Pyrex 0.9.3 on Thu Nov 11 15:16:11 2004 */
2
3
#include "Python.h"
4
#include "structmember.h"
5
#ifndef PY_LONG_LONG
6
#define PY_LONG_LONG LONG_LONG
7
#endif
8
9
10
typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
11
typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
12
static PyObject *__Pyx_UnpackItem(PyObject *, int); /*proto*/
13
static int __Pyx_EndUnpack(PyObject *, int); /*proto*/
14
static int __Pyx_PrintItem(PyObject *); /*proto*/
15
static int __Pyx_PrintNewline(void); /*proto*/
16
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
17
static void __Pyx_ReRaise(void); /*proto*/
18
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
19
static PyObject *__Pyx_GetExcValue(void); /*proto*/
20
static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name); /*proto*/
21
static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
22
static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], int nargs, PyObject **args2, PyObject **kwds2); /*proto*/
23
static void __Pyx_WriteUnraisable(char *name); /*proto*/
24
static void __Pyx_AddTraceback(char *funcname); /*proto*/
25
static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/
26
static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
27
static int __Pyx_GetVtable(PyObject *dict, void *vtabptr); /*proto*/
28
static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/
29
static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/
30
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
31
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
32
33
static PyObject *__pyx_m;
34
static PyObject *__pyx_b;
35
static int __pyx_lineno;
36
static char *__pyx_filename;
37
staticforward char **__pyx_f;
38
39
static char __pyx_mdoc[] = "\nBuild as follows:\n\n# pyrex mult2.pyx\n# ls -lh mult2.c\n-rw-r--r-- 1 was was 28K Nov 11 14:09 mult2.c\n# gcc -shared -O3 -fPIC -I/home/was/local/include/python2.4 mult2.c -o mult2.so\n-rwxr-xr-x 1 was was 21K Nov 11 14:13 mult2.so\n\n(Your Python include directory is probably different than mine.)\n";
40
41
/* Declarations from mult2 */
42
43
staticforward PyTypeObject __pyx_type_5mult2_Matrix;
44
45
struct __pyx_obj_5mult2_Matrix {
46
PyObject_HEAD
47
struct __pyx_vtabstruct_5mult2_Matrix *__pyx_vtab;
48
int (*entries);
49
int p;
50
int n;
51
};
52
53
struct __pyx_vtabstruct_5mult2_Matrix {
54
struct __pyx_obj_5mult2_Matrix *((*__mul__)(struct __pyx_obj_5mult2_Matrix *,struct __pyx_obj_5mult2_Matrix *));
55
};
56
static struct __pyx_vtabstruct_5mult2_Matrix *__pyx_vtabptr_5mult2_Matrix;
57
58
static PyTypeObject *__pyx_ptype_5mult2_Matrix = 0;
59
static PyObject *__pyx_k1;
60
static PyObject *__pyx_k2;
61
62
/* Implementation of mult2 */
63
64
static int __pyx_f_5mult2_6Matrix___new__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
65
static int __pyx_f_5mult2_6Matrix___new__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
66
int __pyx_v_p;
67
int __pyx_v_n;
68
PyObject *__pyx_v_entries = 0;
69
int __pyx_r;
70
static char *__pyx_argnames[] = {"p","n","entries",0};
71
__pyx_v_entries = __pyx_k1;
72
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "ii|O", __pyx_argnames, &__pyx_v_p, &__pyx_v_n, &__pyx_v_entries)) return -1;
73
Py_INCREF(__pyx_v_self);
74
Py_INCREF(__pyx_v_entries);
75
76
/* "/home/was/talks/pyrex/mult2.pyx":22 */
77
((struct __pyx_obj_5mult2_Matrix *)__pyx_v_self)->n = __pyx_v_n;
78
79
/* "/home/was/talks/pyrex/mult2.pyx":23 */
80
((struct __pyx_obj_5mult2_Matrix *)__pyx_v_self)->p = __pyx_v_p;
81
82
/* "/home/was/talks/pyrex/mult2.pyx":24 */
83
((struct __pyx_obj_5mult2_Matrix *)__pyx_v_self)->entries = ((int (*))PyMem_Malloc((((sizeof(int )) * __pyx_v_n) * __pyx_v_n)));
84
85
__pyx_r = 0;
86
goto __pyx_L0;
87
__pyx_L1:;
88
__Pyx_AddTraceback("mult2.Matrix.__new__");
89
__pyx_r = -1;
90
__pyx_L0:;
91
Py_DECREF(__pyx_v_self);
92
Py_DECREF(__pyx_v_entries);
93
return __pyx_r;
94
}
95
96
static void __pyx_f_5mult2_6Matrix___dealloc__(PyObject *__pyx_v_self); /*proto*/
97
static void __pyx_f_5mult2_6Matrix___dealloc__(PyObject *__pyx_v_self) {
98
Py_INCREF(__pyx_v_self);
99
100
/* "/home/was/talks/pyrex/mult2.pyx":27 */
101
PyMem_Free(((struct __pyx_obj_5mult2_Matrix *)__pyx_v_self)->entries);
102
103
goto __pyx_L0;
104
__pyx_L1:;
105
__Pyx_AddTraceback("mult2.Matrix.__dealloc__");
106
__pyx_L0:;
107
Py_DECREF(__pyx_v_self);
108
}
109
110
static int __pyx_f_5mult2_6Matrix___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
111
static char __pyx_doc_5mult2_6Matrix___init__[] = "\n Create a matrix over a finite field.\n INPUT:\n p -- prime\n n -- positive integer\n entries -- entries of the matrix (defaults to None, which means 0 matrix).\n ";
112
static int __pyx_f_5mult2_6Matrix___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
113
int __pyx_v_p;
114
int __pyx_v_n;
115
PyObject *__pyx_v_entries = 0;
116
int __pyx_v_i;
117
int __pyx_v_j;
118
int __pyx_v_k;
119
int __pyx_v_x;
120
int __pyx_r;
121
int __pyx_1;
122
int __pyx_2;
123
PyObject *__pyx_3 = 0;
124
PyObject *__pyx_4 = 0;
125
PyObject *__pyx_5 = 0;
126
int __pyx_6;
127
static char *__pyx_argnames[] = {"p","n","entries",0};
128
__pyx_v_entries = __pyx_k2;
129
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "ii|O", __pyx_argnames, &__pyx_v_p, &__pyx_v_n, &__pyx_v_entries)) return -1;
130
Py_INCREF(__pyx_v_self);
131
Py_INCREF(__pyx_v_entries);
132
133
/* "/home/was/talks/pyrex/mult2.pyx":38 */
134
if (PyObject_Cmp(__pyx_v_entries, Py_None, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;}
135
__pyx_1 = __pyx_1 != 0;
136
if (__pyx_1) {
137
138
/* "/home/was/talks/pyrex/mult2.pyx":39 */
139
__pyx_1 = ((struct __pyx_obj_5mult2_Matrix *)__pyx_v_self)->n;
140
for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {
141
142
/* "/home/was/talks/pyrex/mult2.pyx":40 */
143
__pyx_2 = ((struct __pyx_obj_5mult2_Matrix *)__pyx_v_self)->n;
144
for (__pyx_v_j = 0; __pyx_v_j < __pyx_2; ++__pyx_v_j) {
145
146
/* "/home/was/talks/pyrex/mult2.pyx":41 */
147
__pyx_v_k = ((__pyx_v_i * ((struct __pyx_obj_5mult2_Matrix *)__pyx_v_self)->n) + __pyx_v_j);
148
149
/* "/home/was/talks/pyrex/mult2.pyx":42 */
150
__pyx_3 = PyInt_FromLong(__pyx_v_k); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; goto __pyx_L1;}
151
__pyx_4 = PyObject_GetItem(__pyx_v_entries, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; goto __pyx_L1;}
152
Py_DECREF(__pyx_3); __pyx_3 = 0;
153
__pyx_3 = PyInt_FromLong(__pyx_v_p); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; goto __pyx_L1;}
154
__pyx_5 = PyNumber_Remainder(__pyx_4, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; goto __pyx_L1;}
155
Py_DECREF(__pyx_4); __pyx_4 = 0;
156
Py_DECREF(__pyx_3); __pyx_3 = 0;
157
__pyx_6 = PyInt_AsLong(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; goto __pyx_L1;}
158
Py_DECREF(__pyx_5); __pyx_5 = 0;
159
__pyx_v_x = __pyx_6;
160
161
/* "/home/was/talks/pyrex/mult2.pyx":43 */
162
__pyx_6 = (__pyx_v_x < 0);
163
if (__pyx_6) {
164
__pyx_v_x = (__pyx_v_x + __pyx_v_p);
165
goto __pyx_L7;
166
}
167
__pyx_L7:;
168
169
/* "/home/was/talks/pyrex/mult2.pyx":44 */
170
(((struct __pyx_obj_5mult2_Matrix *)__pyx_v_self)->entries[__pyx_v_k]) = __pyx_v_x;
171
__pyx_L5:;
172
}
173
__pyx_L6:;
174
__pyx_L3:;
175
}
176
__pyx_L4:;
177
goto __pyx_L2;
178
}
179
/*else*/ {
180
181
/* "/home/was/talks/pyrex/mult2.pyx":46 */
182
__pyx_6 = ((struct __pyx_obj_5mult2_Matrix *)__pyx_v_self)->n;
183
for (__pyx_v_i = 0; __pyx_v_i < __pyx_6; ++__pyx_v_i) {
184
185
/* "/home/was/talks/pyrex/mult2.pyx":47 */
186
__pyx_2 = ((struct __pyx_obj_5mult2_Matrix *)__pyx_v_self)->n;
187
for (__pyx_v_j = 0; __pyx_v_j < __pyx_2; ++__pyx_v_j) {
188
189
/* "/home/was/talks/pyrex/mult2.pyx":48 */
190
(((struct __pyx_obj_5mult2_Matrix *)__pyx_v_self)->entries[((__pyx_v_i * ((struct __pyx_obj_5mult2_Matrix *)__pyx_v_self)->n) + __pyx_v_j)]) = 0;
191
__pyx_L10:;
192
}
193
__pyx_L11:;
194
__pyx_L8:;
195
}
196
__pyx_L9:;
197
}
198
__pyx_L2:;
199
200
__pyx_r = 0;
201
goto __pyx_L0;
202
__pyx_L1:;
203
Py_XDECREF(__pyx_3);
204
Py_XDECREF(__pyx_4);
205
Py_XDECREF(__pyx_5);
206
__Pyx_AddTraceback("mult2.Matrix.__init__");
207
__pyx_r = -1;
208
__pyx_L0:;
209
Py_DECREF(__pyx_v_self);
210
Py_DECREF(__pyx_v_entries);
211
return __pyx_r;
212
}
213
214
static PyObject *__pyx_k3p;
215
static PyObject *__pyx_k4p;
216
static PyObject *__pyx_k5p;
217
218
static char (__pyx_k3[]) = "";
219
static char (__pyx_k4[]) = "%s, ";
220
static char (__pyx_k5[]) = "\n";
221
222
static PyObject *__pyx_f_5mult2_6Matrix___repr__(PyObject *__pyx_v_self); /*proto*/
223
static PyObject *__pyx_f_5mult2_6Matrix___repr__(PyObject *__pyx_v_self) {
224
int __pyx_v_i;
225
int __pyx_v_j;
226
int __pyx_v_n;
227
PyObject *__pyx_v_s;
228
PyObject *__pyx_r;
229
PyObject *__pyx_1 = 0;
230
PyObject *__pyx_2 = 0;
231
Py_INCREF(__pyx_v_self);
232
__pyx_v_s = Py_None; Py_INCREF(__pyx_v_s);
233
234
/* "/home/was/talks/pyrex/mult2.pyx":52 */
235
Py_INCREF(__pyx_k3p);
236
Py_DECREF(__pyx_v_s);
237
__pyx_v_s = __pyx_k3p;
238
239
/* "/home/was/talks/pyrex/mult2.pyx":53 */
240
__pyx_v_n = ((struct __pyx_obj_5mult2_Matrix *)__pyx_v_self)->n;
241
242
/* "/home/was/talks/pyrex/mult2.pyx":54 */
243
for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_n; ++__pyx_v_i) {
244
245
/* "/home/was/talks/pyrex/mult2.pyx":55 */
246
for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_n; ++__pyx_v_j) {
247
248
/* "/home/was/talks/pyrex/mult2.pyx":56 */
249
__pyx_1 = PyInt_FromLong((((struct __pyx_obj_5mult2_Matrix *)__pyx_v_self)->entries[((__pyx_v_n * __pyx_v_i) + __pyx_v_j)])); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; goto __pyx_L1;}
250
__pyx_2 = PyNumber_Remainder(__pyx_k4p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; goto __pyx_L1;}
251
Py_DECREF(__pyx_1); __pyx_1 = 0;
252
__pyx_1 = PyNumber_Add(__pyx_v_s, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; goto __pyx_L1;}
253
Py_DECREF(__pyx_2); __pyx_2 = 0;
254
Py_DECREF(__pyx_v_s);
255
__pyx_v_s = __pyx_1;
256
__pyx_1 = 0;
257
__pyx_L4:;
258
}
259
__pyx_L5:;
260
261
/* "/home/was/talks/pyrex/mult2.pyx":57 */
262
__pyx_2 = PyNumber_Add(__pyx_v_s, __pyx_k5p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; goto __pyx_L1;}
263
Py_DECREF(__pyx_v_s);
264
__pyx_v_s = __pyx_2;
265
__pyx_2 = 0;
266
__pyx_L2:;
267
}
268
__pyx_L3:;
269
270
/* "/home/was/talks/pyrex/mult2.pyx":58 */
271
Py_INCREF(__pyx_v_s);
272
__pyx_r = __pyx_v_s;
273
goto __pyx_L0;
274
275
__pyx_r = Py_None; Py_INCREF(__pyx_r);
276
goto __pyx_L0;
277
__pyx_L1:;
278
Py_XDECREF(__pyx_1);
279
Py_XDECREF(__pyx_2);
280
__Pyx_AddTraceback("mult2.Matrix.__repr__");
281
__pyx_r = 0;
282
__pyx_L0:;
283
Py_DECREF(__pyx_v_s);
284
Py_DECREF(__pyx_v_self);
285
return __pyx_r;
286
}
287
288
static struct __pyx_obj_5mult2_Matrix *__pyx_f_5mult2_6Matrix___mul__(struct __pyx_obj_5mult2_Matrix *__pyx_v_self,struct __pyx_obj_5mult2_Matrix *__pyx_v_B) {
289
int __pyx_v_s;
290
int __pyx_v_i;
291
int __pyx_v_j;
292
int __pyx_v_k;
293
int __pyx_v_n;
294
struct __pyx_obj_5mult2_Matrix *__pyx_v_ans;
295
struct __pyx_obj_5mult2_Matrix *__pyx_r;
296
PyObject *__pyx_1 = 0;
297
PyObject *__pyx_2 = 0;
298
PyObject *__pyx_3 = 0;
299
int __pyx_4;
300
Py_INCREF(__pyx_v_self);
301
Py_INCREF(__pyx_v_B);
302
((PyObject*)__pyx_v_ans) = Py_None; Py_INCREF(((PyObject*)__pyx_v_ans));
303
304
/* "/home/was/talks/pyrex/mult2.pyx":63 */
305
__pyx_1 = PyInt_FromLong(__pyx_v_self->p); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;}
306
__pyx_2 = PyInt_FromLong(__pyx_v_self->n); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;}
307
__pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;}
308
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
309
PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);
310
__pyx_1 = 0;
311
__pyx_2 = 0;
312
__pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_5mult2_Matrix), __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;}
313
Py_DECREF(__pyx_3); __pyx_3 = 0;
314
if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5mult2_Matrix)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;}
315
Py_DECREF(((PyObject *)__pyx_v_ans));
316
((PyObject *)__pyx_v_ans) = __pyx_1;
317
__pyx_1 = 0;
318
319
/* "/home/was/talks/pyrex/mult2.pyx":64 */
320
__pyx_v_n = __pyx_v_self->n;
321
322
/* "/home/was/talks/pyrex/mult2.pyx":65 */
323
for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_n; ++__pyx_v_i) {
324
325
/* "/home/was/talks/pyrex/mult2.pyx":66 */
326
for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_n; ++__pyx_v_j) {
327
328
/* "/home/was/talks/pyrex/mult2.pyx":68 */
329
__pyx_v_s = 0;
330
331
/* "/home/was/talks/pyrex/mult2.pyx":69 */
332
for (__pyx_v_k = 0; __pyx_v_k < __pyx_v_n; ++__pyx_v_k) {
333
334
/* "/home/was/talks/pyrex/mult2.pyx":70 */
335
__pyx_v_s = ((__pyx_v_s + ((__pyx_v_self->entries[((__pyx_v_i * __pyx_v_n) + __pyx_v_k)]) * (__pyx_v_B->entries[((__pyx_v_k * __pyx_v_n) + __pyx_v_j)]))) % __pyx_v_self->p);
336
337
/* "/home/was/talks/pyrex/mult2.pyx":71 */
338
__pyx_4 = (__pyx_v_s < 0);
339
if (__pyx_4) {
340
__pyx_v_s = (__pyx_v_s + __pyx_v_self->p);
341
goto __pyx_L8;
342
}
343
__pyx_L8:;
344
345
/* "/home/was/talks/pyrex/mult2.pyx":72 */
346
(__pyx_v_ans->entries[((__pyx_v_i * __pyx_v_n) + __pyx_v_j)]) = __pyx_v_s;
347
__pyx_L6:;
348
}
349
__pyx_L7:;
350
__pyx_L4:;
351
}
352
__pyx_L5:;
353
__pyx_L2:;
354
}
355
__pyx_L3:;
356
357
/* "/home/was/talks/pyrex/mult2.pyx":73 */
358
Py_INCREF(((PyObject *)__pyx_v_ans));
359
__pyx_r = (struct __pyx_obj_5mult2_Matrix *)((PyObject *)__pyx_v_ans);
360
goto __pyx_L0;
361
362
(PyObject *)__pyx_r = Py_None; Py_INCREF((PyObject *)__pyx_r);
363
goto __pyx_L0;
364
__pyx_L1:;
365
Py_XDECREF(__pyx_1);
366
Py_XDECREF(__pyx_2);
367
Py_XDECREF(__pyx_3);
368
__Pyx_AddTraceback("mult2.Matrix.__mul__");
369
__pyx_r = 0;
370
__pyx_L0:;
371
Py_DECREF(__pyx_v_ans);
372
Py_DECREF(__pyx_v_self);
373
Py_DECREF(__pyx_v_B);
374
return ((struct __pyx_obj_5mult2_Matrix *)__pyx_r) ;
375
}
376
377
static __Pyx_StringTabEntry __pyx_string_tab[] = {
378
{&__pyx_k3p, __pyx_k3, sizeof(__pyx_k3)},
379
{&__pyx_k4p, __pyx_k4, sizeof(__pyx_k4)},
380
{&__pyx_k5p, __pyx_k5, sizeof(__pyx_k5)},
381
{0, 0, 0}
382
};
383
static struct __pyx_vtabstruct_5mult2_Matrix __pyx_vtable_5mult2_Matrix;
384
385
static PyObject *__pyx_tp_new_5mult2_Matrix(PyTypeObject *t, PyObject *a, PyObject *k) {
386
PyObject *o = (*t->tp_alloc)(t, 0);
387
struct __pyx_obj_5mult2_Matrix *p = (struct __pyx_obj_5mult2_Matrix *)o;
388
(struct __pyx_vtabstruct_5mult2_Matrix *)p->__pyx_vtab = __pyx_vtabptr_5mult2_Matrix;
389
if (__pyx_f_5mult2_6Matrix___new__(o, a, k) < 0) {
390
Py_DECREF(o); o = 0;
391
}
392
return o;
393
}
394
395
static void __pyx_tp_dealloc_5mult2_Matrix(PyObject *o) {
396
struct __pyx_obj_5mult2_Matrix *p = (struct __pyx_obj_5mult2_Matrix *)o;
397
{
398
PyObject *etype, *eval, *etb;
399
PyErr_Fetch(&etype, &eval, &etb);
400
++o->ob_refcnt;
401
__pyx_f_5mult2_6Matrix___dealloc__(o);
402
if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
403
--o->ob_refcnt;
404
PyErr_Restore(etype, eval, etb);
405
}
406
(*o->ob_type->tp_free)(o);
407
}
408
409
static int __pyx_tp_traverse_5mult2_Matrix(PyObject *o, visitproc v, void *a) {
410
int e;
411
struct __pyx_obj_5mult2_Matrix *p = (struct __pyx_obj_5mult2_Matrix *)o;
412
return 0;
413
}
414
415
static int __pyx_tp_clear_5mult2_Matrix(PyObject *o) {
416
struct __pyx_obj_5mult2_Matrix *p = (struct __pyx_obj_5mult2_Matrix *)o;
417
return 0;
418
}
419
420
static struct PyMethodDef __pyx_methods_5mult2_Matrix[] = {
421
{0, 0, 0, 0}
422
};
423
424
static PyNumberMethods __pyx_tp_as_number_Matrix = {
425
0, /*nb_add*/
426
0, /*nb_subtract*/
427
__pyx_f_5mult2_6Matrix___mul__, /*nb_multiply*/
428
0, /*nb_divide*/
429
0, /*nb_remainder*/
430
0, /*nb_divmod*/
431
0, /*nb_power*/
432
0, /*nb_negative*/
433
0, /*nb_positive*/
434
0, /*nb_absolute*/
435
0, /*nb_nonzero*/
436
0, /*nb_invert*/
437
0, /*nb_lshift*/
438
0, /*nb_rshift*/
439
0, /*nb_and*/
440
0, /*nb_xor*/
441
0, /*nb_or*/
442
0, /*nb_coerce*/
443
0, /*nb_int*/
444
0, /*nb_long*/
445
0, /*nb_float*/
446
0, /*nb_oct*/
447
0, /*nb_hex*/
448
0, /*nb_inplace_add*/
449
0, /*nb_inplace_subtract*/
450
0, /*nb_inplace_multiply*/
451
0, /*nb_inplace_divide*/
452
0, /*nb_inplace_remainder*/
453
0, /*nb_inplace_power*/
454
0, /*nb_inplace_lshift*/
455
0, /*nb_inplace_rshift*/
456
0, /*nb_inplace_and*/
457
0, /*nb_inplace_xor*/
458
0, /*nb_inplace_or*/
459
0, /*nb_floor_divide*/
460
0, /*nb_true_divide*/
461
0, /*nb_inplace_floor_divide*/
462
0, /*nb_inplace_true_divide*/
463
};
464
465
static PySequenceMethods __pyx_tp_as_sequence_Matrix = {
466
0, /*sq_length*/
467
0, /*sq_concat*/
468
0, /*sq_repeat*/
469
0, /*sq_item*/
470
0, /*sq_slice*/
471
0, /*sq_ass_item*/
472
0, /*sq_ass_slice*/
473
0, /*sq_contains*/
474
0, /*sq_inplace_concat*/
475
0, /*sq_inplace_repeat*/
476
};
477
478
static PyMappingMethods __pyx_tp_as_mapping_Matrix = {
479
0, /*mp_length*/
480
0, /*mp_subscript*/
481
0, /*mp_ass_subscript*/
482
};
483
484
static PyBufferProcs __pyx_tp_as_buffer_Matrix = {
485
0, /*bf_getreadbuffer*/
486
0, /*bf_getwritebuffer*/
487
0, /*bf_getsegcount*/
488
0, /*bf_getcharbuffer*/
489
};
490
491
statichere PyTypeObject __pyx_type_5mult2_Matrix = {
492
PyObject_HEAD_INIT(0)
493
0, /*ob_size*/
494
"mult2.Matrix", /*tp_name*/
495
sizeof(struct __pyx_obj_5mult2_Matrix), /*tp_basicsize*/
496
0, /*tp_itemsize*/
497
__pyx_tp_dealloc_5mult2_Matrix, /*tp_dealloc*/
498
0, /*tp_print*/
499
0, /*tp_getattr*/
500
0, /*tp_setattr*/
501
0, /*tp_compare*/
502
__pyx_f_5mult2_6Matrix___repr__, /*tp_repr*/
503
&__pyx_tp_as_number_Matrix, /*tp_as_number*/
504
&__pyx_tp_as_sequence_Matrix, /*tp_as_sequence*/
505
&__pyx_tp_as_mapping_Matrix, /*tp_as_mapping*/
506
0, /*tp_hash*/
507
0, /*tp_call*/
508
0, /*tp_str*/
509
0, /*tp_getattro*/
510
0, /*tp_setattro*/
511
&__pyx_tp_as_buffer_Matrix, /*tp_as_buffer*/
512
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
513
0, /*tp_doc*/
514
__pyx_tp_traverse_5mult2_Matrix, /*tp_traverse*/
515
__pyx_tp_clear_5mult2_Matrix, /*tp_clear*/
516
0, /*tp_richcompare*/
517
0, /*tp_weaklistoffset*/
518
0, /*tp_iter*/
519
0, /*tp_iternext*/
520
__pyx_methods_5mult2_Matrix, /*tp_methods*/
521
0, /*tp_members*/
522
0, /*tp_getset*/
523
0, /*tp_base*/
524
0, /*tp_dict*/
525
0, /*tp_descr_get*/
526
0, /*tp_descr_set*/
527
0, /*tp_dictoffset*/
528
__pyx_f_5mult2_6Matrix___init__, /*tp_init*/
529
0, /*tp_alloc*/
530
__pyx_tp_new_5mult2_Matrix, /*tp_new*/
531
0, /*tp_free*/
532
0, /*tp_is_gc*/
533
0, /*tp_bases*/
534
0, /*tp_mro*/
535
0, /*tp_cache*/
536
0, /*tp_subclasses*/
537
0, /*tp_weaklist*/
538
};
539
540
static struct PyMethodDef __pyx_methods[] = {
541
{0, 0, 0, 0}
542
};
543
544
DL_EXPORT(void) initmult2(void); /*proto*/
545
DL_EXPORT(void) initmult2(void) {
546
__pyx_m = Py_InitModule4("mult2", __pyx_methods, __pyx_mdoc, 0, PYTHON_API_VERSION);
547
if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
548
__pyx_b = PyImport_AddModule("__builtin__");
549
if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
550
if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
551
if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
552
__pyx_vtabptr_5mult2_Matrix = &__pyx_vtable_5mult2_Matrix;
553
__pyx_vtable_5mult2_Matrix.__mul__ = (void *)__pyx_f_5mult2_6Matrix___mul__;
554
if (PyType_Ready(&__pyx_type_5mult2_Matrix) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;}
555
if (__Pyx_SetVtable(__pyx_type_5mult2_Matrix.tp_dict, __pyx_vtabptr_5mult2_Matrix) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;}
556
if (PyObject_SetAttrString(__pyx_m, "Matrix", (PyObject *)&__pyx_type_5mult2_Matrix) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;}
557
__pyx_ptype_5mult2_Matrix = &__pyx_type_5mult2_Matrix;
558
559
/* "/home/was/talks/pyrex/mult2.pyx":21 */
560
Py_INCREF(Py_None);
561
__pyx_k1 = Py_None;
562
563
/* "/home/was/talks/pyrex/mult2.pyx":29 */
564
Py_INCREF(Py_None);
565
__pyx_k2 = Py_None;
566
567
/* "/home/was/talks/pyrex/mult2.pyx":60 */
568
return;
569
__pyx_L1:;
570
__Pyx_AddTraceback("mult2");
571
}
572
573
static char *__pyx_filenames[] = {
574
"mult2.pyx",
575
};
576
statichere char **__pyx_f = __pyx_filenames;
577
578
/* Runtime support code */
579
580
static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
581
if (!type) {
582
PyErr_Format(PyExc_SystemError, "Missing type object");
583
return 0;
584
}
585
if (obj == Py_None || PyObject_TypeCheck(obj, type))
586
return 1;
587
PyErr_Format(PyExc_TypeError, "Cannot convert %s to %s",
588
obj->ob_type->tp_name, type->tp_name);
589
return 0;
590
}
591
592
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
593
while (t->p) {
594
*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
595
if (!*t->p)
596
return -1;
597
++t;
598
}
599
return 0;
600
}
601
602
static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
603
PyObject *pycobj = 0;
604
int result;
605
606
pycobj = PyCObject_FromVoidPtr(vtable, 0);
607
if (!pycobj)
608
goto bad;
609
if (PyDict_SetItemString(dict, "__pyx_vtable__", pycobj) < 0)
610
goto bad;
611
result = 0;
612
goto done;
613
614
bad:
615
result = -1;
616
done:
617
Py_XDECREF(pycobj);
618
return result;
619
}
620
621
#include "compile.h"
622
#include "frameobject.h"
623
#include "traceback.h"
624
625
static void __Pyx_AddTraceback(char *funcname) {
626
PyObject *py_srcfile = 0;
627
PyObject *py_funcname = 0;
628
PyObject *py_globals = 0;
629
PyObject *empty_tuple = 0;
630
PyObject *empty_string = 0;
631
PyCodeObject *py_code = 0;
632
PyFrameObject *py_frame = 0;
633
634
py_srcfile = PyString_FromString(__pyx_filename);
635
if (!py_srcfile) goto bad;
636
py_funcname = PyString_FromString(funcname);
637
if (!py_funcname) goto bad;
638
py_globals = PyModule_GetDict(__pyx_m);
639
if (!py_globals) goto bad;
640
empty_tuple = PyTuple_New(0);
641
if (!empty_tuple) goto bad;
642
empty_string = PyString_FromString("");
643
if (!empty_string) goto bad;
644
py_code = PyCode_New(
645
0, /*int argcount,*/
646
0, /*int nlocals,*/
647
0, /*int stacksize,*/
648
0, /*int flags,*/
649
empty_string, /*PyObject *code,*/
650
empty_tuple, /*PyObject *consts,*/
651
empty_tuple, /*PyObject *names,*/
652
empty_tuple, /*PyObject *varnames,*/
653
empty_tuple, /*PyObject *freevars,*/
654
empty_tuple, /*PyObject *cellvars,*/
655
py_srcfile, /*PyObject *filename,*/
656
py_funcname, /*PyObject *name,*/
657
__pyx_lineno, /*int firstlineno,*/
658
empty_string /*PyObject *lnotab*/
659
);
660
if (!py_code) goto bad;
661
py_frame = PyFrame_New(
662
PyThreadState_Get(), /*PyThreadState *tstate,*/
663
py_code, /*PyCodeObject *code,*/
664
py_globals, /*PyObject *globals,*/
665
0 /*PyObject *locals*/
666
);
667
if (!py_frame) goto bad;
668
py_frame->f_lineno = __pyx_lineno;
669
PyTraceBack_Here(py_frame);
670
bad:
671
Py_XDECREF(py_srcfile);
672
Py_XDECREF(py_funcname);
673
Py_XDECREF(empty_tuple);
674
Py_XDECREF(empty_string);
675
Py_XDECREF(py_code);
676
Py_XDECREF(py_frame);
677
}
678