| 
																	
																	
																	
																 | 
																@@ -1,5 +1,6 @@ | 
															
														
														
													
														
															
																 | 
																 | 
																/* Computes the permanent, given a numpy array */ | 
																 | 
																 | 
																/* Computes the permanent, given a numpy array */ | 
															
														
														
													
														
															
																 | 
																 | 
																
  | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION | 
															
														
														
													
														
															
																 | 
																 | 
																#include <Python.h> | 
																 | 
																 | 
																#include <Python.h> | 
															
														
														
													
														
															
																 | 
																 | 
																#include <numpy/arrayobject.h> | 
																 | 
																 | 
																#include <numpy/arrayobject.h> | 
															
														
														
													
														
															
																 | 
																 | 
																#include <math.h> | 
																 | 
																 | 
																#include <math.h> | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																	
																 | 
																@@ -23,7 +24,6 @@ PyMODINIT_FUNC initpermanent(void) { | 
															
														
														
													
														
															
																 | 
																 | 
																/***************************************************************************** | 
																 | 
																 | 
																/***************************************************************************** | 
															
														
														
													
														
															
																 | 
																 | 
																 * Array access macros.                                                      * | 
																 | 
																 | 
																 * Array access macros.                                                      * | 
															
														
														
													
														
															
																 | 
																 | 
																 *****************************************************************************/ | 
																 | 
																 | 
																 *****************************************************************************/ | 
															
														
														
													
														
															
																 | 
																 | 
																#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																#define m(x0) (*(npy_float64*)((PyArray_DATA(py_m) +                \ | 
																 | 
																 | 
																#define m(x0) (*(npy_float64*)((PyArray_DATA(py_m) +                \ | 
															
														
														
													
														
															
																 | 
																 | 
																                                (x0) * PyArray_STRIDES(py_m)[0]))) | 
																 | 
																 | 
																                                (x0) * PyArray_STRIDES(py_m)[0]))) | 
															
														
														
													
														
															
																 | 
																 | 
																#define m_shape(i) (py_m->dimensions[(i)]) | 
																 | 
																 | 
																#define m_shape(i) (py_m->dimensions[(i)]) | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																	
																 | 
																@@ -44,25 +44,37 @@ PyMODINIT_FUNC initpermanent(void) { | 
															
														
														
													
														
															
																 | 
																 | 
																#define F_shape(i) (py_F->dimensions[(i)]) | 
																 | 
																 | 
																#define F_shape(i) (py_F->dimensions[(i)]) | 
															
														
														
													
														
															
																 | 
																 | 
																
  | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																static PyObject *permanent(PyObject *self, PyObject *args) { | 
																 | 
																 | 
																static PyObject *permanent(PyObject *self, PyObject *args) { | 
															
														
														
													
														
															
																 | 
																 | 
																  // Declare variables.  | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																  npy_int64 d, i, j; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																  double complex sum; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  // Parse input | 
															
														
														
													
														
															
																 | 
																 | 
																  PyArrayObject *submatrix; | 
																 | 
																 | 
																  PyArrayObject *submatrix; | 
															
														
														
													
														
															
																 | 
																 | 
																
  | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																  // Parse variables.  | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																  if (!PyArg_ParseTuple(args, "O!", &PyArray_Type, &submatrix)) { | 
																 | 
																 | 
																  if (!PyArg_ParseTuple(args, "O!", &PyArray_Type, &submatrix)) { | 
															
														
														
													
														
															
																 | 
																 | 
																    return NULL; | 
																 | 
																 | 
																    return NULL; | 
															
														
														
													
														
															
																 | 
																 | 
																  } | 
																 | 
																 | 
																  } | 
															
														
														
													
														
															
																 | 
																 | 
																
  | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  // Declare variables.  | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  /*npy_int64 d, i, j;*/ | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  Py_complex a; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  Py_complex b; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  a.real=1; a.imag=1; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  b.real=1; b.imag=1; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  a.real=a.real+b.real; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  a.imag=a.imag+b.imag; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  // Convert to a python complex number | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  PyObject *output=PyComplex_FromDoubles(a.real,a.imag); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  return output; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  /* | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																  // Compute the permanent | 
																 | 
																 | 
																  // Compute the permanent | 
															
														
														
													
														
															
																 | 
																 | 
																  for(i = 0; i < d; ++i) { | 
																 | 
																 | 
																  for(i = 0; i < d; ++i) { | 
															
														
														
													
														
															
																 | 
																 | 
																    for(j = 0; j<d; ++j) { | 
																 | 
																 | 
																    for(j = 0; j<d; ++j) { | 
															
														
														
													
														
															
																 | 
																 | 
																        sum+=1j; | 
																 | 
																 | 
																        sum+=1j; | 
															
														
														
													
														
															
																 | 
																 | 
																    } | 
																 | 
																 | 
																    } | 
															
														
														
													
														
															
																 | 
																 | 
																  } | 
																 | 
																 | 
																  } | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  */ | 
															
														
														
													
														
															
																 | 
																 | 
																
  | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																  // Convert to a python complex number | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																  /*Py_complex psum = struct {};*/ //fromdouble | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																  PyObject *output=PyComplex_FromCComplex(psum); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																  return output; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																} | 
																 | 
																 | 
																} |