1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
|
/* -*- C -*- (not really, but good for syntax highlighting) */
/*%module sparsetools*/
/* why does SWIG complain about int arrays? a typecheck is provided */
#pragma SWIG nowarn=467
%{
#include "py3k.h"
#define SWIG_FILE_WITH_INIT
#include "Python.h"
#include "numpy/arrayobject.h"
#include "complex_ops.h"
/*#include "sparsetools.h"*/
%}
%feature("autodoc", "1");
%include "numpy.i"
%init %{
import_array();
%}
/*
* IN types
*/
%define I_IN_ARRAY1( ctype )
%apply ctype * IN_ARRAY1 {
const ctype Ap [ ],
const ctype Ai [ ],
const ctype Aj [ ],
const ctype Bp [ ],
const ctype Bi [ ],
const ctype Bj [ ],
const ctype Cp [ ],
const ctype Ci [ ],
const ctype Cj [ ],
const ctype offsets [ ]
};
%enddef
%define T_IN_ARRAY1( ctype )
%apply ctype * IN_ARRAY1 {
const ctype Ax [ ],
const ctype Bx [ ],
const ctype Cx [ ],
const ctype Xx [ ],
const ctype Yx [ ]
};
%enddef
%define T_IN_ARRAY2( ctype )
%apply ctype * IN_ARRAY2 {
const ctype Mx [ ],
const ctype diags [ ]
};
%enddef
/*
* OUT types
*/
%define I_ARRAY_ARGOUT( ctype )
%apply std::vector<ctype>* array_argout {
std::vector<ctype>* Ap,
std::vector<ctype>* Ai,
std::vector<ctype>* Aj,
std::vector<ctype>* Bp,
std::vector<ctype>* Bi,
std::vector<ctype>* Bj,
std::vector<ctype>* Cp,
std::vector<ctype>* Ci,
std::vector<ctype>* Cj
};
%enddef
%define T_ARRAY_ARGOUT( ctype )
%apply std::vector<ctype>* array_argout {
std::vector<ctype>* Ax,
std::vector<ctype>* Bx,
std::vector<ctype>* Cx,
std::vector<ctype>* Xx,
std::vector<ctype>* Yx
};
%enddef
/*
* INOUT types
*/
%define I_INPLACE_ARRAY1( ctype )
%apply ctype * INPLACE_ARRAY {
ctype Ap [ ],
ctype Ai [ ],
ctype Aj [ ],
ctype Bp [ ],
ctype Bi [ ],
ctype Bj [ ],
ctype Cp [ ],
ctype Ci [ ],
ctype Cj [ ],
ctype flag [ ]
};
%enddef
%define T_INPLACE_ARRAY1( ctype )
%apply ctype * INPLACE_ARRAY {
ctype Ax [ ],
ctype Bx [ ],
ctype Cx [ ],
ctype Yx [ ]
};
%enddef
%define T_INPLACE_ARRAY2( ctype )
%apply ctype * INPLACE_ARRAY2 {
ctype Mx [ ]
};
%enddef
/*
* Macros to instantiate index types and data types
*/
%define DECLARE_INDEX_TYPE( ctype )
I_IN_ARRAY1( ctype )
I_ARRAY_ARGOUT( ctype )
I_INPLACE_ARRAY1( ctype )
%enddef
%define DECLARE_DATA_TYPE( ctype )
T_IN_ARRAY1( ctype )
T_IN_ARRAY2( ctype )
T_ARRAY_ARGOUT( ctype )
T_INPLACE_ARRAY1( ctype )
T_INPLACE_ARRAY2( ctype )
%enddef
/*
* Create all desired index and data types here
*/
DECLARE_INDEX_TYPE( int )
DECLARE_DATA_TYPE( signed char )
DECLARE_DATA_TYPE( unsigned char )
DECLARE_DATA_TYPE( short )
DECLARE_DATA_TYPE( unsigned short )
DECLARE_DATA_TYPE( int )
DECLARE_DATA_TYPE( unsigned int )
DECLARE_DATA_TYPE( long long )
DECLARE_DATA_TYPE( unsigned long long )
DECLARE_DATA_TYPE( float )
DECLARE_DATA_TYPE( double )
DECLARE_DATA_TYPE( long double )
DECLARE_DATA_TYPE( npy_cfloat_wrapper )
DECLARE_DATA_TYPE( npy_cdouble_wrapper )
DECLARE_DATA_TYPE( npy_clongdouble_wrapper )
/*%include "sparsetools.h"*/
/*
* Order is important here, list int before float, float before
* double, scalar before complex, etc.
*/
%define INSTANTIATE_ALL( f_name )
/* 32-bit indices */
%template(f_name) f_name<int,signed char>;
%template(f_name) f_name<int,unsigned char>;
%template(f_name) f_name<int,short>;
%template(f_name) f_name<int,unsigned short>;
%template(f_name) f_name<int,int>;
%template(f_name) f_name<int,unsigned int>;
%template(f_name) f_name<int,long long>;
%template(f_name) f_name<int,unsigned long long>;
%template(f_name) f_name<int,float>;
%template(f_name) f_name<int,double>;
%template(f_name) f_name<int,long double>;
%template(f_name) f_name<int,npy_cfloat_wrapper>;
%template(f_name) f_name<int,npy_cdouble_wrapper>;
%template(f_name) f_name<int,npy_clongdouble_wrapper>;
/* 64-bit indices would go here */
%enddef
%define INSTANTIATE_INDEX( f_name )
/* 32-bit indices */
%template(f_name) f_name<int>;
/* 64-bit indices would go here */
%enddef
|