}
}
-void DataArrayDouble::useArray(const double *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo)
+void DataArrayDouble::useArray(const double *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo)
{
_nb_of_tuples=nbOfTuple;
_info_on_compo.resize(nbOfCompo);
declareAsNew();
}
+void DataArrayDouble::useExternalArrayWithRWAccess(const double *array, int nbOfTuple, int nbOfCompo)
+{
+ _nb_of_tuples=nbOfTuple;
+ _info_on_compo.resize(nbOfCompo);
+ _mem.useExternalArrayWithRWAccess(array,nbOfTuple*nbOfCompo);
+ declareAsNew();
+}
+
void DataArrayDouble::checkNoNullValues() const throw(INTERP_KERNEL::Exception)
{
const double *tmp=getConstPointer();
if((_nb_of_compo==nbOfCompo && nbOfTuples==1) || (_nb_of_compo==nbOfTuples && nbOfCompo==1))
{
DataArrayDouble *ret=DataArrayDouble::New();
- ret->useArray(_pt,false,CPP_DEALLOC,nbOfTuples,nbOfCompo);
+ ret->useExternalArrayWithRWAccess(_pt,nbOfTuples,nbOfCompo);
return ret;
}
else
declareAsNew();
}
+void DataArrayInt::useExternalArrayWithRWAccess(const int *array, int nbOfTuple, int nbOfCompo)
+{
+ _nb_of_tuples=nbOfTuple;
+ _info_on_compo.resize(nbOfCompo);
+ _mem.useExternalArrayWithRWAccess(array,nbOfTuple*nbOfCompo);
+ declareAsNew();
+}
+
DataArrayInt *DataArrayInt::fromNoInterlace() const throw(INTERP_KERNEL::Exception)
{
if(_mem.isNull())
if((_nb_of_compo==nbOfCompo && nbOfTuples==1) || (_nb_of_compo==nbOfTuples && nbOfCompo==1))
{
DataArrayInt *ret=DataArrayInt::New();
- ret->useArray(_pt,false,CPP_DEALLOC,nbOfTuples,nbOfCompo);
+ ret->useExternalArrayWithRWAccess(_pt,nbOfTuples,nbOfCompo);
return ret;
}
else
void alloc(int nbOfElements) throw(INTERP_KERNEL::Exception);
void reAlloc(int newNbOfElements) throw(INTERP_KERNEL::Exception);
void useArray(const T *array, bool ownership, DeallocType type, int nbOfElem);
+ void useExternalArrayWithRWAccess(const T *array, int nbOfElem);
void writeOnPlace(int id, T element0, const T *others, int sizeOfOthers);
~MemArray() { destroy(); }
private:
MEDCOUPLING_EXPORT const double *begin() const { return getConstPointer(); }
MEDCOUPLING_EXPORT const double *end() const { return getConstPointer()+getNbOfElems(); }
MEDCOUPLING_EXPORT void useArray(const double *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
+ MEDCOUPLING_EXPORT void useExternalArrayWithRWAccess(const double *array, int nbOfTuple, int nbOfCompo);
MEDCOUPLING_EXPORT void writeOnPlace(int id, double element0, const double *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
MEDCOUPLING_EXPORT void checkNoNullValues() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void getMinMaxPerComponent(double *bounds) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *duplicateEachTupleNTimes(int nbTimes) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT std::set<int> getDifferentValues() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
+ MEDCOUPLING_EXPORT void useExternalArrayWithRWAccess(const int *array, int nbOfTuple, int nbOfCompo);
MEDCOUPLING_EXPORT void writeOnPlace(int id, int element0, const int *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
MEDCOUPLING_EXPORT static DataArrayInt *Add(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void addEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);
_dealloc=type;
}
+ template<class T>
+ void MemArray<T>::useExternalArrayWithRWAccess(const T *array, int nbOfElem)
+ {
+ _nb_of_elem=nbOfElem;
+ destroy();
+ _pointer.setInternal(const_cast<T *>(array));
+ _ownership=false;
+ _dealloc=CPP_DEALLOC;
+ }
+
template<class T>
void MemArray<T>::writeOnPlace(int id, T element0, const T *others, int sizeOfOthers)
{
def ParaMEDMEMDataArrayIntImod(self,*args):
import _MEDCoupling
return _MEDCoupling.DataArrayInt____imod___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleTupleIadd(self,*args):
+ import _MEDCoupling
+ return _MEDCoupling.DataArrayDoubleTuple____iadd___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleTupleIsub(self,*args):
+ import _MEDCoupling
+ return _MEDCoupling.DataArrayDoubleTuple____isub___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleTupleImul(self,*args):
+ import _MEDCoupling
+ return _MEDCoupling.DataArrayDoubleTuple____imul___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleTupleIdiv(self,*args):
+ import _MEDCoupling
+ return _MEDCoupling.DataArrayDoubleTuple____idiv___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleIadd(self,*args):
+ import _MEDCoupling
+ return _MEDCoupling.DataArrayIntTuple____iadd___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleIsub(self,*args):
+ import _MEDCoupling
+ return _MEDCoupling.DataArrayIntTuple____isub___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleImul(self,*args):
+ import _MEDCoupling
+ return _MEDCoupling.DataArrayIntTuple____imul___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleIdiv(self,*args):
+ import _MEDCoupling
+ return _MEDCoupling.DataArrayIntTuple____idiv___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleImod(self,*args):
+ import _MEDCoupling
+ return _MEDCoupling.DataArrayIntTuple____imod___(self, self, *args)
%}
%include "MEDCouplingFinalize.i"
pass
pass
+ def testSwigDataTupleIOp1(self):
+ d=DataArrayDouble(10,1)
+ d.iota(7.)
+ for elt in d:
+ elt+=2.
+ pass
+ toTest=DataArrayDouble([9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0])
+ self.assertTrue(toTest.isEqual(d,1e-12))
+ for elt in d:
+ elt-=2.
+ pass
+ toTest=DataArrayDouble([7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0])
+ self.assertTrue(toTest.isEqual(d,1e-12))
+ for elt in d:
+ elt*=2.
+ pass
+ toTest=DataArrayDouble([14.0,16.0,18.0,20.0,22.0,24.0,26.0,28.0,30.0,32.0])
+ self.assertTrue(toTest.isEqual(d,1e-12))
+ for elt in d:
+ elt/=2.
+ pass
+ toTest=DataArrayDouble([7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0])
+ self.assertTrue(toTest.isEqual(d,1e-12))
+ #
+ d=DataArrayInt(10,1)
+ d.iota(7)
+ for elt in d:
+ elt+=2
+ pass
+ self.assertEqual(d.getValues(),[9,10,11,12,13,14,15,16,17,18])
+ for elt in d:
+ elt-=2
+ pass
+ self.assertEqual(d.getValues(),[7,8,9,10,11,12,13,14,15,16])
+ for elt in d:
+ elt*=2
+ pass
+ self.assertEqual(d.getValues(),[14,16,18,20,22,24,26,28,30,32])
+ for elt in d:
+ elt/=2
+ pass
+ self.assertEqual(d.getValues(),[7,8,9,10,11,12,13,14,15,16])
+ for elt in d:
+ elt%=3
+ pass
+ self.assertEqual(d.getValues(),[1,2,0,1,2,0,1,2,0,1])
+ pass
+
def setUp(self):
pass
pass
{
return self->buildDADouble(1,self->getNumberOfCompo());
}
+
+ PyObject *___iadd___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->buildDADouble(1,self->getNumberOfCompo());
+ ParaMEDMEM_DataArrayDouble____iadd___(ret,0,obj);
+ Py_XINCREF(trueSelf);
+ return trueSelf;
+ }
+ PyObject *___isub___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->buildDADouble(1,self->getNumberOfCompo());
+ ParaMEDMEM_DataArrayDouble____isub___(ret,0,obj);
+ Py_XINCREF(trueSelf);
+ return trueSelf;
+ }
+
+ PyObject *___imul___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->buildDADouble(1,self->getNumberOfCompo());
+ ParaMEDMEM_DataArrayDouble____imul___(ret,0,obj);
+ Py_XINCREF(trueSelf);
+ return trueSelf;
+ }
+
+ PyObject *___idiv___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->buildDADouble(1,self->getNumberOfCompo());
+ ParaMEDMEM_DataArrayDouble____idiv___(ret,0,obj);
+ Py_XINCREF(trueSelf);
+ return trueSelf;
+ }
+
PyObject *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
{
int sw;
{
return self->buildDAInt(1,self->getNumberOfCompo());
}
+
+ PyObject *___iadd___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->buildDAInt(1,self->getNumberOfCompo());
+ ParaMEDMEM_DataArrayInt____iadd___(ret,0,obj);
+ Py_XINCREF(trueSelf);
+ return trueSelf;
+ }
+
+ PyObject *___isub___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->buildDAInt(1,self->getNumberOfCompo());
+ ParaMEDMEM_DataArrayInt____isub___(ret,0,obj);
+ Py_XINCREF(trueSelf);
+ return trueSelf;
+ }
+
+ PyObject *___imul___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->buildDAInt(1,self->getNumberOfCompo());
+ ParaMEDMEM_DataArrayInt____imul___(ret,0,obj);
+ Py_XINCREF(trueSelf);
+ return trueSelf;
+ }
+
+ PyObject *___idiv___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->buildDAInt(1,self->getNumberOfCompo());
+ ParaMEDMEM_DataArrayInt____idiv___(ret,0,obj);
+ Py_XINCREF(trueSelf);
+ return trueSelf;
+ }
+
+ PyObject *___imod___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->buildDAInt(1,self->getNumberOfCompo());
+ ParaMEDMEM_DataArrayInt____imod___(ret,0,obj);
+ Py_XINCREF(trueSelf);
+ return trueSelf;
+ }
PyObject *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
{
MEDCouplingFieldDouble.__imul__=ParaMEDMEMMEDCouplingFieldDoubleImul
MEDCouplingFieldDouble.__idiv__=ParaMEDMEMMEDCouplingFieldDoubleIdiv
+DataArrayDoubleTuple.__iadd__=ParaMEDMEMDataArrayDoubleTupleIadd
+DataArrayDoubleTuple.__isub__=ParaMEDMEMDataArrayDoubleTupleIsub
+DataArrayDoubleTuple.__imul__=ParaMEDMEMDataArrayDoubleTupleImul
+DataArrayDoubleTuple.__idiv__=ParaMEDMEMDataArrayDoubleTupleIdiv
+
+DataArrayIntTuple.__iadd__=ParaMEDMEMDataArrayIntTupleIadd
+DataArrayIntTuple.__isub__=ParaMEDMEMDataArrayIntTupleIsub
+DataArrayIntTuple.__imul__=ParaMEDMEMDataArrayIntTupleImul
+DataArrayIntTuple.__idiv__=ParaMEDMEMDataArrayIntTupleIdiv
+DataArrayIntTuple.__imod__=ParaMEDMEMDataArrayIntTupleImod
+
del ParaMEDMEMDataArrayDoubleIadd
del ParaMEDMEMDataArrayDoubleIsub
del ParaMEDMEMDataArrayDoubleImul
del ParaMEDMEMDataArrayIntImul
del ParaMEDMEMDataArrayIntIdiv
del ParaMEDMEMDataArrayIntImod
+del ParaMEDMEMDataArrayDoubleTupleIadd
+del ParaMEDMEMDataArrayDoubleTupleIsub
+del ParaMEDMEMDataArrayDoubleTupleImul
+del ParaMEDMEMDataArrayDoubleTupleIdiv
+del ParaMEDMEMDataArrayIntTupleIadd
+del ParaMEDMEMDataArrayIntTupleIsub
+del ParaMEDMEMDataArrayIntTupleImul
+del ParaMEDMEMDataArrayIntTupleIdiv
+del ParaMEDMEMDataArrayIntTupleImod
%}
def ParaMEDMEMDataArrayIntImod(self,*args):
import _MEDCouplingRemapper
return _MEDCouplingRemapper.DataArrayInt____imod___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleTupleIadd(self,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.DataArrayDoubleTuple____iadd___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleTupleIsub(self,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.DataArrayDoubleTuple____isub___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleTupleImul(self,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.DataArrayDoubleTuple____imul___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleTupleIdiv(self,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.DataArrayDoubleTuple____idiv___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleIadd(self,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.DataArrayIntTuple____iadd___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleIsub(self,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.DataArrayIntTuple____isub___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleImul(self,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.DataArrayIntTuple____imul___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleIdiv(self,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.DataArrayIntTuple____idiv___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleImod(self,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.DataArrayIntTuple____imod___(self, self, *args)
%}
%include "MEDCouplingFinalize.i"
def ParaMEDMEMDataArrayIntImod(self,*args):
import _MEDLoader
return _MEDLoader.DataArrayInt____imod___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleTupleIadd(self,*args):
+ import _MEDLoader
+ return _MEDLoader.DataArrayDoubleTuple____iadd___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleTupleIsub(self,*args):
+ import _MEDLoader
+ return _MEDLoader.DataArrayDoubleTuple____isub___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleTupleImul(self,*args):
+ import _MEDLoader
+ return _MEDLoader.DataArrayDoubleTuple____imul___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleTupleIdiv(self,*args):
+ import _MEDLoader
+ return _MEDLoader.DataArrayDoubleTuple____idiv___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleIadd(self,*args):
+ import _MEDLoader
+ return _MEDLoader.DataArrayIntTuple____iadd___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleIsub(self,*args):
+ import _MEDLoader
+ return _MEDLoader.DataArrayIntTuple____isub___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleImul(self,*args):
+ import _MEDLoader
+ return _MEDLoader.DataArrayIntTuple____imul___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleIdiv(self,*args):
+ import _MEDLoader
+ return _MEDLoader.DataArrayIntTuple____idiv___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleImod(self,*args):
+ import _MEDLoader
+ return _MEDLoader.DataArrayIntTuple____imod___(self, self, *args)
%}
%include "MEDCouplingFinalize.i"