File: | numpy/linalg/lapack_litemodule.c |
Warning: | line 396, column 9 PyObject ownership leak with reference count of 1 |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /*This module contributed by Doug Heisterkamp | |||
2 | Modified by Jim Hugunin | |||
3 | More modifications by Jeff Whitaker | |||
4 | */ | |||
5 | #define NPY_NO_DEPRECATED_API0x0000000E NPY_API_VERSION0x0000000E | |||
6 | ||||
7 | #include "Python.h" | |||
8 | #include "numpy/arrayobject.h" | |||
9 | #include "npy_cblas.h" | |||
10 | ||||
11 | ||||
12 | #define FNAME(name)name_ BLAS_FUNC(name)name_ | |||
13 | ||||
14 | typedef CBLAS_INTint fortran_int; | |||
15 | ||||
16 | #ifdef HAVE_BLAS_ILP64 | |||
17 | ||||
18 | #if NPY_BITSOF_SHORT(2 * 8) == 64 | |||
19 | #define FINT_PYFMT"i" "h" | |||
20 | #elif NPY_BITSOF_INT(4 * 8) == 64 | |||
21 | #define FINT_PYFMT"i" "i" | |||
22 | #elif NPY_BITSOF_LONG(8 * 8) == 64 | |||
23 | #define FINT_PYFMT"i" "l" | |||
24 | #elif NPY_BITSOF_LONGLONG(8 * 8) == 64 | |||
25 | #define FINT_PYFMT"i" "L" | |||
26 | #else | |||
27 | #error No compatible 64-bit integer size. \ | |||
28 | Please contact NumPy maintainers and give detailed information about your \ | |||
29 | compiler and platform, or set NPY_USE_BLAS64_=0 | |||
30 | #endif | |||
31 | ||||
32 | #else | |||
33 | #define FINT_PYFMT"i" "i" | |||
34 | #endif | |||
35 | ||||
36 | typedef struct { float r, i; } f2c_complex; | |||
37 | typedef struct { double r, i; } f2c_doublecomplex; | |||
38 | /* typedef long int (*L_fp)(); */ | |||
39 | ||||
40 | extern fortran_int FNAME(dgelsd)dgelsd_(fortran_int *m, fortran_int *n, fortran_int *nrhs, | |||
41 | double a[], fortran_int *lda, double b[], fortran_int *ldb, | |||
42 | double s[], double *rcond, fortran_int *rank, | |||
43 | double work[], fortran_int *lwork, fortran_int iwork[], fortran_int *info); | |||
44 | ||||
45 | extern fortran_int FNAME(zgelsd)zgelsd_(fortran_int *m, fortran_int *n, fortran_int *nrhs, | |||
46 | f2c_doublecomplex a[], fortran_int *lda, | |||
47 | f2c_doublecomplex b[], fortran_int *ldb, | |||
48 | double s[], double *rcond, fortran_int *rank, | |||
49 | f2c_doublecomplex work[], fortran_int *lwork, | |||
50 | double rwork[], fortran_int iwork[], fortran_int *info); | |||
51 | ||||
52 | extern fortran_int FNAME(dgeqrf)dgeqrf_(fortran_int *m, fortran_int *n, double a[], fortran_int *lda, | |||
53 | double tau[], double work[], | |||
54 | fortran_int *lwork, fortran_int *info); | |||
55 | ||||
56 | extern fortran_int FNAME(zgeqrf)zgeqrf_(fortran_int *m, fortran_int *n, f2c_doublecomplex a[], fortran_int *lda, | |||
57 | f2c_doublecomplex tau[], f2c_doublecomplex work[], | |||
58 | fortran_int *lwork, fortran_int *info); | |||
59 | ||||
60 | extern fortran_int FNAME(dorgqr)dorgqr_(fortran_int *m, fortran_int *n, fortran_int *k, double a[], fortran_int *lda, | |||
61 | double tau[], double work[], | |||
62 | fortran_int *lwork, fortran_int *info); | |||
63 | ||||
64 | extern fortran_int FNAME(zungqr)zungqr_(fortran_int *m, fortran_int *n, fortran_int *k, f2c_doublecomplex a[], | |||
65 | fortran_int *lda, f2c_doublecomplex tau[], | |||
66 | f2c_doublecomplex work[], fortran_int *lwork, fortran_int *info); | |||
67 | ||||
68 | extern fortran_int FNAME(xerbla)xerbla_(char *srname, fortran_int *info); | |||
69 | ||||
70 | static PyObject *LapackError; | |||
71 | ||||
72 | #define TRY(E)if (!(E)) return ((void*)0) if (!(E)) return NULL((void*)0) | |||
73 | ||||
74 | static int | |||
75 | check_object(PyObject *ob, int t, char *obname, | |||
76 | char *tname, char *funname) | |||
77 | { | |||
78 | if (!PyArray_Check(ob)((((PyObject*)(ob))->ob_type) == (&(*(PyTypeObject *)PyArray_API [2])) || PyType_IsSubtype((((PyObject*)(ob))->ob_type), (& (*(PyTypeObject *)PyArray_API[2]))))) { | |||
79 | PyErr_Format(LapackError, | |||
80 | "Expected an array for parameter %s in lapack_lite.%s", | |||
81 | obname, funname); | |||
82 | return 0; | |||
83 | } | |||
84 | else if (!PyArray_IS_C_CONTIGUOUS((PyArrayObject *)ob)PyArray_CHKFLAGS(((PyArrayObject *)ob), 0x0001)) { | |||
85 | PyErr_Format(LapackError, | |||
86 | "Parameter %s is not contiguous in lapack_lite.%s", | |||
87 | obname, funname); | |||
88 | return 0; | |||
89 | } | |||
90 | else if (!(PyArray_TYPE((PyArrayObject *)ob) == t)) { | |||
91 | PyErr_Format(LapackError, | |||
92 | "Parameter %s is not of type %s in lapack_lite.%s", | |||
93 | obname, tname, funname); | |||
94 | return 0; | |||
95 | } | |||
96 | else if (PyArray_ISBYTESWAPPED((PyArrayObject *)ob)(!((PyArray_DESCR((PyArrayObject *)ob)->byteorder) != '>' ))) { | |||
97 | PyErr_Format(LapackError, | |||
98 | "Parameter %s has non-native byte order in lapack_lite.%s", | |||
99 | obname, funname); | |||
100 | return 0; | |||
101 | } | |||
102 | else { | |||
103 | return 1; | |||
104 | } | |||
105 | } | |||
106 | ||||
107 | #define CHDATA(p)((char *) PyArray_DATA((PyArrayObject *)p)) ((char *) PyArray_DATA((PyArrayObject *)p)) | |||
108 | #define SHDATA(p)((short int *) PyArray_DATA((PyArrayObject *)p)) ((short int *) PyArray_DATA((PyArrayObject *)p)) | |||
109 | #define DDATA(p)((double *) PyArray_DATA((PyArrayObject *)p)) ((double *) PyArray_DATA((PyArrayObject *)p)) | |||
110 | #define FDATA(p)((float *) PyArray_DATA((PyArrayObject *)p)) ((float *) PyArray_DATA((PyArrayObject *)p)) | |||
111 | #define CDATA(p)((f2c_complex *) PyArray_DATA((PyArrayObject *)p)) ((f2c_complex *) PyArray_DATA((PyArrayObject *)p)) | |||
112 | #define ZDATA(p)((f2c_doublecomplex *) PyArray_DATA((PyArrayObject *)p)) ((f2c_doublecomplex *) PyArray_DATA((PyArrayObject *)p)) | |||
113 | #define IDATA(p)((fortran_int *) PyArray_DATA((PyArrayObject *)p)) ((fortran_int *) PyArray_DATA((PyArrayObject *)p)) | |||
114 | ||||
115 | static PyObject * | |||
116 | lapack_lite_dgelsd(PyObject *NPY_UNUSED(self)(__NPY_UNUSED_TAGGEDself) __attribute__ ((__unused__)), PyObject *args) | |||
117 | { | |||
118 | fortran_int lapack_lite_status; | |||
119 | fortran_int m; | |||
120 | fortran_int n; | |||
121 | fortran_int nrhs; | |||
122 | PyObject *a; | |||
123 | fortran_int lda; | |||
124 | PyObject *b; | |||
125 | fortran_int ldb; | |||
126 | PyObject *s; | |||
127 | double rcond; | |||
128 | fortran_int rank; | |||
129 | PyObject *work; | |||
130 | PyObject *iwork; | |||
131 | fortran_int lwork; | |||
132 | fortran_int info; | |||
133 | ||||
134 | TRY(PyArg_ParseTuple(args,if (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "O" "i" "O" "d" "i" "O" "i" "O" "i" ":dgelsd"), &m,&n,&nrhs, &a,&lda,&b,&ldb,&s,&rcond, &rank, &work,&lwork,&iwork,&info))) return ((void*)0 ) | |||
135 | (FINT_PYFMT FINT_PYFMT FINT_PYFMT "O" FINT_PYFMT "O"if (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "O" "i" "O" "d" "i" "O" "i" "O" "i" ":dgelsd"), &m,&n,&nrhs, &a,&lda,&b,&ldb,&s,&rcond, &rank, &work,&lwork,&iwork,&info))) return ((void*)0 ) | |||
136 | FINT_PYFMT "O" "d" FINT_PYFMT "O" FINT_PYFMT "O"if (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "O" "i" "O" "d" "i" "O" "i" "O" "i" ":dgelsd"), &m,&n,&nrhs, &a,&lda,&b,&ldb,&s,&rcond, &rank, &work,&lwork,&iwork,&info))) return ((void*)0 ) | |||
137 | FINT_PYFMT ":dgelsd"),if (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "O" "i" "O" "d" "i" "O" "i" "O" "i" ":dgelsd"), &m,&n,&nrhs, &a,&lda,&b,&ldb,&s,&rcond, &rank, &work,&lwork,&iwork,&info))) return ((void*)0 ) | |||
138 | &m,&n,&nrhs,&a,&lda,&b,&ldb,&s,&rcond,if (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "O" "i" "O" "d" "i" "O" "i" "O" "i" ":dgelsd"), &m,&n,&nrhs, &a,&lda,&b,&ldb,&s,&rcond, &rank, &work,&lwork,&iwork,&info))) return ((void*)0 ) | |||
139 | &rank,&work,&lwork,&iwork,&info))if (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "O" "i" "O" "d" "i" "O" "i" "O" "i" ":dgelsd"), &m,&n,&nrhs, &a,&lda,&b,&ldb,&s,&rcond, &rank, &work,&lwork,&iwork,&info))) return ((void*)0 ); | |||
140 | ||||
141 | TRY(check_object(a,NPY_DOUBLE,"a","NPY_DOUBLE","dgelsd"))if (!(check_object(a,NPY_DOUBLE,"a","NPY_DOUBLE","dgelsd"))) return ((void*)0); | |||
142 | TRY(check_object(b,NPY_DOUBLE,"b","NPY_DOUBLE","dgelsd"))if (!(check_object(b,NPY_DOUBLE,"b","NPY_DOUBLE","dgelsd"))) return ((void*)0); | |||
143 | TRY(check_object(s,NPY_DOUBLE,"s","NPY_DOUBLE","dgelsd"))if (!(check_object(s,NPY_DOUBLE,"s","NPY_DOUBLE","dgelsd"))) return ((void*)0); | |||
144 | TRY(check_object(work,NPY_DOUBLE,"work","NPY_DOUBLE","dgelsd"))if (!(check_object(work,NPY_DOUBLE,"work","NPY_DOUBLE","dgelsd" ))) return ((void*)0); | |||
145 | #ifndef NPY_UMATH_USE_BLAS64_ | |||
146 | TRY(check_object(iwork,NPY_INT,"iwork","NPY_INT","dgelsd"))if (!(check_object(iwork,NPY_INT,"iwork","NPY_INT","dgelsd")) ) return ((void*)0); | |||
147 | #else | |||
148 | TRY(check_object(iwork,NPY_INT64,"iwork","NPY_INT64","dgelsd"))if (!(check_object(iwork,NPY_LONG,"iwork","NPY_INT64","dgelsd" ))) return ((void*)0); | |||
149 | #endif | |||
150 | ||||
151 | lapack_lite_status = | |||
152 | FNAME(dgelsd)dgelsd_(&m,&n,&nrhs,DDATA(a)((double *) PyArray_DATA((PyArrayObject *)a)),&lda,DDATA(b)((double *) PyArray_DATA((PyArrayObject *)b)),&ldb, | |||
153 | DDATA(s)((double *) PyArray_DATA((PyArrayObject *)s)),&rcond,&rank,DDATA(work)((double *) PyArray_DATA((PyArrayObject *)work)),&lwork, | |||
154 | IDATA(iwork)((fortran_int *) PyArray_DATA((PyArrayObject *)iwork)),&info); | |||
155 | if (PyErr_Occurred()) { | |||
156 | return NULL((void*)0); | |||
157 | } | |||
158 | ||||
159 | return Py_BuildValue(("{s:" FINT_PYFMT"i" ",s:" FINT_PYFMT"i" ",s:" FINT_PYFMT"i" | |||
160 | ",s:" FINT_PYFMT"i" ",s:" FINT_PYFMT"i" ",s:" FINT_PYFMT"i" | |||
161 | ",s:d,s:" FINT_PYFMT"i" ",s:" FINT_PYFMT"i" | |||
162 | ",s:" FINT_PYFMT"i" "}"), | |||
163 | "dgelsd_",lapack_lite_status,"m",m,"n",n,"nrhs",nrhs, | |||
164 | "lda",lda,"ldb",ldb,"rcond",rcond,"rank",rank, | |||
165 | "lwork",lwork,"info",info); | |||
166 | } | |||
167 | ||||
168 | static PyObject * | |||
169 | lapack_lite_dgeqrf(PyObject *NPY_UNUSED(self)(__NPY_UNUSED_TAGGEDself) __attribute__ ((__unused__)), PyObject *args) | |||
170 | { | |||
171 | fortran_int lapack_lite_status; | |||
172 | fortran_int m, n, lwork; | |||
173 | PyObject *a, *tau, *work; | |||
174 | fortran_int lda; | |||
175 | fortran_int info; | |||
176 | ||||
177 | TRY(PyArg_ParseTuple(args,if (!(PyArg_ParseTuple(args, ("i" "i" "O" "i" "OO" "i" "i" ":dgeqrf" ), &m,&n,&a,&lda,&tau,&work,&lwork ,&info))) return ((void*)0) | |||
178 | (FINT_PYFMT FINT_PYFMT "O" FINT_PYFMT "OO"if (!(PyArg_ParseTuple(args, ("i" "i" "O" "i" "OO" "i" "i" ":dgeqrf" ), &m,&n,&a,&lda,&tau,&work,&lwork ,&info))) return ((void*)0) | |||
179 | FINT_PYFMT FINT_PYFMT ":dgeqrf"),if (!(PyArg_ParseTuple(args, ("i" "i" "O" "i" "OO" "i" "i" ":dgeqrf" ), &m,&n,&a,&lda,&tau,&work,&lwork ,&info))) return ((void*)0) | |||
180 | &m,&n,&a,&lda,&tau,&work,&lwork,&info))if (!(PyArg_ParseTuple(args, ("i" "i" "O" "i" "OO" "i" "i" ":dgeqrf" ), &m,&n,&a,&lda,&tau,&work,&lwork ,&info))) return ((void*)0); | |||
181 | ||||
182 | /* check objects and convert to right storage order */ | |||
183 | TRY(check_object(a,NPY_DOUBLE,"a","NPY_DOUBLE","dgeqrf"))if (!(check_object(a,NPY_DOUBLE,"a","NPY_DOUBLE","dgeqrf"))) return ((void*)0); | |||
184 | TRY(check_object(tau,NPY_DOUBLE,"tau","NPY_DOUBLE","dgeqrf"))if (!(check_object(tau,NPY_DOUBLE,"tau","NPY_DOUBLE","dgeqrf" ))) return ((void*)0); | |||
185 | TRY(check_object(work,NPY_DOUBLE,"work","NPY_DOUBLE","dgeqrf"))if (!(check_object(work,NPY_DOUBLE,"work","NPY_DOUBLE","dgeqrf" ))) return ((void*)0); | |||
186 | ||||
187 | lapack_lite_status = | |||
188 | FNAME(dgeqrf)dgeqrf_(&m, &n, DDATA(a)((double *) PyArray_DATA((PyArrayObject *)a)), &lda, DDATA(tau)((double *) PyArray_DATA((PyArrayObject *)tau)), | |||
189 | DDATA(work)((double *) PyArray_DATA((PyArrayObject *)work)), &lwork, &info); | |||
190 | if (PyErr_Occurred()) { | |||
191 | return NULL((void*)0); | |||
192 | } | |||
193 | ||||
194 | return Py_BuildValue(("{s:" FINT_PYFMT"i" ",s:" FINT_PYFMT"i" ",s:" FINT_PYFMT"i" | |||
195 | ",s:" FINT_PYFMT"i" ",s:" FINT_PYFMT"i" ",s:" FINT_PYFMT"i" "}"), | |||
196 | "dgeqrf_", | |||
197 | lapack_lite_status,"m",m,"n",n,"lda",lda, | |||
198 | "lwork",lwork,"info",info); | |||
199 | } | |||
200 | ||||
201 | ||||
202 | static PyObject * | |||
203 | lapack_lite_dorgqr(PyObject *NPY_UNUSED(self)(__NPY_UNUSED_TAGGEDself) __attribute__ ((__unused__)), PyObject *args) | |||
204 | { | |||
205 | fortran_int lapack_lite_status; | |||
206 | fortran_int m, n, k, lwork; | |||
207 | PyObject *a, *tau, *work; | |||
208 | fortran_int lda; | |||
209 | fortran_int info; | |||
210 | ||||
211 | TRY(PyArg_ParseTuple(args,if (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "OO" "i" "i" ":dorgqr"), &m, &n, &k, &a, &lda, &tau , &work, &lwork, &info))) return ((void*)0) | |||
212 | (FINT_PYFMT FINT_PYFMT FINT_PYFMT "O"if (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "OO" "i" "i" ":dorgqr"), &m, &n, &k, &a, &lda, &tau , &work, &lwork, &info))) return ((void*)0) | |||
213 | FINT_PYFMT "OO" FINT_PYFMT FINT_PYFMTif (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "OO" "i" "i" ":dorgqr"), &m, &n, &k, &a, &lda, &tau , &work, &lwork, &info))) return ((void*)0) | |||
214 | ":dorgqr"),if (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "OO" "i" "i" ":dorgqr"), &m, &n, &k, &a, &lda, &tau , &work, &lwork, &info))) return ((void*)0) | |||
215 | &m, &n, &k, &a, &lda, &tau, &work, &lwork, &info))if (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "OO" "i" "i" ":dorgqr"), &m, &n, &k, &a, &lda, &tau , &work, &lwork, &info))) return ((void*)0); | |||
216 | TRY(check_object(a,NPY_DOUBLE,"a","NPY_DOUBLE","dorgqr"))if (!(check_object(a,NPY_DOUBLE,"a","NPY_DOUBLE","dorgqr"))) return ((void*)0); | |||
217 | TRY(check_object(tau,NPY_DOUBLE,"tau","NPY_DOUBLE","dorgqr"))if (!(check_object(tau,NPY_DOUBLE,"tau","NPY_DOUBLE","dorgqr" ))) return ((void*)0); | |||
218 | TRY(check_object(work,NPY_DOUBLE,"work","NPY_DOUBLE","dorgqr"))if (!(check_object(work,NPY_DOUBLE,"work","NPY_DOUBLE","dorgqr" ))) return ((void*)0); | |||
219 | lapack_lite_status = | |||
220 | FNAME(dorgqr)dorgqr_(&m, &n, &k, DDATA(a)((double *) PyArray_DATA((PyArrayObject *)a)), &lda, DDATA(tau)((double *) PyArray_DATA((PyArrayObject *)tau)), DDATA(work)((double *) PyArray_DATA((PyArrayObject *)work)), | |||
221 | &lwork, &info); | |||
222 | if (PyErr_Occurred()) { | |||
223 | return NULL((void*)0); | |||
224 | } | |||
225 | ||||
226 | return Py_BuildValue("{s:i,s:i}","dorgqr_",lapack_lite_status, | |||
227 | "info",info); | |||
228 | } | |||
229 | ||||
230 | ||||
231 | static PyObject * | |||
232 | lapack_lite_zgelsd(PyObject *NPY_UNUSED(self)(__NPY_UNUSED_TAGGEDself) __attribute__ ((__unused__)), PyObject *args) | |||
233 | { | |||
234 | fortran_int lapack_lite_status; | |||
235 | fortran_int m; | |||
236 | fortran_int n; | |||
237 | fortran_int nrhs; | |||
238 | PyObject *a; | |||
239 | fortran_int lda; | |||
240 | PyObject *b; | |||
241 | fortran_int ldb; | |||
242 | PyObject *s; | |||
243 | double rcond; | |||
244 | fortran_int rank; | |||
245 | PyObject *work; | |||
246 | fortran_int lwork; | |||
247 | PyObject *rwork; | |||
248 | PyObject *iwork; | |||
249 | fortran_int info; | |||
250 | TRY(PyArg_ParseTuple(args,if (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "O" "i" "Od" "i" "O" "i" "OO" "i" ":zgelsd"), &m,&n,&nrhs,& a,&lda,&b,&ldb,&s,&rcond, &rank,& work,&lwork,&rwork,&iwork,&info))) return ((void *)0) | |||
251 | (FINT_PYFMT FINT_PYFMT FINT_PYFMT "O" FINT_PYFMTif (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "O" "i" "Od" "i" "O" "i" "OO" "i" ":zgelsd"), &m,&n,&nrhs,& a,&lda,&b,&ldb,&s,&rcond, &rank,& work,&lwork,&rwork,&iwork,&info))) return ((void *)0) | |||
252 | "O" FINT_PYFMT "Od" FINT_PYFMT "O" FINT_PYFMTif (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "O" "i" "Od" "i" "O" "i" "OO" "i" ":zgelsd"), &m,&n,&nrhs,& a,&lda,&b,&ldb,&s,&rcond, &rank,& work,&lwork,&rwork,&iwork,&info))) return ((void *)0) | |||
253 | "OO" FINT_PYFMT ":zgelsd"),if (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "O" "i" "Od" "i" "O" "i" "OO" "i" ":zgelsd"), &m,&n,&nrhs,& a,&lda,&b,&ldb,&s,&rcond, &rank,& work,&lwork,&rwork,&iwork,&info))) return ((void *)0) | |||
254 | &m,&n,&nrhs,&a,&lda,&b,&ldb,&s,&rcond,if (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "O" "i" "Od" "i" "O" "i" "OO" "i" ":zgelsd"), &m,&n,&nrhs,& a,&lda,&b,&ldb,&s,&rcond, &rank,& work,&lwork,&rwork,&iwork,&info))) return ((void *)0) | |||
255 | &rank,&work,&lwork,&rwork,&iwork,&info))if (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "O" "i" "Od" "i" "O" "i" "OO" "i" ":zgelsd"), &m,&n,&nrhs,& a,&lda,&b,&ldb,&s,&rcond, &rank,& work,&lwork,&rwork,&iwork,&info))) return ((void *)0); | |||
256 | ||||
257 | TRY(check_object(a,NPY_CDOUBLE,"a","NPY_CDOUBLE","zgelsd"))if (!(check_object(a,NPY_CDOUBLE,"a","NPY_CDOUBLE","zgelsd")) ) return ((void*)0); | |||
258 | TRY(check_object(b,NPY_CDOUBLE,"b","NPY_CDOUBLE","zgelsd"))if (!(check_object(b,NPY_CDOUBLE,"b","NPY_CDOUBLE","zgelsd")) ) return ((void*)0); | |||
259 | TRY(check_object(s,NPY_DOUBLE,"s","NPY_DOUBLE","zgelsd"))if (!(check_object(s,NPY_DOUBLE,"s","NPY_DOUBLE","zgelsd"))) return ((void*)0); | |||
260 | TRY(check_object(work,NPY_CDOUBLE,"work","NPY_CDOUBLE","zgelsd"))if (!(check_object(work,NPY_CDOUBLE,"work","NPY_CDOUBLE","zgelsd" ))) return ((void*)0); | |||
261 | TRY(check_object(rwork,NPY_DOUBLE,"rwork","NPY_DOUBLE","zgelsd"))if (!(check_object(rwork,NPY_DOUBLE,"rwork","NPY_DOUBLE","zgelsd" ))) return ((void*)0); | |||
262 | #ifndef NPY_UMATH_USE_BLAS64_ | |||
263 | TRY(check_object(iwork,NPY_INT,"iwork","NPY_INT","zgelsd"))if (!(check_object(iwork,NPY_INT,"iwork","NPY_INT","zgelsd")) ) return ((void*)0); | |||
264 | #else | |||
265 | TRY(check_object(iwork,NPY_INT64,"iwork","NPY_INT64","zgelsd"))if (!(check_object(iwork,NPY_LONG,"iwork","NPY_INT64","zgelsd" ))) return ((void*)0); | |||
266 | #endif | |||
267 | ||||
268 | lapack_lite_status = | |||
269 | FNAME(zgelsd)zgelsd_(&m,&n,&nrhs,ZDATA(a)((f2c_doublecomplex *) PyArray_DATA((PyArrayObject *)a)),&lda,ZDATA(b)((f2c_doublecomplex *) PyArray_DATA((PyArrayObject *)b)),&ldb,DDATA(s)((double *) PyArray_DATA((PyArrayObject *)s)),&rcond, | |||
270 | &rank,ZDATA(work)((f2c_doublecomplex *) PyArray_DATA((PyArrayObject *)work)),&lwork,DDATA(rwork)((double *) PyArray_DATA((PyArrayObject *)rwork)),IDATA(iwork)((fortran_int *) PyArray_DATA((PyArrayObject *)iwork)),&info); | |||
271 | if (PyErr_Occurred()) { | |||
272 | return NULL((void*)0); | |||
273 | } | |||
274 | ||||
275 | return Py_BuildValue(("{s:" FINT_PYFMT"i" ",s:" FINT_PYFMT"i" ",s:" FINT_PYFMT"i" | |||
276 | ",s:" FINT_PYFMT"i" ",s:" FINT_PYFMT"i" ",s:" FINT_PYFMT"i" | |||
277 | ",s:" FINT_PYFMT"i" ",s:" FINT_PYFMT"i" ",s:" FINT_PYFMT"i" | |||
278 | "}"), | |||
279 | "zgelsd_", | |||
280 | lapack_lite_status,"m",m,"n",n,"nrhs",nrhs,"lda",lda, | |||
281 | "ldb",ldb,"rank",rank,"lwork",lwork,"info",info); | |||
282 | } | |||
283 | ||||
284 | static PyObject * | |||
285 | lapack_lite_zgeqrf(PyObject *NPY_UNUSED(self)(__NPY_UNUSED_TAGGEDself) __attribute__ ((__unused__)), PyObject *args) | |||
286 | { | |||
287 | fortran_int lapack_lite_status; | |||
288 | fortran_int m, n, lwork; | |||
289 | PyObject *a, *tau, *work; | |||
290 | fortran_int lda; | |||
291 | fortran_int info; | |||
292 | ||||
293 | TRY(PyArg_ParseTuple(args,if (!(PyArg_ParseTuple(args, ("i" "i" "O" "i" "OO" "i" "" "i" ":zgeqrf"), &m,&n,&a,&lda,&tau,&work ,&lwork,&info))) return ((void*)0) | |||
294 | (FINT_PYFMT FINT_PYFMT "O" FINT_PYFMT "OO"if (!(PyArg_ParseTuple(args, ("i" "i" "O" "i" "OO" "i" "" "i" ":zgeqrf"), &m,&n,&a,&lda,&tau,&work ,&lwork,&info))) return ((void*)0) | |||
295 | FINT_PYFMT "" FINT_PYFMT ":zgeqrf"),if (!(PyArg_ParseTuple(args, ("i" "i" "O" "i" "OO" "i" "" "i" ":zgeqrf"), &m,&n,&a,&lda,&tau,&work ,&lwork,&info))) return ((void*)0) | |||
296 | &m,&n,&a,&lda,&tau,&work,&lwork,&info))if (!(PyArg_ParseTuple(args, ("i" "i" "O" "i" "OO" "i" "" "i" ":zgeqrf"), &m,&n,&a,&lda,&tau,&work ,&lwork,&info))) return ((void*)0); | |||
297 | ||||
298 | /* check objects and convert to right storage order */ | |||
299 | TRY(check_object(a,NPY_CDOUBLE,"a","NPY_CDOUBLE","zgeqrf"))if (!(check_object(a,NPY_CDOUBLE,"a","NPY_CDOUBLE","zgeqrf")) ) return ((void*)0); | |||
300 | TRY(check_object(tau,NPY_CDOUBLE,"tau","NPY_CDOUBLE","zgeqrf"))if (!(check_object(tau,NPY_CDOUBLE,"tau","NPY_CDOUBLE","zgeqrf" ))) return ((void*)0); | |||
301 | TRY(check_object(work,NPY_CDOUBLE,"work","NPY_CDOUBLE","zgeqrf"))if (!(check_object(work,NPY_CDOUBLE,"work","NPY_CDOUBLE","zgeqrf" ))) return ((void*)0); | |||
302 | ||||
303 | lapack_lite_status = | |||
304 | FNAME(zgeqrf)zgeqrf_(&m, &n, ZDATA(a)((f2c_doublecomplex *) PyArray_DATA((PyArrayObject *)a)), &lda, ZDATA(tau)((f2c_doublecomplex *) PyArray_DATA((PyArrayObject *)tau)), ZDATA(work)((f2c_doublecomplex *) PyArray_DATA((PyArrayObject *)work)), | |||
305 | &lwork, &info); | |||
306 | if (PyErr_Occurred()) { | |||
307 | return NULL((void*)0); | |||
308 | } | |||
309 | ||||
310 | return Py_BuildValue(("{s:" FINT_PYFMT"i" ",s:" FINT_PYFMT"i" | |||
311 | ",s:" FINT_PYFMT"i" ",s:" FINT_PYFMT"i" | |||
312 | ",s:" FINT_PYFMT"i" ",s:" FINT_PYFMT"i" "}"), | |||
313 | "zgeqrf_",lapack_lite_status,"m",m,"n",n,"lda",lda,"lwork",lwork,"info",info); | |||
314 | } | |||
315 | ||||
316 | ||||
317 | static PyObject * | |||
318 | lapack_lite_zungqr(PyObject *NPY_UNUSED(self)(__NPY_UNUSED_TAGGEDself) __attribute__ ((__unused__)), PyObject *args) | |||
319 | { | |||
320 | fortran_int lapack_lite_status; | |||
321 | fortran_int m, n, k, lwork; | |||
322 | PyObject *a, *tau, *work; | |||
323 | fortran_int lda; | |||
324 | fortran_int info; | |||
325 | ||||
326 | TRY(PyArg_ParseTuple(args,if (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "OO" "i" "" "i" ":zungqr"), &m, &n, &k, &a, &lda, & tau, &work, &lwork, &info))) return ((void*)0) | |||
327 | (FINT_PYFMT FINT_PYFMT FINT_PYFMT "O"if (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "OO" "i" "" "i" ":zungqr"), &m, &n, &k, &a, &lda, & tau, &work, &lwork, &info))) return ((void*)0) | |||
328 | FINT_PYFMT "OO" FINT_PYFMT "" FINT_PYFMTif (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "OO" "i" "" "i" ":zungqr"), &m, &n, &k, &a, &lda, & tau, &work, &lwork, &info))) return ((void*)0) | |||
329 | ":zungqr"),if (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "OO" "i" "" "i" ":zungqr"), &m, &n, &k, &a, &lda, & tau, &work, &lwork, &info))) return ((void*)0) | |||
330 | &m, &n, &k, &a, &lda, &tau, &work, &lwork, &info))if (!(PyArg_ParseTuple(args, ("i" "i" "i" "O" "i" "OO" "i" "" "i" ":zungqr"), &m, &n, &k, &a, &lda, & tau, &work, &lwork, &info))) return ((void*)0); | |||
331 | TRY(check_object(a,NPY_CDOUBLE,"a","NPY_CDOUBLE","zungqr"))if (!(check_object(a,NPY_CDOUBLE,"a","NPY_CDOUBLE","zungqr")) ) return ((void*)0); | |||
332 | TRY(check_object(tau,NPY_CDOUBLE,"tau","NPY_CDOUBLE","zungqr"))if (!(check_object(tau,NPY_CDOUBLE,"tau","NPY_CDOUBLE","zungqr" ))) return ((void*)0); | |||
333 | TRY(check_object(work,NPY_CDOUBLE,"work","NPY_CDOUBLE","zungqr"))if (!(check_object(work,NPY_CDOUBLE,"work","NPY_CDOUBLE","zungqr" ))) return ((void*)0); | |||
334 | ||||
335 | ||||
336 | lapack_lite_status = | |||
337 | FNAME(zungqr)zungqr_(&m, &n, &k, ZDATA(a)((f2c_doublecomplex *) PyArray_DATA((PyArrayObject *)a)), &lda, ZDATA(tau)((f2c_doublecomplex *) PyArray_DATA((PyArrayObject *)tau)), ZDATA(work)((f2c_doublecomplex *) PyArray_DATA((PyArrayObject *)work)), | |||
338 | &lwork, &info); | |||
339 | if (PyErr_Occurred()) { | |||
340 | return NULL((void*)0); | |||
341 | } | |||
342 | ||||
343 | return Py_BuildValue(("{s:" FINT_PYFMT"i" ",s:" FINT_PYFMT"i" "}"), | |||
344 | "zungqr_",lapack_lite_status, | |||
345 | "info",info); | |||
346 | } | |||
347 | ||||
348 | ||||
349 | static PyObject * | |||
350 | lapack_lite_xerbla(PyObject *NPY_UNUSED(self)(__NPY_UNUSED_TAGGEDself) __attribute__ ((__unused__)), PyObject *args) | |||
351 | { | |||
352 | fortran_int info = -1; | |||
353 | ||||
354 | NPY_BEGIN_THREADS_DEFPyThreadState *_save=((void*)0);; | |||
355 | NPY_BEGIN_THREADSdo {_save = PyEval_SaveThread();} while (0);; | |||
356 | FNAME(xerbla)xerbla_("test", &info); | |||
357 | NPY_END_THREADSdo { if (_save) { PyEval_RestoreThread(_save); _save = ((void *)0);} } while (0);; | |||
358 | ||||
359 | if (PyErr_Occurred()) { | |||
360 | return NULL((void*)0); | |||
361 | } | |||
362 | Py_RETURN_NONEreturn _Py_INCREF(((PyObject*)((&_Py_NoneStruct)))), (& _Py_NoneStruct); | |||
363 | } | |||
364 | ||||
365 | ||||
366 | #define STR(x)"x" #x | |||
367 | #define lameth(name){"name", lapack_lite_name, 0x0001, ((void*)0)} {STR(name)"name", lapack_lite_##name, METH_VARARGS0x0001, NULL((void*)0)} | |||
368 | static struct PyMethodDef lapack_lite_module_methods[] = { | |||
369 | lameth(dgelsd){"dgelsd", lapack_lite_dgelsd, 0x0001, ((void*)0)}, | |||
370 | lameth(dgeqrf){"dgeqrf", lapack_lite_dgeqrf, 0x0001, ((void*)0)}, | |||
371 | lameth(dorgqr){"dorgqr", lapack_lite_dorgqr, 0x0001, ((void*)0)}, | |||
372 | lameth(zgelsd){"zgelsd", lapack_lite_zgelsd, 0x0001, ((void*)0)}, | |||
373 | lameth(zgeqrf){"zgeqrf", lapack_lite_zgeqrf, 0x0001, ((void*)0)}, | |||
374 | lameth(zungqr){"zungqr", lapack_lite_zungqr, 0x0001, ((void*)0)}, | |||
375 | lameth(xerbla){"xerbla", lapack_lite_xerbla, 0x0001, ((void*)0)}, | |||
376 | { NULL((void*)0),NULL((void*)0),0, NULL((void*)0)} | |||
377 | }; | |||
378 | ||||
379 | ||||
380 | static struct PyModuleDef moduledef = { | |||
381 | PyModuleDef_HEAD_INIT{ { 1, ((void*)0) }, ((void*)0), 0, ((void*)0), }, | |||
382 | "lapack_lite", | |||
383 | NULL((void*)0), | |||
384 | -1, | |||
385 | lapack_lite_module_methods, | |||
386 | NULL((void*)0), | |||
387 | NULL((void*)0), | |||
388 | NULL((void*)0), | |||
389 | NULL((void*)0) | |||
390 | }; | |||
391 | ||||
392 | /* Initialization function for the module */ | |||
393 | PyMODINIT_FUNCPyObject* PyInit_lapack_lite(void) | |||
394 | { | |||
395 | PyObject *m,*d; | |||
396 | m = PyModule_Create(&moduledef)PyModule_Create2(&moduledef, 1013); | |||
| ||||
| ||||
397 | if (m == NULL((void*)0)) { | |||
398 | return NULL((void*)0); | |||
399 | } | |||
400 | import_array(){if (_import_array() < 0) {PyErr_Print(); PyErr_SetString( PyExc_ImportError, "numpy.core.multiarray failed to import"); return ((void*)0); } }; | |||
401 | d = PyModule_GetDict(m); | |||
402 | LapackError = PyErr_NewException("lapack_lite.LapackError", NULL((void*)0), NULL((void*)0)); | |||
403 | PyDict_SetItemString(d, "LapackError", LapackError); | |||
404 | ||||
405 | #ifdef HAVE_BLAS_ILP64 | |||
406 | PyDict_SetItemString(d, "_ilp64", Py_True((PyObject *) &_Py_TrueStruct)); | |||
407 | #else | |||
408 | PyDict_SetItemString(d, "_ilp64", Py_False((PyObject *) &_Py_FalseStruct)); | |||
409 | #endif | |||
410 | ||||
411 | return m; | |||
412 | } |
1 | #ifndef PyModule_Create2 |
2 | struct _object; |
3 | typedef struct _object PyObject; |
4 | PyObject* clang_analyzer_PyObject_New_Reference(); |
5 | PyObject* PyModule_Create2(PyModuleDef *def, int module_api_version) { |
6 | return clang_analyzer_PyObject_New_Reference(); |
7 | } |
8 | #else |
9 | #warning "API PyModule_Create2 is defined as a macro." |
10 | #endif |