]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
pow on DataArrayInt and reverse with multi component
authorageay <ageay>
Mon, 25 Mar 2013 16:33:45 +0000 (16:33 +0000)
committerageay <ageay>
Mon, 25 Mar 2013 16:33:45 +0000 (16:33 +0000)
src/MEDCoupling_Swig/MEDCoupling.i
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py
src/MEDCoupling_Swig/MEDCouplingCommon.i
src/MEDCoupling_Swig/MEDCouplingFinalize.i

index 04d497020f95629c6af7c83f978e0d5248e738e2..de843c7b65fc1ee9a9b1bee1e20d7850fc1db865 100644 (file)
@@ -59,6 +59,9 @@ def ParaMEDMEMDataArrayIntIdiv(self,*args):
 def ParaMEDMEMDataArrayIntImod(self,*args):
     import _MEDCoupling
     return _MEDCoupling.DataArrayInt____imod___(self, self, *args)
+def ParaMEDMEMDataArrayIntIpow(self,*args):
+    import _MEDCoupling
+    return _MEDCoupling.DataArrayInt____ipow___(self, self, *args)
 def ParaMEDMEMDataArrayDoubleTupleIadd(self,*args):
     import _MEDCoupling
     return _MEDCoupling.DataArrayDoubleTuple____iadd___(self, self, *args)
index 5929a4daef119dd09f01a15a458b6bfab9205cb1..82d5e46a9f6654ccd71443e9c21f87cdfecbffd8 100644 (file)
@@ -4570,7 +4570,6 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         dbl2.alloc(7,2);
         self.assertRaises(InterpKernelException, dbl2.isUniform, 10., 1e-15);
         self.assertRaises(InterpKernelException, dbl2.sort);
-        self.assertRaises(InterpKernelException, dbl2.reverse);
         self.assertRaises(InterpKernelException, dbl2.iota, 10.);
         
         dbl=DataArrayDouble.New();
@@ -4578,7 +4577,6 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertRaises(InterpKernelException, dbl.iota, 10.);
         self.assertRaises(InterpKernelException, dbl.isUniform, 10., 1e-15);
         self.assertRaises(InterpKernelException, dbl.sort);
-        self.assertRaises(InterpKernelException, dbl.reverse);
         self.assertRaises(InterpKernelException, dbl.fromNoInterlace);
         self.assertRaises(InterpKernelException, dbl.toNoInterlace);
         
@@ -11692,6 +11690,30 @@ class MEDCouplingBasicsTest(unittest.TestCase):
             pass
         pass
 
+    def testSwig2DAReverseMultiCompo1(self):
+        d=DataArrayDouble(6,2)
+        d[:,0]=range(6)
+        d[:,1]=range(10,16)
+        d.reverse()
+        self.assertTrue(d.isEqual(DataArrayDouble([5.,15.,4.,14.,3.,13.,2.,12.,1.,11.,0.,10.],6,2),1e-14))
+        d=DataArrayDouble(7,2)
+        d[:,0]=range(7)
+        d[:,1]=range(10,17)
+        d.reverse()
+        self.assertTrue(d.isEqual(DataArrayDouble([6.,16.,5.,15.,4.,14.,3.,13.,2.,12.,1.,11.,0.,10.],7,2),1e-14))
+        #
+        d=DataArrayInt(6,2)
+        d[:,0]=range(6)
+        d[:,1]=range(10,16)
+        d.reverse()
+        self.assertTrue(d.isEqual(DataArrayInt([5,15,4,14,3,13,2,12,1,11,0,10],6,2)))
+        d=DataArrayInt(7,2)
+        d[:,0]=range(7)
+        d[:,1]=range(10,17)
+        d.reverse()
+        self.assertTrue(d.isEqual(DataArrayInt([6,16,5,15,4,14,3,13,2,12,1,11,0,10],7,2)))
+        pass
+
     def setUp(self):
         pass
     pass
index 1de0e431be21a7ab22d77d16b2fe0dc433fea71a..b60d7000e5bd37786bdcbff73108ebe0eba7e75a 100644 (file)
@@ -174,6 +174,7 @@ using namespace INTERP_KERNEL;
 %newobject ParaMEDMEM::DataArrayInt::Substract;
 %newobject ParaMEDMEM::DataArrayInt::Multiply;
 %newobject ParaMEDMEM::DataArrayInt::Divide;
+%newobject ParaMEDMEM::DataArrayInt::Pow;
 %newobject ParaMEDMEM::DataArrayInt::BuildUnion;
 %newobject ParaMEDMEM::DataArrayInt::BuildIntersection;
 %newobject ParaMEDMEM::DataArrayInt::Range;
