~ubuntu-branches/ubuntu/saucy/python-scipy/saucy

« back to all changes in this revision

Viewing changes to Lib/linsolve/umfpack/umfpack.i

  • Committer: Bazaar Package Importer
  • Author(s): Ondrej Certik
  • Date: 2008-06-16 22:58:01 UTC
  • mfrom: (2.1.24 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080616225801-irdhrpcwiocfbcmt
Tags: 0.6.0-12
* The description updated to match the current SciPy (Closes: #489149).
* Standards-Version bumped to 3.8.0 (no action needed)
* Build-Depends: netcdf-dev changed to libnetcdf-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%module _umfpack
2
 
 
3
 
/*
4
 
  See umfpack.py for more information.
5
 
 
6
 
  Created by: Robert Cimrman
7
 
*/
8
 
 
9
 
%{
10
 
#include <umfpack.h>
11
 
#include "numpy/arrayobject.h"
12
 
%}
13
 
 
14
 
%feature("autodoc", "1");
15
 
 
16
 
#include <umfpack.h>
17
 
 
18
 
%init %{
19
 
    import_array();
20
 
%}
21
 
 
22
 
%{
23
 
/*!
24
 
  Appends @a what to @a where. On input, @a where need not to be a tuple, but on
25
 
  return it always is.
26
 
 
27
 
  @par Revision history:
28
 
  - 17.02.2005, c
29
 
*/
30
 
PyObject *helper_appendToTuple( PyObject *where, PyObject *what ) {
31
 
  PyObject *o2, *o3;
32
 
 
33
 
  if ((!where) || (where == Py_None)) {
34
 
    where = what;
35
 
  } else {
36
 
    if (!PyTuple_Check( where )) {
37
 
      o2 = where;
38
 
      where = PyTuple_New( 1 );
39
 
      PyTuple_SetItem( where, 0, o2 );
40
 
    }
41
 
    o3 = PyTuple_New( 1 );
42
 
    PyTuple_SetItem( o3, 0, what );
43
 
    o2 = where;
44
 
    where = PySequence_Concat( o2, o3 );
45
 
    Py_DECREF( o2 );
46
 
    Py_DECREF( o3 );
47
 
  }
48
 
  return where;
49
 
}
50
 
 
51
 
/*!
52
 
  Gets PyArrayObject from a PyObject.
53
 
 
54
 
  @par Revision history:
55
 
  - 22.02.2005, c
56
 
  - 03.03.2005
57
 
  - 25.11.2005
58
 
  - 30.11.2005
59
 
  - 01.12.2005
60
 
*/
61
 
PyArrayObject *helper_getCArrayObject( PyObject *input, int type,
62
 
                                       int minDim, int maxDim ) {
63
 
  PyArrayObject *obj;
64
 
 
65
 
  if (PyArray_Check( input )) {
66
 
    obj = (PyArrayObject *) input;
67
 
    if (!PyArray_ISCARRAY( obj )) {
68
 
      PyErr_SetString( PyExc_TypeError, "not a C array" );
69
 
      return NULL;
70
 
    }
71
 
    obj = (PyArrayObject *)
72
 
      PyArray_ContiguousFromAny( input, type, minDim, maxDim );
73
 
    if (!obj) return NULL;
74
 
  } else {
75
 
    PyErr_SetString( PyExc_TypeError, "not an array" );
76
 
    return NULL;
77
 
  }
78
 
  return obj;
79
 
}
80
 
%}
81
 
 
82
 
/*!
83
 
  Use for arrays as input arguments. Could be also used for changing an array
84
 
  in place.
85
 
 
86
 
  @a rtype ... return this C data type
87
 
  @a ctype ... C data type of the C function
88
 
  @a atype ... PyArray_* suffix
89
 
 
90
 
  @par Revision history:
91
 
  - 30.11.2005, c
92
 
*/
93
 
#define ARRAY_IN( rtype, ctype, atype ) \
94
 
%typemap( python, in ) (ctype *array) { \
95
 
  PyArrayObject *obj; \
96
 
  obj = helper_getCArrayObject( $input, PyArray_##atype, 1, 1 ); \
97
 
  if (!obj) return NULL; \
98
 
  $1 = (rtype *) obj->data; \
99
 
  Py_DECREF( obj ); \
100
 
};
101
 
 
102
 
/*!
103
 
  @par Revision history:
104
 
  - 30.11.2005, c
105
 
*/
106
 
#define CONF_IN( arSize ) \
107
 
%typemap( python, in ) (double conf [arSize]) { \
108
 
  PyArrayObject *obj; \
109
 
  obj = helper_getCArrayObject( $input, PyArray_DOUBLE, 1, 1 ); \
110
 
  if (!obj) return NULL; \
111
 
  if ((obj->nd != 1) || (obj->dimensions[0] != arSize)) { \
112
 
    PyErr_SetString( PyExc_ValueError, "wrong Control/Info array size" ); \
113
 
    Py_DECREF( obj ); \
114
 
    return NULL; \
115
 
  } \
116
 
  $1 = (double *) obj->data; \
117
 
};
118
 
 
119
 
/*!
120
 
  @par Revision history:
121
 
  - 01.12.2005, c
122
 
  - 02.12.2005
123
 
*/
124
 
#define OPAQUE_ARGOUT( ttype ) \
125
 
%typemap( python, in, numinputs=0 ) ttype* opaque_argout( ttype tmp ) { \
126
 
  $1 = &tmp; \
127
 
}; \
128
 
%typemap( python, argout ) ttype* opaque_argout { \
129
 
  PyObject *obj; \
130
 
  obj = SWIG_NewPointerObj( (ttype) (*$1), $*1_descriptor, 1 ); \
131
 
  $result = helper_appendToTuple( $result, obj ); \
132
 
};
133
 
 
134
 
/*!
135
 
  @par Revision history:
136
 
  - 02.12.2005, c
137
 
*/
138
 
#define OPAQUE_ARGINOUT( ttype ) \
139
 
%typemap( python, in ) ttype* opaque_arginout( ttype tmp ) { \
140
 
  if ((SWIG_ConvertPtr( $input,(void **) &tmp, $*1_descriptor, \
141
 
                        SWIG_POINTER_EXCEPTION)) == -1) return NULL; \
142
 
  $1 = &tmp; \
143
 
}; \
144
 
%typemap( python, argout ) ttype* opaque_arginout { \
145
 
  PyObject *obj; \
146
 
  obj = SWIG_NewPointerObj( (ttype) (*$1), $*1_descriptor, 1 ); \
147
 
  $result = helper_appendToTuple( $result, obj ); \
148
 
};
149
 
 
150
 
ARRAY_IN( int, const int, INT )
151
 
%apply const int *array {
152
 
    const int Ap [ ],
153
 
    const int Ai [ ]
154
 
};
155
 
 
156
 
ARRAY_IN( long, const long, LONG )
157
 
%apply const long *array {
158
 
    const long Ap [ ],
159
 
    const long Ai [ ]
160
 
};
161
 
 
162
 
ARRAY_IN( double, const double, DOUBLE )
163
 
%apply const double *array {
164
 
    const double Ax [ ],
165
 
    const double Az [ ],
166
 
    const double B [ ],
167
 
    const double Bx [ ],
168
 
    const double Bz [ ]
169
 
};
170
 
 
171
 
ARRAY_IN( double, double, DOUBLE )
172
 
%apply double *array {
173
 
    double X [ ],
174
 
    double Xx [ ],
175
 
    double Xz [ ]
176
 
};
177
 
 
178
 
CONF_IN( UMFPACK_CONTROL )
179
 
%apply (double conf [UMFPACK_CONTROL]) {
180
 
    double Control [ANY]
181
 
};
182
 
 
183
 
CONF_IN( UMFPACK_INFO )
184
 
%apply double conf [UMFPACK_INFO] {
185
 
    double Info [ANY]
186
 
};
187
 
 
188
 
%include <umfpack.h>
189
 
%include <umfpack_solve.h>
190
 
%include <umfpack_defaults.h>
191
 
%include <umfpack_triplet_to_col.h>
192
 
%include <umfpack_col_to_triplet.h>
193
 
%include <umfpack_transpose.h>
194
 
%include <umfpack_scale.h>
195
 
 
196
 
%include <umfpack_report_symbolic.h>
197
 
%include <umfpack_report_numeric.h>
198
 
%include <umfpack_report_info.h>
199
 
%include <umfpack_report_control.h>
200
 
 
201
 
/*
202
 
  The order is important below!
203
 
*/
204
 
 
205
 
OPAQUE_ARGOUT( void * )
206
 
%apply  void ** opaque_argout {
207
 
    void **Symbolic,
208
 
    void **Numeric
209
 
}
210
 
 
211
 
%include <umfpack_symbolic.h>
212
 
%include <umfpack_numeric.h>
213
 
 
214
 
 
215
 
OPAQUE_ARGINOUT( void * )
216
 
%apply  void ** opaque_arginout {
217
 
    void **Symbolic,
218
 
    void **Numeric
219
 
}
220
 
 
221
 
%include <umfpack_free_symbolic.h>
222
 
%include <umfpack_free_numeric.h>
223
 
 
224
 
 
225
 
 
226
 
/*
227
 
 * wnbell - attempt to get L,U,P,Q out
228
 
 */
229
 
%include "typemaps.i"
230
 
%apply int  *OUTPUT {
231
 
    int *lnz,
232
 
    int *unz,
233
 
    int *n_row,
234
 
    int *n_col,
235
 
    int *nz_udiag
236
 
};
237
 
%apply long *OUTPUT {
238
 
    long *lnz,
239
 
    long *unz,
240
 
    long *n_row,
241
 
    long *n_col,
242
 
    long *nz_udiag
243
 
};
244
 
%include <umfpack_get_lunz.h>
245
 
 
246
 
 
247
 
ARRAY_IN( double, double, DOUBLE )
248
 
%apply double *array {
249
 
    double Lx [ ],
250
 
    double Lz [ ],
251
 
    double Ux [ ],
252
 
    double Uz [ ],
253
 
    double Dx [ ],
254
 
    double Dz [ ],
255
 
    double Rs [ ]
256
 
};
257
 
 
258
 
ARRAY_IN( int, int, INT )
259
 
%apply int *array {
260
 
    int Lp [ ],
261
 
    int Lj [ ],
262
 
    int Up [ ],
263
 
    int Ui [ ],
264
 
    int P [ ],
265
 
    int Q [ ]
266
 
};
267
 
%apply int  *OUTPUT { int *do_recip};
268
 
%include <umfpack_get_numeric.h>