]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Some new functionnalities with arrays in python.
authorageay <ageay>
Fri, 20 Apr 2012 15:20:33 +0000 (15:20 +0000)
committerageay <ageay>
Fri, 20 Apr 2012 15:20:33 +0000 (15:20 +0000)
src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling_Swig/MEDCoupling.i
src/MEDCoupling_Swig/MEDCouplingTypemaps.i

index 69367db4b9c1093b10d70569aca623735c802320..f40d2d4efb14cacacf8b9ea9b7daff4820609f36 100644 (file)
@@ -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<double>());
+  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<double>());
+        }
+      else if(nbOfComp2==1)
+        {
+          double *ptr=getPointer();
+          const double *ptrc=other->getConstPointer();
+          for(int i=0;i<nbOfTuple;i++)
+            std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptr+i*nbOfComp,std::bind2nd(std::plus<double>(),*ptrc++));
+        }
+      else
+        throw INTERP_KERNEL::Exception(msg);
+    }
+  else if(nbOfTuple2==1)
+    {
+      double *ptr=getPointer();
+      const double *ptrc=other->getConstPointer();
+      for(int i=0;i<nbOfTuple;i++)
+        std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptrc,ptr+i*nbOfComp,std::plus<double>());
+    }
+  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<double>());
+  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<double>());
+        }
+      else if(nbOfComp2==1)
+        {
+          double *ptr=getPointer();
+          const double *ptrc=other->getConstPointer();
+          for(int i=0;i<nbOfTuple;i++)
+            std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptr+i*nbOfComp,std::bind2nd(std::minus<double>(),*ptrc++));
+        }
+      else
+        throw INTERP_KERNEL::Exception(msg);
+    }
+  else if(nbOfTuple2==1)
+    {
+      double *ptr=getPointer();
+      const double *ptrc=other->getConstPointer();
+      for(int i=0;i<nbOfTuple;i++)
+        std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptrc,ptr+i*nbOfComp,std::minus<double>());
+    }
+  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<double>());
-    }
-  else
+  if(nbOfTuple==nbOfTuple2)
     {
-      if(nbOfComp2==1)
+      if(nbOfComp==nbOfComp2)
+        {
+          std::transform(begin(),end(),other->begin(),getPointer(),std::multiplies<double>());
+        }
+      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<nbOfTuple;i++)
-            myPtr=std::transform(myPtr,myPtr+nbOfComp,myPtr,std::bind2nd(std::multiplies<double>(),ptr[i]));
+            std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptr+i*nbOfComp,std::bind2nd(std::multiplies<double>(),*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<nbOfTuple;i++)
+        std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptrc,ptr+i*nbOfComp,std::multiplies<double>());
+    }
+  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<double>());
-    }
-  else
+  if(nbOfTuple==nbOfTuple2)
     {
-      if(nbOfComp2==1)
+      if(nbOfComp==nbOfComp2)
+        {
+          std::transform(begin(),end(),other->begin(),getPointer(),std::divides<double>());
+        }
+      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<nbOfTuple;i++)
-            myPtr=std::transform(myPtr,myPtr+nbOfComp,myPtr,std::bind2nd(std::divides<double>(),ptr[i]));
+            std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptr+i*nbOfComp,std::bind2nd(std::divides<double>(),*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<nbOfTuple;i++)
+        std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptrc,ptr+i*nbOfComp,std::divides<double>());
+    }
+  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<int>());
+  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<int>());
+        }
+      else if(nbOfComp2==1)
+        {
+          int *ptr=getPointer();
+          const int *ptrc=other->getConstPointer();
+          for(int i=0;i<nbOfTuple;i++)
+            std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptr+i*nbOfComp,std::bind2nd(std::plus<int>(),*ptrc++));
+        }
+      else
+        throw INTERP_KERNEL::Exception(msg);
+    }
+  else if(nbOfTuple2==1)
+    {
+      int *ptr=getPointer();
+      const int *ptrc=other->getConstPointer();
+      for(int i=0;i<nbOfTuple;i++)
+        std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptrc,ptr+i*nbOfComp,std::plus<int>());
+    }
+  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<int>());
+  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<int>());
+        }
+      else if(nbOfComp2==1)
+        {
+          int *ptr=getPointer();
+          const int *ptrc=other->getConstPointer();
+          for(int i=0;i<nbOfTuple;i++)
+            std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptr+i*nbOfComp,std::bind2nd(std::minus<int>(),*ptrc++));
+        }
+      else
+        throw INTERP_KERNEL::Exception(msg);
+    }
+  else if(nbOfTuple2==1)
+    {
+      int *ptr=getPointer();
+      const int *ptrc=other->getConstPointer();
+      for(int i=0;i<nbOfTuple;i++)
+        std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptrc,ptr+i*nbOfComp,std::minus<int>());
+    }
+  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<int>());
-    }
-  else
+  if(nbOfTuple==nbOfTuple2)
     {
-      if(nbOfComp2==1)
+      if(nbOfComp==nbOfComp2)
+        {
+          std::transform(begin(),end(),other->begin(),getPointer(),std::multiplies<int>());
+        }
+      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<nbOfTuple;i++)
-            myPtr=std::transform(myPtr,myPtr+nbOfComp,myPtr,std::bind2nd(std::multiplies<int>(),ptr[i]));
+            std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptr+i*nbOfComp,std::bind2nd(std::multiplies<int>(),*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<nbOfTuple;i++)
+        std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptrc,ptr+i*nbOfComp,std::multiplies<int>());
+    }
+  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<int>());
-    }
-  else
+  if(nbOfTuple==nbOfTuple2)
     {
-      if(nbOfComp2==1)
+      if(nbOfComp==nbOfComp2)
+        {
+          std::transform(begin(),end(),other->begin(),getPointer(),std::divides<int>());
+        }
+      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<nbOfTuple;i++)
-            myPtr=std::transform(myPtr,myPtr+nbOfComp,myPtr,std::bind2nd(std::divides<int>(),ptr[i]));
+            std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptr+i*nbOfComp,std::bind2nd(std::divides<int>(),*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<nbOfTuple;i++)
+        std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptrc,ptr+i*nbOfComp,std::divides<int>());
+    }
+  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<int>());
+  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<int>());
+        }
+      else if(nbOfComp2==1)
+        {
+          int *ptr=getPointer();
+          const int *ptrc=other->getConstPointer();
+          for(int i=0;i<nbOfTuple;i++)
+            std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptr+i*nbOfComp,std::bind2nd(std::modulus<int>(),*ptrc++));
+        }
+      else
+        throw INTERP_KERNEL::Exception(msg);
+    }
+  else if(nbOfTuple2==1)
+    {
+      int *ptr=getPointer();
+      const int *ptrc=other->getConstPointer();
+      for(int i=0;i<nbOfTuple;i++)
+        std::transform(ptr+i*nbOfComp,ptr+(i+1)*nbOfComp,ptrc,ptr+i*nbOfComp,std::modulus<int>());
+    }
+  else
+    throw INTERP_KERNEL::Exception(msg);
   declareAsNew();
 }
 