@@ -204,6 +205,8 @@ using namespace INTERP_KERNEL;
 %newobject ParaMEDMEM::DataArrayInt::__rdiv__;
 %newobject ParaMEDMEM::DataArrayInt::__mod__;
 %newobject ParaMEDMEM::DataArrayInt::__rmod__;
+%newobject ParaMEDMEM::DataArrayInt::__pow__;
+%newobject ParaMEDMEM::DataArrayInt::__rpow__;
 %newobject ParaMEDMEM::DataArrayIntTuple::buildDAInt;
 %newobject ParaMEDMEM::DataArrayChar::convertToIntArr;
 %newobject ParaMEDMEM::DataArrayChar::renumber;
@@ -7462,6 +7465,113 @@ namespace ParaMEDMEM
          throw INTERP_KERNEL::Exception(msg);
        }
    }
+
+   DataArrayInt *__pow__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+   {
+     const char msg[]="Unexpected situation in __pow__ !";
+     int val;
+     DataArrayInt *a;
+     std::vector<int> aa;
+     DataArrayIntTuple *aaa;
+     int sw;
+     convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa);
+     switch(sw)
+       {
+       case 1:
+         {
+           MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+           ret->applyPow(val);
+           return ret.retn();
+         }
+       case 2:
+         {
+           MEDCouplingAutoRefCountObjectPtr<DataArrayInt> aaa=DataArrayInt::New(); aaa->useArray(&aa[0],false,CPP_DEALLOC,1,(int)aa.size());
+           return DataArrayInt::Pow(self,aaa);
+         }
+       case 3:
+         {
+           return DataArrayInt::Pow(self,a);
+         }
+       case 4:
+         {
+           MEDCouplingAutoRefCountObjectPtr<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+           return DataArrayInt::Pow(self,aaaa);
+         }
+       default:
+         throw INTERP_KERNEL::Exception(msg);
+       }
+   }
+
+   DataArrayInt *__rpow__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+   {
+     const char msg[]="Unexpected situation in __rpow__ !";
+     int val;
+     DataArrayInt *a;
+     std::vector<int> aa;
+     DataArrayIntTuple *aaa;
+     int sw;
+     convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa);
+     switch(sw)
+       {
+       case 1:
+         {
+           MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+           ret->applyRPow(val);
+           return ret.retn();
+         }
+       case 2:
+         {
+           MEDCouplingAutoRefCountObjectPtr<DataArrayInt> aaa=DataArrayInt::New(); aaa->useArray(&aa[0],false,CPP_DEALLOC,1,(int)aa.size());
+           return DataArrayInt::Pow(aaa,self);
+         }
+       case 3:
+         {
+           return DataArrayInt::Pow(a,self);
+         }
+       case 4:
+         {
+           MEDCouplingAutoRefCountObjectPtr<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+           return DataArrayInt::Pow(aaaa,self);
+         }
+       default:
+         throw INTERP_KERNEL::Exception(msg);
+       }
+   }
+   
+   PyObject *___ipow___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception)
+   {
+     const char msg[]="Unexpected situation in __ipow__ !";
+     int val;
+     DataArrayInt *a;
+     std::vector<int> aa;
+     DataArrayIntTuple *aaa;
+     int sw;
+     convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa);
+     switch(sw)
+       {
+       case 1:
+         {
+           self->applyPow(val);
+           Py_XINCREF(trueSelf);
+           return trueSelf;
+         }
+       case 3:
+         {
+           self->powEqual(a);
+           Py_XINCREF(trueSelf);
+           return trueSelf;
+         }
+       case 4:
+         {
+           MEDCouplingAutoRefCountObjectPtr<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+           self->powEqual(aaaa);
+           Py_XINCREF(trueSelf);
+           return trueSelf;
+         }
+       default:
+         throw INTERP_KERNEL::Exception(msg);
+       }
+   }
  };
 
 namespace ParaMEDMEM
index 909b4cf959caf78155fd680a6ea4ffb5f50d1c6b..d686aa607e9b8eebbfcf48d7b59ca69bbbb8efd7 100644 (file)
@@ -28,6 +28,7 @@ DataArrayInt.__isub__=ParaMEDMEMDataArrayIntIsub
 DataArrayInt.__imul__=ParaMEDMEMDataArrayIntImul
 DataArrayInt.__idiv__=ParaMEDMEMDataArrayIntIdiv
 DataArrayInt.__imod__=ParaMEDMEMDataArrayIntImod
+DataArrayInt.__ipow__=ParaMEDMEMDataArrayIntIpow
 
 MEDCouplingFieldDouble.__iadd__=ParaMEDMEMMEDCouplingFieldDoubleIadd
 MEDCouplingFieldDouble.__isub__=ParaMEDMEMMEDCouplingFieldDoubleIsub