1
#include "Python.h"
2
#include "numpy/npy_common.h"
3
#include "npy_cblas.h"
4

5
/*
6
  From the original manpage:
7
  --------------------------
8
  XERBLA is an error handler for the LAPACK routines.
9
  It is called by an LAPACK routine if an input parameter has an invalid value.
10
  A message is printed and execution stops.
11

12
  Instead of printing a message and stopping the execution, a
13
  ValueError is raised with the message.
14

15
  Parameters:
16
  -----------
17
  srname: Subroutine name to use in error message, maximum six characters.
18
          Spaces at the end are skipped.
19
  info: Number of the invalid parameter.
20
*/
21

22 0
CBLAS_INT BLAS_FUNC(xerbla)(char *srname, CBLAS_INT *info)
23
{
24
        static const char format[] = "On entry to %.*s" \
25
                " parameter number %d had an illegal value";
26
        char buf[sizeof(format) + 6 + 4];   /* 6 for name, 4 for param. num. */
27

28 0
        int len = 0; /* length of subroutine name*/
29
#ifdef WITH_THREAD
30
        PyGILState_STATE save;
31
#endif
32

33 0
        while( len<6 && srname[len]!='\0' )
34 0
                len++;
35 0
        while( len && srname[len-1]==' ' )
36 0
                len--;
37
#ifdef WITH_THREAD
38 0
        save = PyGILState_Ensure();
39
#endif
40 0
        PyOS_snprintf(buf, sizeof(buf), format, len, srname, (int)*info);
41 0
        PyErr_SetString(PyExc_ValueError, buf);
42
#ifdef WITH_THREAD
43 0
        PyGILState_Release(save);
44
#endif
45

46 0
        return 0;
47
}

Read our documentation on viewing source code .

Loading