index 20a3ab3a3368f2e6e7a6a4045736778d3a72b294..f5db9b5d7c5d782e6babba171f11b80a8b70a976 100644 (file)
@@ -2715,8 +2715,9 @@ namespace ParaMEDMEM
      double val;
      DataArrayDouble *a;
      DataArrayDoubleTuple *aa;
+     std::vector<double> 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<double> 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<double> 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<DataArrayDouble> 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<double> 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<DataArrayDouble> aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents());
            return DataArrayDouble::Substract(self,aaa);
          }
+       case 4:
+         {
+           MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> 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<double> 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<DataArrayDouble> aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents());
            return DataArrayDouble::Substract(aaa,self);
          }
+       case 4:
+         {
+           MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> 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<double> 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<DataArrayDouble> 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<double> 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<DataArrayDouble> aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents());
            return DataArrayDouble::Multiply(self,aaa);
          }
+       case 4:
+         {
+           MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> 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<double> 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<DataArrayDouble> aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents());
            return DataArrayDouble::Multiply(self,aaa);
          }
+       case 4:
+         {
+           MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> 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<double> 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<DataArrayDouble> 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<double> 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<DataArrayDouble> aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents());
            return DataArrayDouble::Divide(self,aaa);
          }
+       case 4:
+         {
+           MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> 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<double> 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<DataArrayDouble> aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents());
            return DataArrayDouble::Divide(aaa,self);
          }
+       case 4:
+         {
+           MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> 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<double> 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<DataArrayDouble> 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);
        }
index c9a7eb975e2ccf24f73ffb23d5be7a58a0ca73ac..607eded72c1b042ea64fb626399f5b6fee190121 100644 (file)
@@ -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<double> sw=4
+ * if value tuple[int,double] -> cpp std::vector<double> 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<double>& 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<size;i++)
+        {
+          PyObject *o=PyTuple_GetItem(value,i);
+          if(PyFloat_Check(o))
+            f[i]=PyFloat_AS_DOUBLE(o);
+          else if(PyInt_Check(o))
+            f[i]=(double)PyInt_AS_LONG(o);
+          else
+            {
+              std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
+              throw INTERP_KERNEL::Exception(oss.str().c_str());
+            }
+        }
+      sw=4;
+      return;
+    }
+  if(PyList_Check(value))
+    {
+      int size=PyList_Size(value);
+      f.resize(size);
+      for(int i=0;i<size;i++)
+        {
+          PyObject *o=PyList_GetItem(value,i);
+          if(PyFloat_Check(o))
+            f[i]=PyFloat_AS_DOUBLE(o);
+          else if(PyInt_Check(o))
+            f[i]=(double)PyInt_AS_LONG(o);
+          else
+            {
+              std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
+              throw INTERP_KERNEL::Exception(oss.str().c_str());
+            }
+        }
+      sw=4;
+      return;
+    }
   void *argp;
   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
   if(SWIG_IsOK(status))