Package: pysparse
Version: 1.0.1-5
Severity: serious
Tags: patch

Hi Adam,

thanks for maintaining pysparse. If I may venture a request: it would be
nice if pysparse.superlu worked instead of segfaulting. Attached is my
suggestion to fix it. (Yeah, it breaks some options which are
undocumented and in part have changed before without notice and it is
not segfaulting anymore, I would claim that that is strictly better.)

See this message for a test case:

https://lists.ubuntu.com/archives/ubuntu-users/2008-May/148160.html

Note, however, that unlike the claim of his code the output
should not be a vector with all ones.

I have allowed myself to fix some unrelated bogosities.

Kind regards

T.

diff -u pysparse-1.0.1/debian/changelog pysparse-1.0.1/debian/changelog
--- pysparse-1.0.1/debian/changelog
+++ pysparse-1.0.1/debian/changelog
@@ -1,3 +1,11 @@
+pysparse (1.0.1-5.1) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Fix pysparse.superlu module port to superlu 3 based on reading
+    the docs.
+
+ -- Thomas Viehmann <t...@beamnet.de>  Fri, 01 May 2009 20:56:39 +0200
+
 pysparse (1.0.1-5) unstable; urgency=low
 
   * Removed removal of /usr/lib and Build-Depends on python-central >= 0.6
diff -u pysparse-1.0.1/Src/superlumodule.c pysparse-1.0.1/Src/superlumodule.c
--- pysparse-1.0.1/Src/superlumodule.c
+++ pysparse-1.0.1/Src/superlumodule.c
@@ -89,8 +89,9 @@
   dCreate_Dense_Matrix(&B, self->n, 1, (double *)x->data, self->n, SLU_DN, 
SLU_D, SLU_GE);
 #endif
 
+    StatInit(&dummy);
   /* Solve the system, overwriting vector x. */
-  dgstrs(trans, &self->L, &self->U, self->perm_r, self->perm_c, &B, &dummy, 
&info);
+  dgstrs(trans, &self->L, &self->U, self->perm_c, self->perm_r, &B, &dummy, 
&info);
 
   /* free memory */
   Destroy_SuperMatrix_Store(&B);
@@ -197,20 +198,17 @@
   SuperMatrix A;      /* A in NC format used by the factorization routine. */
   SuperMatrix AC;     /* Matrix postmultiplied by Pc */
   mem_usage_t mem_usage;
-  int lwork = 0;
   int *etree;
   int info;
   
-  optionst.Trans = NOTRANS;
-  optionst.DiagPivotThresh = diag_pivot_thresh;
-  statt.panel_histo = &panel_size;
-  statt.RefineSteps = relax;
+  set_default_options(&optionst);
 
+  /* the below comment is interesting because statt is a local variable. eh?
   /* make sure StatInit is only called once */
-  if (!StatInit_done) {
+  //if (!StatInit_done) {
     StatInit(&statt);
-    StatInit_done = 1;
-  }
+  //  StatInit_done = 1;
+  //}
 
   /* Create SuperLUObject */
   self = PyObject_New(SuperLUObject, &SuperLUType);
@@ -231,16 +229,17 @@
   etree = intMalloc(n);
   self->perm_r = intMalloc(n);
   self->perm_c = intMalloc(n);
-  if (self->perm_r == NULL || self->perm_c == NULL) {
+  if (self->perm_r == NULL || self->perm_c == NULL || etree == NULL) {
     PyErr_NoMemory();
     goto fail;
   }
   get_perm_c(permc_spec, &A, self->perm_c); /* calc column permutation */
   sp_preorder(&optionst, &A, self->perm_c, etree, &AC); /* apply column 
permutation */
-
+  panel_size = sp_ienv(1);
+  relax = sp_ienv(2);
   /* Perform factorization */
   dgstrf(&optionst, &AC, drop_tol, relax, panel_size,
-         etree, NULL, lwork, self->perm_r, self->perm_c,
+         etree, NULL, 0, self->perm_c,self->perm_r,
          &self->L, &self->U, &statt, &info);
 
   /* free memory */
@@ -263,8 +262,8 @@
   return (PyObject *)self;
 
  fail:
-  PyMem_Del(self->perm_r);
-  PyMem_Del(self->perm_c);
+  SUPERLU_FREE(self->perm_r);
+  SUPERLU_FREE(self->perm_c);
   PyObject_Del(self);
   return NULL;
 }



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to