From: ageay Date: Fri, 20 Apr 2012 15:20:33 +0000 (+0000) Subject: Some new functionnalities with arrays in python. X-Git-Tag: TRIPOLI_323~41 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d4cd58782fc1c0552a4f858f88673df6ed89c9ac;p=tools%2Fmedcoupling.git Some new functionnalities with arrays in python. --- diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 69367db4b..f40d2d4ef 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -2324,10 +2324,36 @@ DataArrayDouble *DataArrayDouble::Add(const DataArrayDouble *a1, const DataArray void DataArrayDouble::addEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception) { - int nbOfTuple=other->getNumberOfTuples(); - int nbOfComp=other->getNumberOfComponents(); - checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array add equal !"); - std::transform(begin(),end(),other->begin(),getPointer(),std::plus()); + const char *msg="Nb of tuples mismatch for DataArrayDouble::addEqual !"; + int nbOfTuple=getNumberOfTuples(); + int nbOfTuple2=other->getNumberOfTuples(); + int nbOfComp=getNumberOfComponents(); + int nbOfComp2=other->getNumberOfComponents(); + if(nbOfTuple==nbOfTuple2) + { + if(nbOfComp==nbOfComp2) + { + std::transform(begin(),end(),other->begin(),getPointer(),std::plus()); + } + else if(nbOfComp2==1) + { + double *ptr=getPointer(); + const double *ptrc=other->getConstPointer(); + for(int i=0;i(),*ptrc++)); + } + else + throw INTERP_KERNEL::Exception(msg); + } + else if(nbOfTuple2==1) + { + double *ptr=getPointer(); + const double *ptrc=other->getConstPointer(); + for(int i=0;i()); + } + else + throw INTERP_KERNEL::Exception(msg); declareAsNew(); } @@ -2345,10 +2371,36 @@ DataArrayDouble *DataArrayDouble::Substract(const DataArrayDouble *a1, const Dat void DataArrayDouble::substractEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception) { - int nbOfTuple=other->getNumberOfTuples(); - int nbOfComp=other->getNumberOfComponents(); - checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array substract equal !"); - std::transform(begin(),end(),other->begin(),getPointer(),std::minus()); + const char *msg="Nb of tuples mismatch for DataArrayDouble::substractEqual !"; + int nbOfTuple=getNumberOfTuples(); + int nbOfTuple2=other->getNumberOfTuples(); + int nbOfComp=getNumberOfComponents(); + int nbOfComp2=other->getNumberOfComponents(); + if(nbOfTuple==nbOfTuple2) + { + if(nbOfComp==nbOfComp2) + { + std::transform(begin(),end(),other->begin(),getPointer(),std::minus()); + } + else if(nbOfComp2==1) + { + double *ptr=getPointer(); + const double *ptrc=other->getConstPointer(); + for(int i=0;i(),*ptrc++)); + } + else + throw INTERP_KERNEL::Exception(msg); + } + else if(nbOfTuple2==1) + { + double *ptr=getPointer(); + const double *ptrc=other->getConstPointer(); + for(int i=0;i()); + } + else + throw INTERP_KERNEL::Exception(msg); declareAsNew(); } @@ -2401,28 +2453,36 @@ DataArrayDouble *DataArrayDouble::Multiply(const DataArrayDouble *a1, const Data void DataArrayDouble::multiplyEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception) { + const char *msg="Nb of tuples mismatch for DataArrayDouble::multiplyEqual !"; int nbOfTuple=getNumberOfTuples(); int nbOfTuple2=other->getNumberOfTuples(); int nbOfComp=getNumberOfComponents(); int nbOfComp2=other->getNumberOfComponents(); - if(nbOfTuple!=nbOfTuple2) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array multiplyEqual !"); - if(nbOfComp==nbOfComp2) - { - std::transform(begin(),end(),other->begin(),getPointer(),std::multiplies()); - } - else + if(nbOfTuple==nbOfTuple2) { - if(nbOfComp2==1) + if(nbOfComp==nbOfComp2) + { + std::transform(begin(),end(),other->begin(),getPointer(),std::multiplies()); + } + else if(nbOfComp2==1) { - const double *ptr=other->getConstPointer(); - double *myPtr=getPointer(); + double *ptr=getPointer(); + const double *ptrc=other->getConstPointer(); for(int i=0;i(),ptr[i])); + std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptr+i*nbOfComp,std::bind2nd(std::multiplies(),*ptrc++)); } else - throw INTERP_KERNEL::Exception("Nb of components mismatch for array multiplyEqual !"); + throw INTERP_KERNEL::Exception(msg); } + else if(nbOfTuple2==1) + { + double *ptr=getPointer(); + const double *ptrc=other->getConstPointer(); + for(int i=0;i()); + } + else + throw INTERP_KERNEL::Exception(msg); declareAsNew(); } @@ -2463,28 +2523,36 @@ DataArrayDouble *DataArrayDouble::Divide(const DataArrayDouble *a1, const DataAr void DataArrayDouble::divideEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception) { + const char *msg="Nb of tuples mismatch for DataArrayDouble::divideEqual !"; int nbOfTuple=getNumberOfTuples(); int nbOfTuple2=other->getNumberOfTuples(); int nbOfComp=getNumberOfComponents(); int nbOfComp2=other->getNumberOfComponents(); - if(nbOfTuple!=nbOfTuple2) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array divideEqual !"); - if(nbOfComp==nbOfComp2) - { - std::transform(begin(),end(),other->begin(),getPointer(),std::divides()); - } - else + if(nbOfTuple==nbOfTuple2) { - if(nbOfComp2==1) + if(nbOfComp==nbOfComp2) + { + std::transform(begin(),end(),other->begin(),getPointer(),std::divides()); + } + else if(nbOfComp2==1) { - const double *ptr=other->getConstPointer(); - double *myPtr=getPointer(); + double *ptr=getPointer(); + const double *ptrc=other->getConstPointer(); for(int i=0;i(),ptr[i])); + std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptr+i*nbOfComp,std::bind2nd(std::divides(),*ptrc++)); } else - throw INTERP_KERNEL::Exception("Nb of components mismatch for array divideEqual !"); + throw INTERP_KERNEL::Exception(msg); } + else if(nbOfTuple2==1) + { + double *ptr=getPointer(); + const double *ptrc=other->getConstPointer(); + for(int i=0;i()); + } + else + throw INTERP_KERNEL::Exception(msg); declareAsNew(); } @@ -4661,10 +4729,36 @@ DataArrayInt *DataArrayInt::Add(const DataArrayInt *a1, const DataArrayInt *a2) void DataArrayInt::addEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception) { - int nbOfTuple=other->getNumberOfTuples(); - int nbOfComp=other->getNumberOfComponents(); - checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array add equal !"); - std::transform(begin(),end(),other->begin(),getPointer(),std::plus()); + const char *msg="Nb of tuples mismatch for DataArrayInt::addEqual !"; + int nbOfTuple=getNumberOfTuples(); + int nbOfTuple2=other->getNumberOfTuples(); + int nbOfComp=getNumberOfComponents(); + int nbOfComp2=other->getNumberOfComponents(); + if(nbOfTuple==nbOfTuple2) + { + if(nbOfComp==nbOfComp2) + { + std::transform(begin(),end(),other->begin(),getPointer(),std::plus()); + } + else if(nbOfComp2==1) + { + int *ptr=getPointer(); + const int *ptrc=other->getConstPointer(); + for(int i=0;i(),*ptrc++)); + } + else + throw INTERP_KERNEL::Exception(msg); + } + else if(nbOfTuple2==1) + { + int *ptr=getPointer(); + const int *ptrc=other->getConstPointer(); + for(int i=0;i()); + } + else + throw INTERP_KERNEL::Exception(msg); declareAsNew(); } @@ -4682,10 +4776,36 @@ DataArrayInt *DataArrayInt::Substract(const DataArrayInt *a1, const DataArrayInt void DataArrayInt::substractEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception) { - int nbOfTuple=other->getNumberOfTuples(); - int nbOfComp=other->getNumberOfComponents(); - checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array substract equal !"); - std::transform(begin(),end(),other->begin(),getPointer(),std::minus()); + const char *msg="Nb of tuples mismatch for DataArrayInt::substractEqual !"; + int nbOfTuple=getNumberOfTuples(); + int nbOfTuple2=other->getNumberOfTuples(); + int nbOfComp=getNumberOfComponents(); + int nbOfComp2=other->getNumberOfComponents(); + if(nbOfTuple==nbOfTuple2) + { + if(nbOfComp==nbOfComp2) + { + std::transform(begin(),end(),other->begin(),getPointer(),std::minus()); + } + else if(nbOfComp2==1) + { + int *ptr=getPointer(); + const int *ptrc=other->getConstPointer(); + for(int i=0;i(),*ptrc++)); + } + else + throw INTERP_KERNEL::Exception(msg); + } + else if(nbOfTuple2==1) + { + int *ptr=getPointer(); + const int *ptrc=other->getConstPointer(); + for(int i=0;i()); + } + else + throw INTERP_KERNEL::Exception(msg); declareAsNew(); } @@ -4738,28 +4858,36 @@ DataArrayInt *DataArrayInt::Multiply(const DataArrayInt *a1, const DataArrayInt void DataArrayInt::multiplyEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception) { + const char *msg="Nb of tuples mismatch for DataArrayInt::multiplyEqual !"; int nbOfTuple=getNumberOfTuples(); int nbOfTuple2=other->getNumberOfTuples(); int nbOfComp=getNumberOfComponents(); int nbOfComp2=other->getNumberOfComponents(); - if(nbOfTuple!=nbOfTuple2) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array multiplyEqual !"); - if(nbOfComp==nbOfComp2) - { - std::transform(begin(),end(),other->begin(),getPointer(),std::multiplies()); - } - else + if(nbOfTuple==nbOfTuple2) { - if(nbOfComp2==1) + if(nbOfComp==nbOfComp2) + { + std::transform(begin(),end(),other->begin(),getPointer(),std::multiplies()); + } + else if(nbOfComp2==1) { - const int *ptr=other->getConstPointer(); - int *myPtr=getPointer(); + int *ptr=getPointer(); + const int *ptrc=other->getConstPointer(); for(int i=0;i(),ptr[i])); + std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptr+i*nbOfComp,std::bind2nd(std::multiplies(),*ptrc++)); } else - throw INTERP_KERNEL::Exception("Nb of components mismatch for array multiplyEqual !"); + throw INTERP_KERNEL::Exception(msg); } + else if(nbOfTuple2==1) + { + int *ptr=getPointer(); + const int *ptrc=other->getConstPointer(); + for(int i=0;i()); + } + else + throw INTERP_KERNEL::Exception(msg); declareAsNew(); } @@ -4800,28 +4928,36 @@ DataArrayInt *DataArrayInt::Divide(const DataArrayInt *a1, const DataArrayInt *a void DataArrayInt::divideEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception) { + const char *msg="Nb of tuples mismatch for DataArrayInt::divideEqual !"; int nbOfTuple=getNumberOfTuples(); int nbOfTuple2=other->getNumberOfTuples(); int nbOfComp=getNumberOfComponents(); int nbOfComp2=other->getNumberOfComponents(); - if(nbOfTuple!=nbOfTuple2) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array divideEqual !"); - if(nbOfComp==nbOfComp2) - { - std::transform(begin(),end(),other->begin(),getPointer(),std::divides()); - } - else + if(nbOfTuple==nbOfTuple2) { - if(nbOfComp2==1) + if(nbOfComp==nbOfComp2) + { + std::transform(begin(),end(),other->begin(),getPointer(),std::divides()); + } + else if(nbOfComp2==1) { - const int *ptr=other->getConstPointer(); - int *myPtr=getPointer(); + int *ptr=getPointer(); + const int *ptrc=other->getConstPointer(); for(int i=0;i(),ptr[i])); + std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptr+i*nbOfComp,std::bind2nd(std::divides(),*ptrc++)); } else - throw INTERP_KERNEL::Exception("Nb of components mismatch for array divideEqual !"); + throw INTERP_KERNEL::Exception(msg); } + else if(nbOfTuple2==1) + { + int *ptr=getPointer(); + const int *ptrc=other->getConstPointer(); + for(int i=0;i()); + } + else + throw INTERP_KERNEL::Exception(msg); declareAsNew(); } @@ -4839,10 +4975,36 @@ DataArrayInt *DataArrayInt::Modulus(const DataArrayInt *a1, const DataArrayInt * void DataArrayInt::modulusEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception) { - int nbOfTuple=other->getNumberOfTuples(); - int nbOfComp=other->getNumberOfComponents(); - checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array modulus equal"); - std::transform(begin(),end(),other->begin(),getPointer(),std::modulus()); + const char *msg="Nb of tuples mismatch for DataArrayInt::modulusEqual !"; + int nbOfTuple=getNumberOfTuples(); + int nbOfTuple2=other->getNumberOfTuples(); + int nbOfComp=getNumberOfComponents(); + int nbOfComp2=other->getNumberOfComponents(); + if(nbOfTuple==nbOfTuple2) + { + if(nbOfComp==nbOfComp2) + { + std::transform(begin(),end(),other->begin(),getPointer(),std::modulus()); + } + else if(nbOfComp2==1) + { + int *ptr=getPointer(); + const int *ptrc=other->getConstPointer(); + for(int i=0;i(),*ptrc++)); + } + else + throw INTERP_KERNEL::Exception(msg); + } + else if(nbOfTuple2==1) + { + int *ptr=getPointer(); + const int *ptrc=other->getConstPointer(); + for(int i=0;i()); + } + else + throw INTERP_KERNEL::Exception(msg); declareAsNew(); } diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index 20a3ab3a3..f5db9b5d7 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -2715,8 +2715,9 @@ namespace ParaMEDMEM double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; + std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa); + convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -2746,8 +2747,9 @@ namespace ParaMEDMEM double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; + std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa); + convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -2773,8 +2775,9 @@ namespace ParaMEDMEM double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; + std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa); + convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -2793,6 +2796,12 @@ namespace ParaMEDMEM self->addEqual(aaa); return self; } + case 4: + { + MEDCouplingAutoRefCountObjectPtr aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + self->addEqual(aaa); + return self; + } default: throw INTERP_KERNEL::Exception(msg); } @@ -2804,8 +2813,9 @@ namespace ParaMEDMEM double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; + std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa); + convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -2824,6 +2834,11 @@ namespace ParaMEDMEM MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents()); return DataArrayDouble::Substract(self,aaa); } + case 4: + { + MEDCouplingAutoRefCountObjectPtr aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + return DataArrayDouble::Substract(self,aaa); + } default: throw INTERP_KERNEL::Exception(msg); } @@ -2835,8 +2850,9 @@ namespace ParaMEDMEM double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; + std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa); + convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -2851,6 +2867,11 @@ namespace ParaMEDMEM MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents()); return DataArrayDouble::Substract(aaa,self); } + case 4: + { + MEDCouplingAutoRefCountObjectPtr aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + return DataArrayDouble::Substract(aaa,self); + } default: throw INTERP_KERNEL::Exception(msg); } @@ -2862,8 +2883,9 @@ namespace ParaMEDMEM double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; + std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa); + convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -2882,6 +2904,12 @@ namespace ParaMEDMEM self->substractEqual(aaa); return self; } + case 4: + { + MEDCouplingAutoRefCountObjectPtr aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + self->substractEqual(aaa); + return self; + } default: throw INTERP_KERNEL::Exception(msg); } @@ -2893,8 +2921,9 @@ namespace ParaMEDMEM double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; + std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa); + convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -2913,6 +2942,11 @@ namespace ParaMEDMEM MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents()); return DataArrayDouble::Multiply(self,aaa); } + case 4: + { + MEDCouplingAutoRefCountObjectPtr aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + return DataArrayDouble::Multiply(self,aaa); + } default: throw INTERP_KERNEL::Exception(msg); } @@ -2924,8 +2958,9 @@ namespace ParaMEDMEM double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; + std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa); + convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -2940,6 +2975,11 @@ namespace ParaMEDMEM MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents()); return DataArrayDouble::Multiply(self,aaa); } + case 4: + { + MEDCouplingAutoRefCountObjectPtr aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + return DataArrayDouble::Multiply(self,aaa); + } default: throw INTERP_KERNEL::Exception(msg); } @@ -2951,8 +2991,9 @@ namespace ParaMEDMEM double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; + std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa); + convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -2971,6 +3012,12 @@ namespace ParaMEDMEM self->multiplyEqual(aaa); return self; } + case 4: + { + MEDCouplingAutoRefCountObjectPtr aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + self->multiplyEqual(aaa); + return self; + } default: throw INTERP_KERNEL::Exception(msg); } @@ -2982,8 +3029,9 @@ namespace ParaMEDMEM double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; + std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa); + convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -3004,6 +3052,11 @@ namespace ParaMEDMEM MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents()); return DataArrayDouble::Divide(self,aaa); } + case 4: + { + MEDCouplingAutoRefCountObjectPtr aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + return DataArrayDouble::Divide(self,aaa); + } default: throw INTERP_KERNEL::Exception(msg); } @@ -3015,8 +3068,9 @@ namespace ParaMEDMEM double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; + std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa); + convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -3031,6 +3085,11 @@ namespace ParaMEDMEM MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents()); return DataArrayDouble::Divide(aaa,self); } + case 4: + { + MEDCouplingAutoRefCountObjectPtr aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + return DataArrayDouble::Divide(aaa,self); + } default: throw INTERP_KERNEL::Exception(msg); } @@ -3042,8 +3101,9 @@ namespace ParaMEDMEM double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; + std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa); + convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -3064,6 +3124,12 @@ namespace ParaMEDMEM self->divideEqual(aaa); return self; } + case 4: + { + MEDCouplingAutoRefCountObjectPtr aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + self->divideEqual(aaa); + return self; + } default: throw INTERP_KERNEL::Exception(msg); } diff --git a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i index c9a7eb975..607eded72 100644 --- a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i +++ b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i @@ -1056,8 +1056,10 @@ static void convertObjToPossibleCpp3(PyObject *value, int nbTuple, int nbCompo, * if value double -> cpp val sw=1 * if value DataArrayDouble -> cpp DataArrayDouble sw=2 * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3 + * if value list[int,double] -> cpp std::vector sw=4 + * if value tuple[int,double] -> cpp std::vector sw=4 */ -static void convertObjToPossibleCpp5(PyObject *value, int& sw, double& val, ParaMEDMEM::DataArrayDouble *&d, ParaMEDMEM::DataArrayDoubleTuple *&e) +static void convertObjToPossibleCpp5(PyObject *value, int& sw, double& val, ParaMEDMEM::DataArrayDouble *&d, ParaMEDMEM::DataArrayDoubleTuple *&e, std::vector& f) { sw=-1; if(PyFloat_Check(value)) @@ -1072,6 +1074,46 @@ static void convertObjToPossibleCpp5(PyObject *value, int& sw, double& val, Para sw=1; return; } + if(PyTuple_Check(value)) + { + int size=PyTuple_Size(value); + f.resize(size); + for(int i=0;i