[Scipy-svn] r3779 - in trunk/scipy/sparse: . sparsetools tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Fri Jan 4 02:01:00 EST 2008
Author: wnbell
Date: 2008-01-04 01:00:52 -0600 (Fri, 04 Jan 2008)
New Revision: 3779
Modified:
trunk/scipy/sparse/bsr.py
trunk/scipy/sparse/compressed.py
trunk/scipy/sparse/sparsetools/sparsetools.h
trunk/scipy/sparse/sparsetools/sparsetools.i
trunk/scipy/sparse/sparsetools/sparsetools.py
trunk/scipy/sparse/sparsetools/sparsetools_wrap.cxx
trunk/scipy/sparse/tests/test_base.py
Log:
added eliminate_zeros() to compressed formats
Modified: trunk/scipy/sparse/bsr.py
===================================================================
--- trunk/scipy/sparse/bsr.py 2008-01-04 01:29:56 UTC (rev 3778)
+++ trunk/scipy/sparse/bsr.py 2008-01-04 07:00:52 UTC (rev 3779)
@@ -434,7 +434,29 @@
##############################################################
# methods that examine or modify the internal data structure #
##############################################################
-
+
+ def eliminate_zeros(self):
+ R,C = self.blocksize
+ M,N = self.shape
+
+ mask = (self.data != 0).reshape(-1,R*C).sum(axis=1) #nonzero blocks
+
+ nonzero_blocks = mask.nonzero()[0]
+
+ if len(nonzero_blocks) == 0:
+ return #nothing to do
+
+ self.data[:len(nonzero_blocks)] = self.data[nonzero_blocks]
+
+ from csr import csr_matrix
+
+ # modifies self.indptr and self.indices *in place*
+ proxy = csr_matrix((mask,self.indices,self.indptr),shape=(M/R,N/C))
+ proxy.eliminate_zeros()
+
+ self.prune()
+
+
def sum_duplicates(self):
raise NotImplementedError
Modified: trunk/scipy/sparse/compressed.py
===================================================================
--- trunk/scipy/sparse/compressed.py 2008-01-04 01:29:56 UTC (rev 3778)
+++ trunk/scipy/sparse/compressed.py 2008-01-04 07:00:52 UTC (rev 3779)
@@ -555,6 +555,17 @@
# methods that examine or modify the internal data structure #
##############################################################
+ def eliminate_zeros(self):
+ """Remove zero entries from the matrix
+
+ The is an *in place* operation
+ """
+ fn = sparsetools.csr_eliminate_zeros
+ M,N = self._swap(self.shape)
+ fn( M, N, self.indptr, self.indices, self.data)
+
+ self.prune() #nnz may have changed
+
def sum_duplicates(self):
"""Eliminate duplicate matrix entries by adding them together
@@ -572,8 +583,10 @@
def __get_sorted(self):
"""Determine whether the matrix has sorted indices
- True if the indices of the matrix are in
- sorted order, False otherwise.
+ Returns
+ - True: if the indices of the matrix are in sorted order
+ - False: otherwise
+
"""
#first check to see if result was cached
Modified: trunk/scipy/sparse/sparsetools/sparsetools.h
===================================================================
--- trunk/scipy/sparse/sparsetools/sparsetools.h 2008-01-04 01:29:56 UTC (rev 3778)
+++ trunk/scipy/sparse/sparsetools/sparsetools.h 2008-01-04 07:00:52 UTC (rev 3779)
@@ -887,7 +887,8 @@
* T Ax[nnz(A)] - nonzeros
*
* Note:
- * Ap,Aj, and Ax will be modified *inplace*
+ * The column indicies within each row must be in sorted order.
+ * Ap, Aj, and Ax will be modified *inplace*
*
*/
template <class I, class T>
@@ -916,49 +917,47 @@
}
Ap[i+1] = nnz;
}
+}
-
- //method that works on unsorted indices
-// std::vector<I> next(n_col,-1);
-// std::vector<T> sums(n_col, 0);
-//
-// I nnz = 0;
-//
-// I row_start = 0;
-// I row_end = 0;
-//
-// for(I i = 0; i < n_row; i++){
-// I head = -2;
-//
-// row_start = row_end; //Ap[i] may have been changed
-// row_end = Ap[i+1]; //Ap[i+1] is safe
-//
-// for(I jj = row_start; jj < row_end; jj++){
-// I j = Aj[jj];
-//
-// sums[j] += Ax[jj];
-//
-// if(next[j] == -1){
-// next[j] = head;
-// head = j;
-// }
-// }
-//
-// while(head != -2){
-// I curr = head; //current column
-// head = next[curr];
-//
-// if(sums[curr] != 0){
-// Aj[nnz] = curr;
-// Ax[nnz] = sums[curr];
-// nnz++;
-// }
-//
-// next[curr] = -1;
-// sums[curr] = 0;
-// }
-// Ap[i+1] = nnz;
-// }
+/*
+ * Eliminate zero entries from CSR matrix A
+ *
+ *
+ * Input Arguments:
+ * I n_row - number of rows in A (and B)
+ * I n_col - number of columns in A (and B)
+ * I Ap[n_row+1] - row pointer
+ * I Aj[nnz(A)] - column indices
+ * T Ax[nnz(A)] - nonzeros
+ *
+ * Note:
+ * Ap, Aj, and Ax will be modified *inplace*
+ *
+ */
+template <class I, class T>
+void csr_eliminate_zeros(const I n_row,
+ const I n_col,
+ I Ap[],
+ I Aj[],
+ T Ax[])
+{
+ I nnz = 0;
+ I row_end = 0;
+ for(I i = 0; i < n_row; i++){
+ I jj = row_end;
+ row_end = Ap[i+1];
+ while( jj < row_end ){
+ I j = Aj[jj];
+ T x = Ax[jj];
+ if(x != 0){
+ Aj[nnz] = j;
+ Ax[nnz] = x;
+ nnz++;
+ }
+ jj++;
+ }
+ Ap[i+1] = nnz;
+ }
}
@@ -985,8 +984,6 @@
* Note:
* Input: row and column indices *are not* assumed to be ordered
*
- * Output: CSR column indices *will be* in sorted order
- *
* Note: duplicate entries are carried over to the CSR represention
*
* Complexity: Linear. Specifically O(nnz(A) + max(n_row,n_col))
Modified: trunk/scipy/sparse/sparsetools/sparsetools.i
===================================================================
--- trunk/scipy/sparse/sparsetools/sparsetools.i 2008-01-04 01:29:56 UTC (rev 3778)
+++ trunk/scipy/sparse/sparsetools/sparsetools.i 2008-01-04 07:00:52 UTC (rev 3779)
@@ -259,6 +259,11 @@
/*
+ * Remove zeros
+ */
+INSTANTIATE_ALL(csr_eliminate_zeros)
+
+/*
* Sum duplicate entries.
*/
INSTANTIATE_ALL(csr_sum_duplicates)
Modified: trunk/scipy/sparse/sparsetools/sparsetools.py
===================================================================
--- trunk/scipy/sparse/sparsetools/sparsetools.py 2008-01-04 01:29:56 UTC (rev 3778)
+++ trunk/scipy/sparse/sparsetools/sparsetools.py 2008-01-04 07:00:52 UTC (rev 3779)
@@ -1055,6 +1055,25 @@
"""
return _sparsetools.csr_sort_indices(*args)
+def csr_eliminate_zeros(*args):
+ """
+ csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, signed char Ax)
+ csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned char Ax)
+ csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, short Ax)
+ csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned short Ax)
+ csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, int Ax)
+ csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned int Ax)
+ csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, long long Ax)
+ csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax)
+ csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, float Ax)
+ csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, double Ax)
+ csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, long double Ax)
+ csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax)
+ csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax)
+ csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax)
+ """
+ return _sparsetools.csr_eliminate_zeros(*args)
+
def csr_sum_duplicates(*args):
"""
csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, signed char Ax)
Modified: trunk/scipy/sparse/sparsetools/sparsetools_wrap.cxx
===================================================================
--- trunk/scipy/sparse/sparsetools/sparsetools_wrap.cxx 2008-01-04 01:29:56 UTC (rev 3778)
+++ trunk/scipy/sparse/sparsetools/sparsetools_wrap.cxx 2008-01-04 07:00:52 UTC (rev 3779)
@@ -77001,6 +77001,1213 @@
}
+SWIGINTERN PyObject *_wrap_csr_eliminate_zeros__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int *arg3 ;
+ int *arg4 ;
+ signed char *arg5 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyArrayObject *temp3 = NULL ;
+ PyArrayObject *temp4 = NULL ;
+ PyArrayObject *temp5 = NULL ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOOO:csr_eliminate_zeros",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_eliminate_zeros" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = static_cast< int >(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_eliminate_zeros" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ {
+ temp3 = obj_to_array_no_conversion(obj2,PyArray_INT);
+ if (!temp3 || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
+ arg3 = (int*) array_data(temp3);
+ }
+ {
+ temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+ if (!temp4 || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+ arg4 = (int*) array_data(temp4);
+ }
+ {
+ temp5 = obj_to_array_no_conversion(obj4,PyArray_BYTE);
+ if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
+ arg5 = (signed char*) array_data(temp5);
+ }
+ csr_eliminate_zeros<int,signed char >(arg1,arg2,arg3,arg4,arg5);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_csr_eliminate_zeros__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int *arg3 ;
+ int *arg4 ;
+ unsigned char *arg5 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyArrayObject *temp3 = NULL ;
+ PyArrayObject *temp4 = NULL ;
+ PyArrayObject *temp5 = NULL ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOOO:csr_eliminate_zeros",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_eliminate_zeros" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = static_cast< int >(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_eliminate_zeros" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ {
+ temp3 = obj_to_array_no_conversion(obj2,PyArray_INT);
+ if (!temp3 || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
+ arg3 = (int*) array_data(temp3);
+ }
+ {
+ temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+ if (!temp4 || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+ arg4 = (int*) array_data(temp4);
+ }
+ {
+ temp5 = obj_to_array_no_conversion(obj4,PyArray_UBYTE);
+ if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
+ arg5 = (unsigned char*) array_data(temp5);
+ }
+ csr_eliminate_zeros<int,unsigned char >(arg1,arg2,arg3,arg4,arg5);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_csr_eliminate_zeros__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int *arg3 ;
+ int *arg4 ;
+ short *arg5 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyArrayObject *temp3 = NULL ;
+ PyArrayObject *temp4 = NULL ;
+ PyArrayObject *temp5 = NULL ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOOO:csr_eliminate_zeros",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_eliminate_zeros" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = static_cast< int >(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_eliminate_zeros" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ {
+ temp3 = obj_to_array_no_conversion(obj2,PyArray_INT);
+ if (!temp3 || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
+ arg3 = (int*) array_data(temp3);
+ }
+ {
+ temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+ if (!temp4 || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+ arg4 = (int*) array_data(temp4);
+ }
+ {
+ temp5 = obj_to_array_no_conversion(obj4,PyArray_SHORT);
+ if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
+ arg5 = (short*) array_data(temp5);
+ }
+ csr_eliminate_zeros<int,short >(arg1,arg2,arg3,arg4,arg5);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_csr_eliminate_zeros__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int *arg3 ;
+ int *arg4 ;
+ unsigned short *arg5 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyArrayObject *temp3 = NULL ;
+ PyArrayObject *temp4 = NULL ;
+ PyArrayObject *temp5 = NULL ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOOO:csr_eliminate_zeros",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_eliminate_zeros" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = static_cast< int >(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_eliminate_zeros" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ {
+ temp3 = obj_to_array_no_conversion(obj2,PyArray_INT);
+ if (!temp3 || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
+ arg3 = (int*) array_data(temp3);
+ }
+ {
+ temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+ if (!temp4 || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+ arg4 = (int*) array_data(temp4);
+ }
+ {
+ temp5 = obj_to_array_no_conversion(obj4,PyArray_USHORT);
+ if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
+ arg5 = (unsigned short*) array_data(temp5);
+ }
+ csr_eliminate_zeros<int,unsigned short >(arg1,arg2,arg3,arg4,arg5);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_csr_eliminate_zeros__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int *arg3 ;
+ int *arg4 ;
+ int *arg5 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyArrayObject *temp3 = NULL ;
+ PyArrayObject *temp4 = NULL ;
+ PyArrayObject *temp5 = NULL ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOOO:csr_eliminate_zeros",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_eliminate_zeros" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = static_cast< int >(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_eliminate_zeros" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ {
+ temp3 = obj_to_array_no_conversion(obj2,PyArray_INT);
+ if (!temp3 || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
+ arg3 = (int*) array_data(temp3);
+ }
+ {
+ temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+ if (!temp4 || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+ arg4 = (int*) array_data(temp4);
+ }
+ {
+ temp5 = obj_to_array_no_conversion(obj4,PyArray_INT);
+ if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
+ arg5 = (int*) array_data(temp5);
+ }
+ csr_eliminate_zeros<int,int >(arg1,arg2,arg3,arg4,arg5);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_csr_eliminate_zeros__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int *arg3 ;
+ int *arg4 ;
+ unsigned int *arg5 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyArrayObject *temp3 = NULL ;
+ PyArrayObject *temp4 = NULL ;
+ PyArrayObject *temp5 = NULL ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOOO:csr_eliminate_zeros",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_eliminate_zeros" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = static_cast< int >(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_eliminate_zeros" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ {
+ temp3 = obj_to_array_no_conversion(obj2,PyArray_INT);
+ if (!temp3 || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
+ arg3 = (int*) array_data(temp3);
+ }
+ {
+ temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+ if (!temp4 || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+ arg4 = (int*) array_data(temp4);
+ }
+ {
+ temp5 = obj_to_array_no_conversion(obj4,PyArray_UINT);
+ if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
+ arg5 = (unsigned int*) array_data(temp5);
+ }
+ csr_eliminate_zeros<int,unsigned int >(arg1,arg2,arg3,arg4,arg5);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_csr_eliminate_zeros__SWIG_7(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int *arg3 ;
+ int *arg4 ;
+ long long *arg5 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyArrayObject *temp3 = NULL ;
+ PyArrayObject *temp4 = NULL ;
+ PyArrayObject *temp5 = NULL ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOOO:csr_eliminate_zeros",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_eliminate_zeros" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = static_cast< int >(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_eliminate_zeros" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ {
+ temp3 = obj_to_array_no_conversion(obj2,PyArray_INT);
+ if (!temp3 || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
+ arg3 = (int*) array_data(temp3);
+ }
+ {
+ temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+ if (!temp4 || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+ arg4 = (int*) array_data(temp4);
+ }
+ {
+ temp5 = obj_to_array_no_conversion(obj4,PyArray_LONGLONG);
+ if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
+ arg5 = (long long*) array_data(temp5);
+ }
+ csr_eliminate_zeros<int,long long >(arg1,arg2,arg3,arg4,arg5);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_csr_eliminate_zeros__SWIG_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int *arg3 ;
+ int *arg4 ;
+ unsigned long long *arg5 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyArrayObject *temp3 = NULL ;
+ PyArrayObject *temp4 = NULL ;
+ PyArrayObject *temp5 = NULL ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOOO:csr_eliminate_zeros",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_eliminate_zeros" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = static_cast< int >(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_eliminate_zeros" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ {
+ temp3 = obj_to_array_no_conversion(obj2,PyArray_INT);
+ if (!temp3 || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
+ arg3 = (int*) array_data(temp3);
+ }
+ {
+ temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+ if (!temp4 || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+ arg4 = (int*) array_data(temp4);
+ }
+ {
+ temp5 = obj_to_array_no_conversion(obj4,PyArray_ULONGLONG);
+ if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
+ arg5 = (unsigned long long*) array_data(temp5);
+ }
+ csr_eliminate_zeros<int,unsigned long long >(arg1,arg2,arg3,arg4,arg5);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_csr_eliminate_zeros__SWIG_9(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int *arg3 ;
+ int *arg4 ;
+ float *arg5 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyArrayObject *temp3 = NULL ;
+ PyArrayObject *temp4 = NULL ;
+ PyArrayObject *temp5 = NULL ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOOO:csr_eliminate_zeros",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_eliminate_zeros" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = static_cast< int >(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_eliminate_zeros" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ {
+ temp3 = obj_to_array_no_conversion(obj2,PyArray_INT);
+ if (!temp3 || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
+ arg3 = (int*) array_data(temp3);
+ }
+ {
+ temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+ if (!temp4 || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+ arg4 = (int*) array_data(temp4);
+ }
+ {
+ temp5 = obj_to_array_no_conversion(obj4,PyArray_FLOAT);
+ if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
+ arg5 = (float*) array_data(temp5);
+ }
+ csr_eliminate_zeros<int,float >(arg1,arg2,arg3,arg4,arg5);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_csr_eliminate_zeros__SWIG_10(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int *arg3 ;
+ int *arg4 ;
+ double *arg5 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyArrayObject *temp3 = NULL ;
+ PyArrayObject *temp4 = NULL ;
+ PyArrayObject *temp5 = NULL ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOOO:csr_eliminate_zeros",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_eliminate_zeros" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = static_cast< int >(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_eliminate_zeros" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ {
+ temp3 = obj_to_array_no_conversion(obj2,PyArray_INT);
+ if (!temp3 || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
+ arg3 = (int*) array_data(temp3);
+ }
+ {
+ temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+ if (!temp4 || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+ arg4 = (int*) array_data(temp4);
+ }
+ {
+ temp5 = obj_to_array_no_conversion(obj4,PyArray_DOUBLE);
+ if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
+ arg5 = (double*) array_data(temp5);
+ }
+ csr_eliminate_zeros<int,double >(arg1,arg2,arg3,arg4,arg5);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_csr_eliminate_zeros__SWIG_11(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int *arg3 ;
+ int *arg4 ;
+ long double *arg5 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyArrayObject *temp3 = NULL ;
+ PyArrayObject *temp4 = NULL ;
+ PyArrayObject *temp5 = NULL ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOOO:csr_eliminate_zeros",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_eliminate_zeros" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = static_cast< int >(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_eliminate_zeros" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ {
+ temp3 = obj_to_array_no_conversion(obj2,PyArray_INT);
+ if (!temp3 || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
+ arg3 = (int*) array_data(temp3);
+ }
+ {
+ temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+ if (!temp4 || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+ arg4 = (int*) array_data(temp4);
+ }
+ {
+ temp5 = obj_to_array_no_conversion(obj4,PyArray_LONGDOUBLE);
+ if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
+ arg5 = (long double*) array_data(temp5);
+ }
+ csr_eliminate_zeros<int,long double >(arg1,arg2,arg3,arg4,arg5);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_csr_eliminate_zeros__SWIG_12(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int *arg3 ;
+ int *arg4 ;
+ npy_cfloat_wrapper *arg5 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyArrayObject *temp3 = NULL ;
+ PyArrayObject *temp4 = NULL ;
+ PyArrayObject *temp5 = NULL ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOOO:csr_eliminate_zeros",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_eliminate_zeros" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = static_cast< int >(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_eliminate_zeros" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ {
+ temp3 = obj_to_array_no_conversion(obj2,PyArray_INT);
+ if (!temp3 || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
+ arg3 = (int*) array_data(temp3);
+ }
+ {
+ temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+ if (!temp4 || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+ arg4 = (int*) array_data(temp4);
+ }
+ {
+ temp5 = obj_to_array_no_conversion(obj4,PyArray_CFLOAT);
+ if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
+ arg5 = (npy_cfloat_wrapper*) array_data(temp5);
+ }
+ csr_eliminate_zeros<int,npy_cfloat_wrapper >(arg1,arg2,arg3,arg4,arg5);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_csr_eliminate_zeros__SWIG_13(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int *arg3 ;
+ int *arg4 ;
+ npy_cdouble_wrapper *arg5 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyArrayObject *temp3 = NULL ;
+ PyArrayObject *temp4 = NULL ;
+ PyArrayObject *temp5 = NULL ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOOO:csr_eliminate_zeros",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_eliminate_zeros" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = static_cast< int >(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_eliminate_zeros" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ {
+ temp3 = obj_to_array_no_conversion(obj2,PyArray_INT);
+ if (!temp3 || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
+ arg3 = (int*) array_data(temp3);
+ }
+ {
+ temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+ if (!temp4 || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+ arg4 = (int*) array_data(temp4);
+ }
+ {
+ temp5 = obj_to_array_no_conversion(obj4,PyArray_CDOUBLE);
+ if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
+ arg5 = (npy_cdouble_wrapper*) array_data(temp5);
+ }
+ csr_eliminate_zeros<int,npy_cdouble_wrapper >(arg1,arg2,arg3,arg4,arg5);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_csr_eliminate_zeros__SWIG_14(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int *arg3 ;
+ int *arg4 ;
+ npy_clongdouble_wrapper *arg5 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyArrayObject *temp3 = NULL ;
+ PyArrayObject *temp4 = NULL ;
+ PyArrayObject *temp5 = NULL ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOOO:csr_eliminate_zeros",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_eliminate_zeros" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = static_cast< int >(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_eliminate_zeros" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ {
+ temp3 = obj_to_array_no_conversion(obj2,PyArray_INT);
+ if (!temp3 || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
+ arg3 = (int*) array_data(temp3);
+ }
+ {
+ temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+ if (!temp4 || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+ arg4 = (int*) array_data(temp4);
+ }
+ {
+ temp5 = obj_to_array_no_conversion(obj4,PyArray_CLONGDOUBLE);
+ if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
+ arg5 = (npy_clongdouble_wrapper*) array_data(temp5);
+ }
+ csr_eliminate_zeros<int,npy_clongdouble_wrapper >(arg1,arg2,arg3,arg4,arg5);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_csr_eliminate_zeros(PyObject *self, PyObject *args) {
+ int argc;
+ PyObject *argv[6];
+ int ii;
+
+ if (!PyTuple_Check(args)) SWIG_fail;
+ argc = (int)PyObject_Length(args);
+ for (ii = 0; (ii < argc) && (ii < 5); ii++) {
+ argv[ii] = PyTuple_GET_ITEM(args,ii);
+ }
+ if (argc == 5) {
+ int _v;
+ {
+ int res = SWIG_AsVal_int(argv[0], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[1], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_BYTE)) ? 1 : 0;
+ }
+ if (_v) {
+ return _wrap_csr_eliminate_zeros__SWIG_1(self, args);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (argc == 5) {
+ int _v;
+ {
+ int res = SWIG_AsVal_int(argv[0], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[1], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_UBYTE)) ? 1 : 0;
+ }
+ if (_v) {
+ return _wrap_csr_eliminate_zeros__SWIG_2(self, args);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (argc == 5) {
+ int _v;
+ {
+ int res = SWIG_AsVal_int(argv[0], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[1], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_SHORT)) ? 1 : 0;
+ }
+ if (_v) {
+ return _wrap_csr_eliminate_zeros__SWIG_3(self, args);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (argc == 5) {
+ int _v;
+ {
+ int res = SWIG_AsVal_int(argv[0], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[1], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_USHORT)) ? 1 : 0;
+ }
+ if (_v) {
+ return _wrap_csr_eliminate_zeros__SWIG_4(self, args);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (argc == 5) {
+ int _v;
+ {
+ int res = SWIG_AsVal_int(argv[0], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[1], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ return _wrap_csr_eliminate_zeros__SWIG_5(self, args);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (argc == 5) {
+ int _v;
+ {
+ int res = SWIG_AsVal_int(argv[0], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[1], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_UINT)) ? 1 : 0;
+ }
+ if (_v) {
+ return _wrap_csr_eliminate_zeros__SWIG_6(self, args);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (argc == 5) {
+ int _v;
+ {
+ int res = SWIG_AsVal_int(argv[0], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[1], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGLONG)) ? 1 : 0;
+ }
+ if (_v) {
+ return _wrap_csr_eliminate_zeros__SWIG_7(self, args);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (argc == 5) {
+ int _v;
+ {
+ int res = SWIG_AsVal_int(argv[0], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[1], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_ULONGLONG)) ? 1 : 0;
+ }
+ if (_v) {
+ return _wrap_csr_eliminate_zeros__SWIG_8(self, args);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (argc == 5) {
+ int _v;
+ {
+ int res = SWIG_AsVal_int(argv[0], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[1], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0;
+ }
+ if (_v) {
+ return _wrap_csr_eliminate_zeros__SWIG_9(self, args);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (argc == 5) {
+ int _v;
+ {
+ int res = SWIG_AsVal_int(argv[0], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[1], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0;
+ }
+ if (_v) {
+ return _wrap_csr_eliminate_zeros__SWIG_10(self, args);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (argc == 5) {
+ int _v;
+ {
+ int res = SWIG_AsVal_int(argv[0], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[1], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0;
+ }
+ if (_v) {
+ return _wrap_csr_eliminate_zeros__SWIG_11(self, args);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (argc == 5) {
+ int _v;
+ {
+ int res = SWIG_AsVal_int(argv[0], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[1], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0;
+ }
+ if (_v) {
+ return _wrap_csr_eliminate_zeros__SWIG_12(self, args);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (argc == 5) {
+ int _v;
+ {
+ int res = SWIG_AsVal_int(argv[0], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[1], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0;
+ }
+ if (_v) {
+ return _wrap_csr_eliminate_zeros__SWIG_13(self, args);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (argc == 5) {
+ int _v;
+ {
+ int res = SWIG_AsVal_int(argv[0], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[1], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0;
+ }
+ if (_v) {
+ {
+ _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0;
+ }
+ if (_v) {
+ return _wrap_csr_eliminate_zeros__SWIG_14(self, args);
+ }
+ }
+ }
+ }
+ }
+ }
+
+fail:
+ SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_eliminate_zeros'.\n Possible C/C++ prototypes are:\n"" csr_eliminate_zeros<(int,signed char)>(int const,int const,int [],int [],signed char [])\n"" csr_eliminate_zeros<(int,unsigned char)>(int const,int const,int [],int [],unsigned char [])\n"" csr_eliminate_zeros<(int,short)>(int const,int const,int [],int [],short [])\n"" csr_eliminate_zeros<(int,unsigned short)>(int const,int const,int [],int [],unsigned short [])\n"" csr_eliminate_zeros<(int,int)>(int const,int const,int [],int [],int [])\n"" csr_eliminate_zeros<(int,unsigned int)>(int const,int const,int [],int [],unsigned int [])\n"" csr_eliminate_zeros<(int,long long)>(int const,int const,int [],int [],long long [])\n"" csr_eliminate_zeros<(int,unsigned long long)>(int const,int const,int [],int [],unsigned long long [])\n"" csr_eliminate_zeros<(int,float)>(int const,int const,int [],int [],float [])\n"" csr_eliminate_zeros<(int,double)>(int const,int const,int [],int [],double [])\n"" csr_eliminate_zeros<(int,long double)>(int const,int const,int [],int [],long double [])\n"" csr_eliminate_zeros<(int,npy_cfloat_wrapper)>(int const,int const,int [],int [],npy_cfloat_wrapper [])\n"" csr_eliminate_zeros<(int,npy_cdouble_wrapper)>(int const,int const,int [],int [],npy_cdouble_wrapper [])\n"" csr_eliminate_zeros<(int,npy_clongdouble_wrapper)>(int const,int const,int [],int [],npy_clongdouble_wrapper [])\n");
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_csr_sum_duplicates__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
int arg1 ;
@@ -82221,6 +83428,22 @@
"csr_sort_indices(int n_row, int Ap, int Aj, npy_cdouble_wrapper Ax)\n"
"csr_sort_indices(int n_row, int Ap, int Aj, npy_clongdouble_wrapper Ax)\n"
""},
+ { (char *)"csr_eliminate_zeros", _wrap_csr_eliminate_zeros, METH_VARARGS, (char *)"\n"
+ "csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, signed char Ax)\n"
+ "csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned char Ax)\n"
+ "csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, short Ax)\n"
+ "csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned short Ax)\n"
+ "csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, int Ax)\n"
+ "csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned int Ax)\n"
+ "csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, long long Ax)\n"
+ "csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax)\n"
+ "csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, float Ax)\n"
+ "csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, double Ax)\n"
+ "csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, long double Ax)\n"
+ "csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax)\n"
+ "csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax)\n"
+ "csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax)\n"
+ ""},
{ (char *)"csr_sum_duplicates", _wrap_csr_sum_duplicates, METH_VARARGS, (char *)"\n"
"csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, signed char Ax)\n"
"csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned char Ax)\n"
Modified: trunk/scipy/sparse/tests/test_base.py
===================================================================
--- trunk/scipy/sparse/tests/test_base.py 2008-01-04 01:29:56 UTC (rev 3778)
+++ trunk/scipy/sparse/tests/test_base.py 2008-01-04 07:00:52 UTC (rev 3779)
@@ -15,7 +15,7 @@
import numpy
from numpy import arange, zeros, array, dot, ones, matrix, asmatrix, \
- asarray, vstack, ndarray, kron
+ asarray, vstack, ndarray, kron, transpose
import random
from numpy.testing import *
@@ -812,6 +812,17 @@
assert_array_equal(asp.indices,[1, 2, 7, 4, 5])
assert_array_equal(asp.todense(),bsp.todense())
+ def check_eliminate_zeros(self):
+ data = array( [1, 0, 0, 0, 2, 0, 3, 0] )
+ indices = array( [1, 2, 3, 4, 5, 6, 7, 8] )
+ indptr = array( [0, 3, 8] )
+ asp = csr_matrix( (data, indices, indptr), shape=(2,10) )
+ bsp = asp.copy()
+ asp.eliminate_zeros( )
+ assert_array_equal(asp.nnz, 3)
+ assert_array_equal(asp.data,[1, 2, 3])
+ assert_array_equal(asp.todense(),bsp.todense())
+
def check_get_submatrix(self):
a = csr_matrix( array([[1,2,3,4],[1,2,3,5],[0,2,0,1]]) )
i0 = slice( 0, 2 )
@@ -875,6 +886,17 @@
csc = csc_matrix((data, indices, indptr))
assert_array_equal(csc.shape,(6,3))
+ def check_eliminate_zeros(self):
+ data = array( [1, 0, 0, 0, 2, 0, 3, 0] )
+ indices = array( [1, 2, 3, 4, 5, 6, 7, 8] )
+ indptr = array( [0, 3, 8] )
+ asp = csc_matrix( (data, indices, indptr), shape=(10,2) )
+ bsp = asp.copy()
+ asp.eliminate_zeros( )
+ assert_array_equal(asp.nnz, 3)
+ assert_array_equal(asp.data,[1, 2, 3])
+ assert_array_equal(asp.todense(),bsp.todense())
+
def check_sort_indices(self):
data = arange( 5 )
row = array( [7, 2, 1, 5, 4] )
@@ -1260,6 +1282,16 @@
A = kron( [[1,0,2,0],[0,1,0,0],[0,0,0,0]], [[0,1,2],[3,0,5]] )
assert_equal(bsr_matrix(A,blocksize=(2,3)).todense(),A)
+ def check_eliminate_zeros(self):
+ data = kron([1, 0, 0, 0, 2, 0, 3, 0], [[1,1],[1,1]]).T
+ data = data.reshape(-1,2,2)
+ indices = array( [1, 2, 3, 4, 5, 6, 7, 8] )
+ indptr = array( [0, 3, 8] )
+ asp = bsr_matrix( (data, indices, indptr), shape=(4,20) )
+ bsp = asp.copy()
+ asp.eliminate_zeros()
+ assert_array_equal(asp.nnz, 3*4)
+ assert_array_equal(asp.todense(),bsp.todense())
if __name__ == "__main__":
More information about the Scipy-svn
mailing list