Ignore:
Timestamp:
Nov 18, 2004, 10:53:59 PM (20 years ago)
Author:
steve
Message:

Working on sparse. Sparse_CSR * vertor works, Sparse_CSR * matrix doesn't.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/sparse_ext.c

    r589 r594  
    1616int _csr_mv(int M,
    1717            double* data,
    18             int* colind,
    19             int* row_ptr,
     18            long* colind,
     19            long* row_ptr,
    2020            double* x,
    2121            double* y) {
    2222               
    23   int i, j, ckey;
     23  long i, j, ckey;
    2424
    2525  for (i=0; i<M; i++ )
     
    4040 
    4141  PyObject *csr_sparse, // input sparse matrix
    42     *R;                 // output wrapped vector
     42    *xin, *R;                 // output wrapped vector
    4343 
    4444  PyArrayObject
     
    4848    *x,               //Input vector array
    4949    *y;               //Return vector array
     50
     51  double *xdata;
    5052   
    5153  int dimensions[1], M, err;
    5254 
    5355  // Convert Python arguments to C 
    54   if (!PyArg_ParseTuple(args, "OO", &csr_sparse, &x))
     56  if (!PyArg_ParseTuple(args, "OO", &csr_sparse, &xin))
    5557    return NULL;
     58
     59  x = (PyArrayObject*) PyArray_ContiguousFromObject(xin,PyArray_DOUBLE,1,2);
     60  if (!x)
     61    return NULL;
     62
     63/*   printf("x.nd = %i\n",x->nd); */
     64/*   printf("x.descr->type_num = %i %i\n",x->descr->type_num,PyArray_LONG); */
     65/*   printf("x.dimensions[0] = %i\n",x->dimensions[0]); */
     66/*   printf("x.data[0] = %g\n",((double*) x->data)[0]); */
     67/*   printf("x.data[1] = %g\n",((double*) x->data)[1]); */
     68/*   printf("x.data[2] = %g\n",((double*) x->data)[2]); */
     69/*   printf("x.data[3] = %g\n",((double*) x->data)[3]); */
     70/*   printf("x.data[4] = %g\n",((double*) x->data)[4]); */
     71/*   printf("x.data[5] = %g\n",((double*) x->data)[5]); */
     72
     73 
    5674
    5775
     
    6179    return NULL; 
    6280
     81
    6382  colind = (PyArrayObject*)
    6483    PyObject_GetAttrString(csr_sparse, "colind");
    6584  if (!colind) return NULL;   
    66  
     85
    6786  row_ptr = (PyArrayObject*)
    6887    PyObject_GetAttrString(csr_sparse, "row_ptr");   
     
    7796  err = _csr_mv(M,
    7897                (double*) data -> data,
    79                 (int*)    colind -> data,
    80                 (int*)    row_ptr -> data,
     98                (long*)    colind -> data,
     99                (long*)    row_ptr -> data,
    81100                (double*) x -> data,
    82101                (double*) y -> data);     
Note: See TracChangeset for help on using the changeset viewer.