1 // SWIG file ComplexTensor.i
2 
3 %{
4 #include "openturns/ComplexTensor.hxx"
5 %}
6 
7 %include ComplexTensor_doc.i
8 
9 %template(ComplexTensorImplementationTypedInterfaceObject) OT::TypedInterfaceObject<OT::ComplexTensorImplementation>;
10 %apply const ComplexCollection & { const OT::ComplexTensor::ComplexCollection & };
11 
12 %rename(__baseaddress__) OT::ComplexTensor::data;
13 %rename(__elementsize__) OT::ComplexTensor::elementSize;
14 %rename(__stride__) OT::ComplexTensor::stride;
15 
16 %include openturns/ComplexTensor.hxx
17 
18 %pythoncode %{
19 # This code has been added to conform to Numpy ndarray interface
20 # that tries to reuse the data stored in the ComplexTensor (zero copy)
21 # see http://docs.scipy.org/doc/numpy/reference/arrays.interface.html#arrays-interface
22 # for details.
23 # See python doc http://docs.python.org/reference/datamodel.html?highlight=getattribute#object.__getattribute__
24 # for details on how to write such a method.
25 def ComplexTensor___getattribute__(self, name):
26     """Implement attribute accesses."""
27     if (name == '__array_interface__'):
28         self.__dict__['__array_interface__'] = {'shape': (self.getNbRows(), self.getNbColumns(), self.getNbSheets()),
29                                                 'typestr': "|c" + str(self.__elementsize__()),
30                                                 'data': (int(self.__baseaddress__()), True),
31                                                 'strides': (self.__stride__(0), self.__stride__(1), self.__stride__(2)),
32                                                 'version': 3,
33                                                 }
34     return object.__getattribute__(self, name)
35 ComplexTensor.__getattribute__ = ComplexTensor___getattribute__
36 %}
37 
38 namespace OT {
39 
40 %extend ComplexTensor {
41 
42   ComplexTensor(const ComplexTensor & other) { return new OT::ComplexTensor(other); }
43 
44   ComplexTensor(PyObject * pyObj) { return new OT::ComplexTensor( OT::convert<OT::_PySequence_,OT::ComplexTensor>(pyObj) ); }
45 
46   OTTensorAccessors(ComplexTensor, Complex, _PyComplex_)
47 
48 } // ComplexTensor
49 } // OT
50