#include "Python.h"
#include "arrayobject.h"
#include <math.h>
#include <unistd.h>

#define IDATA(p) ((int *) (((PyArrayObject *)p)->data))
#define DDATA(p) ((double *) (((PyArrayObject *)p)->data))

static PyObject *py_change_array(PyObject *self, PyObject *args);

static PyObject *py_change_array(PyObject *self, PyObject *args){
  int n,ok,i;
  PyObject *xarray;
  double *x;

  ok = PyArg_ParseTuple(args,"iO",&n,&xarray);
  if (!ok){
    fprintf(stderr,"Error (change_array) in parsing arguments\n");
    exit(1);
  }
  x = DDATA(xarray);
  
  for (i=0;i<n;i++){
    printf(" Array x %d %lf\n",i,x[i]);
    x[i]=x[i]*10;
  }
  sleep(3);

  return Py_BuildValue("i",i);
}
static PyMethodDef c_code1_methods[] = {
  {"change_array",py_change_array,METH_VARARGS},
  {NULL,NULL} /* Sentinel */
};
void initc_code1(){
  (void) Py_InitModule("c_code1",c_code1_methods);
}


