[Numpy-svn] r4997 - trunk/numpy/linalg
numpy-svn at scipy.org
numpy-svn at scipy.org
Wed Apr 9 10:38:30 EDT 2008
Author: pearu
Date: 2008-04-09 09:38:15 -0500 (Wed, 09 Apr 2008)
New Revision: 4997
Added:
trunk/numpy/linalg/pythonxerbla.c
Modified:
trunk/numpy/linalg/blas_lite.c
trunk/numpy/linalg/setup.py
Log:
Apply modified patch from ticket 673. The patch is effective when using unoptimized lapack shipped with numpy [tested] or if optimized lapack library does not have xerbla_ defined [not tested]
Modified: trunk/numpy/linalg/blas_lite.c
===================================================================
--- trunk/numpy/linalg/blas_lite.c 2008-04-09 11:53:02 UTC (rev 4996)
+++ trunk/numpy/linalg/blas_lite.c 2008-04-09 14:38:15 UTC (rev 4997)
@@ -4306,7 +4306,8 @@
return ret_val;
} /* lsame_ */
-/* Subroutine */ int xerbla_(char *srname, integer *info)
+/* Using xerbla_ from pythonxerbla.c */
+/* Subroutine */ int xerbla_DISABLE(char *srname, integer *info)
{
/* Format strings */
static char fmt_9999[] = "(\002 ** On entry to \002,a6,\002 parameter nu"
Added: trunk/numpy/linalg/pythonxerbla.c
===================================================================
--- trunk/numpy/linalg/pythonxerbla.c 2008-04-09 11:53:02 UTC (rev 4996)
+++ trunk/numpy/linalg/pythonxerbla.c 2008-04-09 14:38:15 UTC (rev 4997)
@@ -0,0 +1,37 @@
+#include "Python.h"
+#include "f2c.h"
+
+/*
+ From the original manpage:
+ XERBLA is an error handler for the LAPACK routines.
+ It is called by an LAPACK routine if an input parameter has an invalid value.
+ A message is printed and execution stops.
+
+ Instead of printing a message and stopping the execution, a
+ ValueError is raised with the message.
+
+ Parameters:
+ srname: Subroutine name to use in error message, maximum six characters.
+ Spaces at the end are skipped.
+ info: Number of the invalid parameter.
+*/
+
+extern int dgesv_(int *n, int *nrhs,
+ double a[], int *lda, int ipiv[],
+ double b[], int *ldb, int *info);
+
+int xerbla_(char *srname, integer *info)
+{
+ const char* format = "On entry to %.*s" \
+ " parameter number %d had an illegal value";
+ char buf[strlen(format) + 6 + 4]; /* 6 for name, 4 for param. num. */
+
+ int len = 0; /* length of subroutine name*/
+ while( len<6 && srname[len]!='\0' )
+ len++;
+ while( len && srname[len-1]==' ' )
+ len--;
+ snprintf(buf, sizeof(buf), format, len, srname, *info);
+ PyErr_SetString(PyExc_ValueError, buf);
+ return 0;
+}
Modified: trunk/numpy/linalg/setup.py
===================================================================
--- trunk/numpy/linalg/setup.py 2008-04-09 11:53:02 UTC (rev 4996)
+++ trunk/numpy/linalg/setup.py 2008-04-09 14:38:15 UTC (rev 4997)
@@ -13,14 +13,15 @@
print "### Warning: Using unoptimized lapack ###"
return ext.depends[:-1]
else:
- return ext.depends[:1]
+ return ext.depends[:2]
config.add_extension('lapack_lite',
sources = [get_lapack_lite_sources],
depends= ['lapack_litemodule.c',
- 'zlapack_lite.c', 'dlapack_lite.c',
- 'blas_lite.c', 'dlamch.c',
- 'f2c_lite.c','f2c.h'],
+ 'pythonxerbla.c',
+ 'zlapack_lite.c', 'dlapack_lite.c',
+ 'blas_lite.c', 'dlamch.c',
+ 'f2c_lite.c','f2c.h'],
extra_info = lapack_info
)
More information about the Numpy-svn
mailing list