diff options
author | Stefan van der Walt <stefan@sun.ac.za> | 2008-04-28 08:14:06 +0000 |
---|---|---|
committer | Stefan van der Walt <stefan@sun.ac.za> | 2008-04-28 08:14:06 +0000 |
commit | 56ec2be60ea1cfba72f79c96ee4151cec7be3d06 (patch) | |
tree | d07b7db5ee705b3b12b3631162038b4a162168ed /numpy/linalg/python_xerbla.c | |
parent | 28b0f986959cb92abc1e53029c100fb16b555e58 (diff) | |
download | numpy-56ec2be60ea1cfba72f79c96ee4151cec7be3d06.tar.gz |
Rename and reformat pythonxerbla.
Diffstat (limited to 'numpy/linalg/python_xerbla.c')
-rw-r--r-- | numpy/linalg/python_xerbla.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/numpy/linalg/python_xerbla.c b/numpy/linalg/python_xerbla.c new file mode 100644 index 000000000..ed0cac9b5 --- /dev/null +++ b/numpy/linalg/python_xerbla.c @@ -0,0 +1,36 @@ +#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. +*/ + +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; +} |