Salome HOME
activate paramedmem test with "salome test" mechanism
[tools/medcoupling.git] / src / MEDCoupling_Swig / DataArrayInt.i
1 // Copyright (C) 2007-2020  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (EDF R&D)
20
21 %include "MEDCouplingMemArray.i"
22
23 %define ARRAYDEF( ARRAY, INT )
24
25 // namespace MEDCoupling
26 // {
27 //   class ARRAY ## Iterator;
28
29 //   class ARRAY : public DataArray -- #ifdef doesn't work inside
30 //   {
31   public:
32     static ARRAY *New();
33     INT intValue() const;
34     INT getHashCode() const;
35     bool empty() const;
36     void aggregate(const ARRAY *other);
37     ARRAY *performCopyOrIncrRef(bool deepCopy) const;
38     void deepCopyFrom(const ARRAY& other);
39     void reserve(std::size_t nbOfElems);
40     void pushBackSilent(INT val);
41     INT popBackSilent();
42     void pack() const;
43     void allocIfNecessary(INT nbOfTuple, INT nbOfCompo);
44     bool isEqual(const ARRAY& other) const;
45     bool isEqualWithoutConsideringStr(const ARRAY& other) const;
46     bool isEqualWithoutConsideringStrAndOrder(const ARRAY& other) const;
47     DataArrayIdType *occurenceRankInThis() const;
48     DataArrayIdType *buildPermutationArr(const ARRAY& other) const;
49     ARRAY *sumPerTuple() const;
50     void sort(bool asc=true);
51     void reverse();
52     void checkMonotonic(bool increasing) const;
53     bool isMonotonic(bool increasing) const;
54     void checkStrictlyMonotonic(bool increasing) const;
55     bool isStrictlyMonotonic(bool increasing) const;
56     void fillWithZero();
57     void fillWithValue(INT val);
58     void iota(INT init=0);
59     std::string repr() const;
60     std::string reprZip() const;
61     std::string reprNotTooLong() const;
62     ARRAY *invertArrayO2N2N2O(mcIdType newNbOfElem) const;
63     ARRAY *invertArrayN2O2O2N(mcIdType oldNbOfElem) const;
64     ARRAY *invertArrayO2N2N2OBis(mcIdType newNbOfElem) const;
65     DataArrayIdType *indicesOfSubPart(const ARRAY& partOfThis) const;
66     ARRAY *fromNoInterlace() const;
67     ARRAY *toNoInterlace() const;
68     ARRAY *selectByTupleIdSafeSlice(mcIdType bg, mcIdType end, mcIdType step) const;
69     DataArrayIdType *checkAndPreparePermutation() const;
70     DataArrayIdType *buildPermArrPerLevel() const;
71     bool isIota(mcIdType sizeExpected) const;
72     bool isUniform(INT val) const;
73     INT checkUniformAndGuess() const;
74     bool hasUniqueValues() const;
75     ARRAY *subArray(mcIdType tupleIdBg, mcIdType tupleIdEnd=-1) const;
76     void transpose();
77     ARRAY *changeNbOfComponents(std::size_t newNbOfComp, INT dftValue) const;
78     void meldWith(const ARRAY *other);
79     void setPartOfValues1(const ARRAY *a, mcIdType bgTuples, mcIdType endTuples, mcIdType stepTuples, mcIdType bgComp, mcIdType endComp, mcIdType stepComp, bool strictCompoCompare=true);
80     void setPartOfValuesSimple1(INT a, mcIdType bgTuples, mcIdType endTuples, mcIdType stepTuples, mcIdType bgComp, mcIdType endComp, mcIdType stepComp);
81     void setPartOfValuesAdv(const ARRAY *a, const DataArrayIdType *tuplesSelec);
82     void getTuple(mcIdType tupleId, INT *res) const;
83     INT getIJ(std::size_t tupleId, std::size_t compoId) const;
84     INT getIJSafe(std::size_t tupleId, std::size_t compoId) const;
85     INT front() const;
86     INT back() const;
87     void setIJ(mcIdType tupleId, mcIdType compoId, INT newVal);
88     void setIJSilent(mcIdType tupleId, mcIdType compoId, INT newVal);
89     INT *getPointer();
90     const INT *getConstPointer() const;
91     ARRAY ## Iterator *iterator();
92     const INT *begin() const;
93     const INT *end() const;
94     DataArrayIdType *findIdsEqual(INT val) const;
95     DataArrayIdType *findIdsNotEqual(INT val) const;
96     mcIdType changeValue(INT oldValue, INT newValue);
97     mcIdType findIdFirstEqualTuple(const std::vector<INT>& tupl) const;
98     mcIdType findIdFirstEqual(INT value) const;
99     mcIdType findIdFirstEqual(const std::vector<INT>& vals) const;
100     mcIdType findIdSequence(const std::vector<INT>& vals) const;
101     bool presenceOfTuple(const std::vector<INT>& tupl) const;
102     bool presenceOfValue(INT value) const;
103     bool presenceOfValue(const std::vector<INT>& vals) const;
104     INT count(INT value) const;
105     INT accumulate(INT compId) const;
106     INT getMaxValueInArray() const;
107     INT getMaxAbsValueInArray() const;
108     INT getMinValueInArray() const;
109     void abs();
110     ARRAY *computeAbs() const;
111     void applyLin(INT a, INT b, INT compoId);
112     void applyLin(INT a, INT b);
113     void applyInv(INT numerator);
114     ARRAY *negate() const;
115     void applyDivideBy(INT val);
116     void applyModulus(INT val);
117     void applyRModulus(INT val);
118     void applyPow(INT val);
119     void applyRPow(INT val);
120     ARRAY *findIdsInRange(INT vmin, INT vmax) const;
121     ARRAY *findIdsNotInRange(INT vmin, INT vmax) const;
122     ARRAY *findIdsStrictlyNegative() const;
123     bool checkAllIdsInRange(INT vmin, INT vmax) const;
124     static ARRAY *Aggregate(const ARRAY *a1, const ARRAY *a2, INT offsetA2);
125     static ARRAY *Meld(const ARRAY *a1, const ARRAY *a2);
126     static DataArrayIdType *MakePartition(const std::vector<const ARRAY *>& groups, mcIdType newNb, std::vector< std::vector<mcIdType> >& fidsOfGroups);
127     static ARRAY *BuildUnion(const std::vector<const ARRAY *>& arr);
128     static ARRAY *BuildIntersection(const std::vector<const ARRAY *>& arr);
129     static DataArrayIdType *FindPermutationFromFirstToSecond(const ARRAY *ids1, const ARRAY *ids2);
130     static DataArrayIdType *FindPermutationFromFirstToSecondDuplicate(const ARRAY *ids1, const ARRAY *ids2);
131     DataArrayIdType *buildComplement(mcIdType nbOfElement) const;
132     ARRAY *buildSubstraction(const ARRAY *other) const;
133     ARRAY *buildSubstractionOptimized(const ARRAY *other) const;
134     ARRAY *buildUnion(const ARRAY *other) const;
135     ARRAY *buildIntersection(const ARRAY *other) const;
136     DataArrayIdType *indexOfSameConsecutiveValueGroups() const;
137     ARRAY *buildUnique() const;
138     ARRAY *buildUniqueNotSorted() const;
139     ARRAY *deltaShiftIndex() const;
140     void computeOffsets();
141     void computeOffsetsFull();
142     ARRAY *buildExplicitArrByRanges(const ARRAY *offsets) const;
143     DataArrayIdType *findRangeIdForEachTuple(const ARRAY *ranges) const;
144     ARRAY *findIdInRangeForEachTuple(const ARRAY *ranges) const;
145     void sortEachPairToMakeALinkedList();
146     ARRAY *duplicateEachTupleNTimes(mcIdType nbTimes) const;
147     ARRAY *getDifferentValues() const;
148     static ARRAY *Add(const ARRAY *a1, const ARRAY *a2);
149     void addEqual(const ARRAY *other);
150     static ARRAY *Substract(const ARRAY *a1, const ARRAY *a2);
151     void substractEqual(const ARRAY *other);
152     static ARRAY *Multiply(const ARRAY *a1, const ARRAY *a2);
153     void multiplyEqual(const ARRAY *other);
154     static ARRAY *Divide(const ARRAY *a1, const ARRAY *a2);
155     void divideEqual(const ARRAY *other);
156     static ARRAY *Modulus(const ARRAY *a1, const ARRAY *a2);
157     void modulusEqual(const ARRAY *other);
158     static ARRAY *Pow(const ARRAY *a1, const ARRAY *a2);
159     void powEqual(const ARRAY *other);
160     MCAuto<ARRAY> fromLinkedListOfPairToList() const;
161     MCAuto<DataArrayIdType> findIdsGreaterOrEqualTo(INT val) const;
162     MCAuto<DataArrayIdType> findIdsGreaterThan(INT val) const;
163     MCAuto<DataArrayIdType> findIdsLowerOrEqualTo(INT val) const;
164     MCAuto<DataArrayIdType> findIdsLowerThan(INT val) const;
165     MCAuto<ARRAY> selectPartDef(const PartDefinition* pd) const;
166     MCAuto<DataArrayDouble> convertToDblArr() const;
167     MCAuto<DataArrayFloat> convertToFloatArr() const;
168   public:
169     static ARRAY *Range(INT begin, INT end, INT step);
170     %extend
171     {
172       ARRAY()
173         {
174           return ARRAY::New();
175         }
176
177       static ARRAY *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
178       {
179         const char *msgBase="MEDCoupling::ARRAY::New : Available API are : \n-ARRAY.New()\n-ARRAY.New([1,3,4])\n-ARRAY.New([1,3,4],3)\n-ARRAY.New([1,3,4,5],2,2)\n-ARRAY.New([1,3,4,5,7,8],3,2)\n-ARRAY.New([(1,3),(4,5),(7,8)])\n-ARRAY.New(5)\n-ARRAY.New(5,2)";
180         std::string msg(msgBase);
181         if ( MEDCouplingHasNumPyBindings() )
182           msg+="\n-ARRAY.New(numpy array with dtype=int32)";
183
184         msg+=" !";
185         if(PyList_Check(elt0) || PyTuple_Check(elt0))
186           {
187             if(nbOfTuples)
188               {
189                 if(PyInt_Check(nbOfTuples))
190                   {
191                     mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples));
192                     if(nbOfTuples1<0)
193                       throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive set of allocated memory !");
194                     if(nbOfComp)
195                       {
196                         if(PyInt_Check(nbOfComp))
197                           {//ARRAY.New([1,3,4,5],2,2)
198                             mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp));
199                             if(nbOfCompo<0)
200                               throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive number of components !");
201                             MCAuto<ARRAY> ret=ARRAY::New();
202                             std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(elt0,nbOfTuples1,nbOfCompo);
203                             ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
204                             return ret.retn();
205                           }
206                         else
207                           throw INTERP_KERNEL::Exception(msg.c_str());
208                       }
209                     else
210                       {//ARRAY.New([1,3,4],3)
211                         MCAuto<ARRAY> ret=ARRAY::New();
212                         mcIdType tmpp1=-1;
213                         std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(elt0,nbOfTuples1,tmpp1);
214                         ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
215                         return ret.retn();
216                       }
217                   }
218                 else
219                   throw INTERP_KERNEL::Exception(msg.c_str());
220               }
221             else
222               {// ARRAY.New([1,3,4])
223                 MCAuto<ARRAY> ret=ARRAY::New();
224                 mcIdType tmpp1=-1,tmpp2=-1;
225                 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(elt0,tmpp1,tmpp2);
226                 ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
227                 return ret.retn();
228               }
229           }
230         else if(PyInt_Check(elt0))
231           {
232             INT nbOfTuples1=(INT)PyInt_AS_LONG(elt0);
233             if(nbOfTuples1<0)
234               throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive set of allocated memory !");
235             if(nbOfTuples)
236               {
237                 if(!nbOfComp)
238                   {
239                     if(PyInt_Check(nbOfTuples))
240                       {//ARRAY.New(5,2)
241                         INT nbOfCompo=(INT)PyInt_AS_LONG(nbOfTuples);
242                         if(nbOfCompo<0)
243                           throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive number of components !");
244                         MCAuto<ARRAY> ret=ARRAY::New();
245                         ret->alloc(nbOfTuples1,nbOfCompo);
246                         return ret.retn();
247                       }
248                     else
249                       throw INTERP_KERNEL::Exception(msg.c_str());
250                   }
251                 else
252                   throw INTERP_KERNEL::Exception(msg.c_str());
253               }
254             else
255               {//ARRAY.New(5)
256                 MCAuto<ARRAY> ret=ARRAY::New();
257                 ret->alloc(nbOfTuples1,1);
258                 return ret.retn();
259               }
260           }
261 #if defined(WITH_NUMPY)
262         else if(MEDCouplingHasNumPyBindings() && PyArray_Check(elt0) && nbOfTuples==NULL && nbOfComp==NULL)
263           {//ARRAY.New(numpyArray)
264             return BuildNewInstance<ARRAY,INT>(elt0,NPYTraits<INT>::NPYObjectType,NPYTraits<INT>::NPYFunc,MEDCoupling::Traits<INT>::NPYStr);
265           }
266 #endif
267         else
268           throw INTERP_KERNEL::Exception(msg.c_str());
269         throw INTERP_KERNEL::Exception(msg.c_str());//to make g++ happy
270       }
271
272       ARRAY(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
273         {
274           return MEDCoupling_ ## ARRAY ## _New__SWIG_1(elt0,nbOfTuples,nbOfComp);
275         }
276       
277       std::string __str__() const
278       {
279         return self->reprNotTooLong();
280       }
281
282       mcIdType __len__() const
283       {
284         if(self->isAllocated())
285           {
286             return self->getNumberOfTuples();
287           }
288         else
289           {
290             throw INTERP_KERNEL::Exception("ARRAY::__len__ : Instance is NOT allocated !");
291           }
292       }
293
294       INT __int__() const
295       {
296         return self->intValue();
297       }
298
299       ARRAY ## Iterator *__iter__()
300       {
301         return self->iterator();
302       }
303    
304       PyObject *accumulate() const
305       {
306         mcIdType sz=ToIdType(self->getNumberOfComponents());
307         INTERP_KERNEL::AutoPtr<INT> tmp=new INT[sz];
308         self->accumulate((INT *)tmp);
309         return convertIntArrToPyList((const INT *)tmp,sz);
310       }
311
312       ARRAY *accumulatePerChunck(PyObject *indexArr) const
313       {
314         mcIdType sw,sz,val;
315         std::vector<mcIdType> val2;
316         const mcIdType *bg=convertIntStarLikePyObjToCppIntStar(indexArr,sw,sz,val,val2);
317         return self->accumulatePerChunck(bg,bg+sz);
318       }
319
320       DataArrayIdType *findIdsEqualTuple(PyObject *inputTuple) const
321       {
322         mcIdType sw,sz;
323         INT val;
324         std::vector<INT> val2;
325         const INT *bg(convertIntStarLikePyObjToCppIntStar(inputTuple,sw,sz,val,val2));
326         return self->findIdsEqualTuple(bg,bg+sz);
327       }
328
329       DataArrayIdType *findIdForEach(PyObject *vals) const
330       {
331         mcIdType sw,sz;
332         INT val;
333         std::vector<INT> val2;
334         const INT *bg(convertIntStarLikePyObjToCppIntStar(vals,sw,sz,val,val2));
335         MCAuto<DataArrayIdType> ret(self->findIdForEach(bg,bg+sz));
336         return ret.retn();
337       }
338
339       PyObject *splitInBalancedSlices(mcIdType nbOfSlices) const
340       {
341         std::vector< std::pair<mcIdType,mcIdType> > slcs(self->splitInBalancedSlices(nbOfSlices));
342         PyObject *ret=PyList_New(slcs.size());
343         for(std::size_t i=0;i<slcs.size();i++)
344           PyList_SetItem(ret,i,PySlice_New(PyInt_FromLong(slcs[i].first),PyInt_FromLong(slcs[i].second),PyInt_FromLong(1)));
345         return ret;
346       }
347
348       ARRAY *buildExplicitArrOfSliceOnScaledArr(PyObject *slic) const
349       {
350         if(!PySlice_Check(slic))
351           throw INTERP_KERNEL::Exception("ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : expecting a pyslice as second (first) parameter !");
352         Py_ssize_t strt=2,stp=2,step=2;
353         GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !");
354         if(strt==std::numeric_limits<INT>::max() || stp==std::numeric_limits<INT>::max())
355           throw INTERP_KERNEL::Exception("ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice contains some unknowns that can't be determined in static method ! Call DataArray::getSlice (non static) instead !");
356         return self->buildExplicitArrOfSliceOnScaledArr((INT)strt,(INT)stp,(INT)step);
357       }
358
359       PyObject *getMinMaxValues() const
360       {
361         INT a,b;
362         self->getMinMaxValues(a,b);
363         PyObject *ret=PyTuple_New(2);
364         PyTuple_SetItem(ret,0,PyInt_FromLong(a));
365         PyTuple_SetItem(ret,1,PyInt_FromLong(b));
366         return ret;
367       }
368    
369       static PyObject *ConvertIndexArrayToO2N(mcIdType nbOfOldTuples, PyObject *arr, PyObject *arrI)
370       {
371         mcIdType newNbOfTuples=-1;
372         mcIdType szArr,szArrI,sw,iTypppArr,iTypppArrI;
373         std::vector<mcIdType> stdvecTyyppArr;
374         std::vector<mcIdType> stdvecTyyppArrI;
375         const mcIdType *arrPtr=convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr);
376         const mcIdType *arrIPtr=convertIntStarLikePyObjToCppIntStar(arrI,sw,szArrI,iTypppArrI,stdvecTyyppArrI);
377         DataArrayIdType *ret0=MEDCoupling::ARRAY::ConvertIndexArrayToO2N(nbOfOldTuples,arrPtr,arrIPtr,arrIPtr+szArrI,newNbOfTuples);
378         PyObject *ret=PyTuple_New(2);
379         PyTuple_SetItem(ret,0,SWIG_NewPointerObj((void*)ret0,SWIGTITraits<mcIdType>::TI,SWIG_POINTER_OWN | 0));
380         PyTuple_SetItem(ret,1,PyInt_FromLong(newNbOfTuples));
381         return ret;
382       }
383
384       static DataArrayIdType *CheckAndPreparePermutation(PyObject *arr)
385       {
386         MCAuto<DataArrayIdType> ret(DataArrayIdType::New());
387         mcIdType szArr,sw;
388         INT iTypppArr;
389         std::vector<INT> stdvecTyyppArr;
390         const INT *arrPtr(convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr));
391         mcIdType *pt(MEDCoupling::ARRAY::CheckAndPreparePermutation(arrPtr,arrPtr+szArr));
392         ret->useArray(pt,true,MEDCoupling::DeallocType::C_DEALLOC,szArr,1);
393         return ret.retn();
394       }
395
396       void setValues(PyObject *li, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
397       {
398         const char *msg="MEDCoupling::ARRAY::setValues : Available API are : \n-ARRAY.setValues([1,3,4])\n-ARRAY.setValues([1,3,4],3)\n-ARRAY.setValues([1,3,4,5],2,2)\n-ARRAY.New(5)\n !";
399         if(PyList_Check(li) || PyTuple_Check(li))
400           {
401             if(nbOfTuples && nbOfTuples != Py_None)
402               {
403                 if(PyInt_Check(nbOfTuples))
404                   {
405                     mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples));
406                     if(nbOfTuples1<0)
407                       throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive set of allocated memory !");
408                     if(nbOfComp && nbOfComp != Py_None)
409                       {
410                         if(PyInt_Check(nbOfComp))
411                           {//ARRAY.setValues([1,3,4,5],2,2)
412                             mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp));
413                             if(nbOfCompo<0)
414                               throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive number of components !");
415                             std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,nbOfTuples1,nbOfCompo);
416                             self->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),self->getPointer());
417                           }
418                         else
419                           throw INTERP_KERNEL::Exception(msg);
420                       }
421                     else
422                       {//ARRAY.setValues([1,3,4],3)
423                         mcIdType tmpp1=-1;
424                         std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,nbOfTuples1,tmpp1);
425                         self->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),self->getPointer());
426                       }
427                   }
428                 else
429                   throw INTERP_KERNEL::Exception(msg);
430               }
431             else
432               {// ARRAY.setValues([1,3,4])
433                 mcIdType tmpp1=-1,tmpp2=-1;
434                 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,tmpp1,tmpp2);
435                 self->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),self->getPointer());
436               }
437           }
438         else
439           throw INTERP_KERNEL::Exception(msg);
440       }
441
442       PyObject *getValues() const
443       {
444         const INT *vals=self->getConstPointer();
445         return convertIntArrToPyList(vals,self->getNbOfElems());
446       }
447
448       PyObject *isEqualIfNotWhy(const ARRAY& other) const
449       {
450         std::string ret1;
451         bool ret0=self->isEqualIfNotWhy(other,ret1);
452         PyObject *ret=PyTuple_New(2);
453         PyObject *ret0Py=ret0?Py_True:Py_False;
454         Py_XINCREF(ret0Py);
455         PyTuple_SetItem(ret,0,ret0Py);
456         PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str()));
457         return ret;
458       }
459
460       PyObject *getValuesAsTuple() const
461       {
462         const INT *vals=self->getConstPointer();
463         mcIdType nbOfComp=ToIdType(self->getNumberOfComponents());
464         mcIdType nbOfTuples=self->getNumberOfTuples();
465         return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
466       }
467
468       static PyObject *MakePartition(PyObject *gps, mcIdType newNb)
469       {
470         std::vector<const ARRAY *> groups;
471         std::vector< std::vector<mcIdType> > fidsOfGroups;
472         convertFromPyObjVectorOfObj(gps,SWIGTITraits<INT>::TI,"ARRAY",groups);
473         DataArrayIdType *ret0=MEDCoupling::ARRAY::MakePartition(groups,newNb,fidsOfGroups);
474         PyObject *ret = PyList_New(2);
475         PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
476         std::size_t sz=fidsOfGroups.size();
477         PyObject *ret1 = PyList_New(sz);
478         for(std::size_t i=0;i<sz;i++)
479           PyList_SetItem(ret1,i,convertIntArrToPyList2(fidsOfGroups[i]));
480         PyList_SetItem(ret,1,ret1);
481         return ret;
482       }
483
484       DataArrayIdType *findIdsEqualList(PyObject *obj)
485       {
486         mcIdType sw;
487         INT singleVal;
488         std::vector<INT> multiVal;
489         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
490         ARRAY *daIntTyypp=0;
491         convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
492         switch(sw)
493           {
494           case 1:
495             return self->findIdsEqualList(&singleVal,&singleVal+1);
496           case 2:
497             return self->findIdsEqualList(&multiVal[0],&multiVal[0]+multiVal.size());
498           case 4:
499             return self->findIdsEqualList(daIntTyypp->begin(),daIntTyypp->end());
500           default:
501             throw INTERP_KERNEL::Exception("ARRAY::findIdsEqualList : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
502           }
503       }
504
505       DataArrayIdType *findIdsNotEqualList(PyObject *obj)
506       {
507         mcIdType sw;
508         INT singleVal;
509         std::vector<INT> multiVal;
510         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
511         ARRAY *daIntTyypp=0;
512         convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
513         switch(sw)
514           {
515           case 1:
516             return self->findIdsNotEqualList(&singleVal,&singleVal+1);
517           case 2:
518             return self->findIdsNotEqualList(&multiVal[0],&multiVal[0]+multiVal.size());
519           case 4:
520             return self->findIdsNotEqualList(daIntTyypp->begin(),daIntTyypp->end());
521           default:
522             throw INTERP_KERNEL::Exception("ARRAY::findIdsNotEqualList : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
523           }
524       }
525
526       PyObject *splitByValueRange(PyObject *li) const
527       {
528         ARRAY *ret0=0,*ret1=0,*ret2=0;
529         void *da=0;
530         int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<INT>::TI, 0 |  0 );
531         if (!SWIG_IsOK(res1))
532           {
533             mcIdType size;
534             INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
535             self->splitByValueRange(tmp,(INT *)tmp+size,ret0,ret1,ret2);
536           }
537         else
538           {
539             ARRAY *da2=reinterpret_cast< ARRAY * >(da);
540             if(!da2)
541               throw INTERP_KERNEL::Exception("Not null ARRAY instance expected !");
542             da2->checkAllocated();
543             self->splitByValueRange(da2->begin(),da2->end(),ret0,ret1,ret2);
544           }
545         PyObject *ret = PyList_New(3);
546         PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
547         PyList_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
548         PyList_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(ret2),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
549         return ret;
550       }
551
552       DataArrayIdType *transformWithIndArrR(PyObject *li) const
553       {
554         void *da=0;
555         int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<INT>::TI, 0 |  0 );
556         if (!SWIG_IsOK(res1))
557           {
558             mcIdType size;
559             INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
560             return self->transformWithIndArrR(tmp,tmp+size);
561           }
562         else
563           {
564             ARRAY *da2=reinterpret_cast< ARRAY * >(da);
565             return self->transformWithIndArrR(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
566           }
567       }
568
569       ARRAY *renumberAndReduce(PyObject *li, mcIdType newNbOfTuple)
570       {
571         void *da=0;
572         int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 |  0 );
573         if (!SWIG_IsOK(res1))
574           {
575             mcIdType size;
576             INTERP_KERNEL::AutoPtr<mcIdType> tmp=convertPyToNewIntArr2(li,&size);
577             if(size!=self->getNumberOfTuples())
578               {
579                 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
580               }
581             return self->renumberAndReduce(tmp,newNbOfTuple);
582           }
583         else
584           {
585             DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da);
586             if(!da2)
587               throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
588             da2->checkAllocated();
589             mcIdType size=self->getNumberOfTuples();
590             if(size!=self->getNumberOfTuples())
591               {
592                 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
593               }
594             return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple);
595           }
596       }
597
598       ARRAY *renumber(PyObject *li)
599       {
600         void *da=0;
601         int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 |  0 );
602         if (!SWIG_IsOK(res1))
603           {
604             mcIdType size;
605             INTERP_KERNEL::AutoPtr<mcIdType> tmp=convertPyToNewIntArr2(li,&size);
606             if(size!=self->getNumberOfTuples())
607               {
608                 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
609               }
610             return self->renumber(tmp);
611           }
612         else
613           {
614             DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da);
615             if(!da2)
616               throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
617             da2->checkAllocated();
618             mcIdType size=self->getNumberOfTuples();
619             if(size!=self->getNumberOfTuples())
620               {
621                 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
622               }
623             return self->renumber(da2->getConstPointer());
624           }
625       }
626
627       ARRAY *renumberR(PyObject *li)
628       {
629         void *da=0;
630         int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 |  0 );
631         if (!SWIG_IsOK(res1))
632           {
633             mcIdType size;
634             INTERP_KERNEL::AutoPtr<mcIdType> tmp=convertPyToNewIntArr2(li,&size);
635             if(size!=self->getNumberOfTuples())
636               {
637                 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
638               }
639             return self->renumberR(tmp);
640           }
641         else
642           {
643             DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da);
644             if(!da2)
645               throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
646             da2->checkAllocated();
647             mcIdType size=self->getNumberOfTuples();
648             if(size!=self->getNumberOfTuples())
649               {
650                 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
651               }
652             return self->renumberR(da2->getConstPointer());
653           }
654       }
655
656       void setSelectedComponents(const ARRAY *a, PyObject *li)
657       {
658         std::vector<std::size_t> tmp;
659         convertPyToNewIntArr3(li,tmp);
660         self->setSelectedComponents(a,tmp);
661       }
662
663       PyObject *explodeComponents() const
664       {
665         std::vector< MCAuto<ARRAY> > retCpp(self->explodeComponents());
666         std::size_t sz(retCpp.size());
667         PyObject *res(PyList_New(sz));
668         for(std::size_t i=0;i<sz;i++)
669           PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(retCpp[i].retn()),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
670         return res;
671       }
672
673       PyObject *getTuple(mcIdType tupleId)
674       {
675         mcIdType sz=ToIdType(self->getNumberOfComponents());
676         INTERP_KERNEL::AutoPtr<INT> tmp=new INT[sz];
677         self->getTuple(tupleId,tmp);
678         return convertIntArrToPyList((const INT*)tmp,sz);
679       }
680
681       PyObject *changeSurjectiveFormat(INT targetNb) const
682       {
683         DataArrayIdType *arr=0;
684         DataArrayIdType *arrI=0;
685         self->changeSurjectiveFormat(targetNb,arr,arrI);
686         PyObject *res = PyList_New(2);
687         PyList_SetItem(res,0,SWIG_NewPointerObj((void*)arr,SWIGTITraits<mcIdType>::TI,SWIG_POINTER_OWN | 0));
688         PyList_SetItem(res,1,SWIG_NewPointerObj((void*)arrI,SWIGTITraits<mcIdType>::TI,SWIG_POINTER_OWN | 0));
689         return res;
690       }
691
692       static ARRAY *Meld(PyObject *li)
693       {
694         std::vector<const ARRAY *> tmp;
695         convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
696         return ARRAY::Meld(tmp);
697       }
698
699       static ARRAY *Aggregate(PyObject *li)
700       {
701         std::vector<const ARRAY *> tmp;
702         convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
703         return ARRAY::Aggregate(tmp);
704       }
705
706       static ARRAY *AggregateIndexes(PyObject *li)
707       {
708         std::vector<const ARRAY *> tmp;
709         convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
710         return ARRAY::AggregateIndexes(tmp);
711       }
712
713       static ARRAY *BuildUnion(PyObject *li)
714       {
715         std::vector<const ARRAY *> tmp;
716         convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
717         return ARRAY::BuildUnion(tmp);
718       }
719
720       static ARRAY *BuildIntersection(PyObject *li)
721       {
722         std::vector<const ARRAY *> tmp;
723         convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
724         return ARRAY::BuildIntersection(tmp);
725       }
726
727       PyObject *getMaxValue() const
728       {
729         mcIdType tmp;
730         INT r1=self->getMaxValue(tmp);
731         PyObject *ret=PyTuple_New(2);
732         PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
733         PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
734         return ret;
735       }
736     
737       PyObject *getMaxAbsValue(std::size_t& tupleId) const
738       {
739         std::size_t tmp;
740         INT r1=self->getMaxAbsValue(tmp);
741         PyObject *ret=PyTuple_New(2);
742         PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
743         PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
744         return ret;
745       }
746
747       PyObject *getMinValue() const
748       {
749         mcIdType tmp;
750         INT r1=self->getMinValue(tmp);
751         PyObject *ret=PyTuple_New(2);
752         PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
753         PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
754         return ret;
755       }
756
757       mcIdType index(PyObject *obj) const
758       {
759         std::size_t nbOfCompo=self->getNumberOfComponents();
760         switch(nbOfCompo)
761           {
762           case 1:
763             {
764               if(PyInt_Check(obj))
765                 {
766                   INT val=(INT)PyInt_AS_LONG(obj);
767                   return self->findIdFirstEqual(val);
768                 }
769               else
770                 throw INTERP_KERNEL::Exception("ARRAY::index : 'this' contains one component and trying to find an element which is not an integer !");
771             }
772           default:
773             {
774               std::vector<INT> arr;
775               convertPyToNewIntArr3(obj,arr);
776               return self->findIdFirstEqualTuple(arr);
777             }
778           }
779       }
780
781       bool __contains__(PyObject *obj) const
782       {
783         std::size_t nbOfCompo=self->getNumberOfComponents();
784         switch(nbOfCompo)
785           {
786           case 0:
787             return false;
788           case 1:
789             {
790               if(PyInt_Check(obj))
791                 {
792                   INT val=(INT)PyInt_AS_LONG(obj);
793                   return self->presenceOfValue(val);
794                 }
795               else
796                 throw INTERP_KERNEL::Exception("ARRAY::__contains__ : 'this' contains one component and trying to find an element which is not an integer !");
797             }
798           default:
799             {
800               std::vector<INT> arr;
801               convertPyToNewIntArr3(obj,arr);
802               return self->presenceOfTuple(arr);
803             }
804           }
805       }
806
807       PyObject *__getitem__(PyObject *obj)
808       {
809         const char msg[]="Unexpected situation in ARRAY::__getitem__ !";
810         const char msg2[]="ARRAY::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
811         self->checkAllocated();
812         mcIdType nbOfTuples=self->getNumberOfTuples();
813         std::size_t nbOfComponents=self->getNumberOfComponents();
814         mcIdType it1;
815         std::size_t ic1;
816         std::vector<mcIdType> vt1;
817         std::vector<std::size_t> vc1;
818         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > pt1,pc1;
819         DataArrayIdType *dt1=0,*dc1=0;
820         mcIdType sw;
821         convertObjToPossibleCpp3(obj,nbOfTuples,(int)nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
822         MCAuto<ARRAY> ret;
823         switch(sw)
824           {
825           case 1:
826             {
827               if(nbOfComponents==1)
828                 return PyInt_FromLong(self->getIJSafe(it1,0));
829               return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&it1,&it1+1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
830             }
831           case 2:
832             return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size())),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
833           case 3:
834             return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
835           case 4:
836             return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems())),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
837           case 5:
838             return PyInt_FromLong(self->getIJSafe(it1,ic1));
839           case 6:
840             {
841               ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
842               std::vector<std::size_t> v2(1,ic1);
843               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
844             }
845           case 7:
846             {
847               ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
848               std::vector<std::size_t> v2(1,ic1);
849               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
850             }
851           case 8:
852             {
853               ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
854               std::vector<std::size_t> v2(1,ic1);
855               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
856             }
857           case 9:
858             {
859               ret=self->selectByTupleIdSafe(&it1,&it1+1);
860               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
861             }
862           case 10:
863             {
864               ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
865               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
866             }
867           case 11:
868             {
869               ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
870               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
871             }
872           case 12:
873             {
874               ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
875               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
876             }
877           case 13:
878             {
879               ret=self->selectByTupleIdSafe(&it1,&it1+1);
880               mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
881               std::vector<std::size_t> v2(nbOfComp);
882               for(INT i=0;i<nbOfComp;i++)
883                 v2[i]=pc1.first+i*pc1.second.second;
884               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
885             }
886           case 14:
887             {
888               ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
889               mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
890               std::vector<std::size_t> v2(nbOfComp);
891               for(INT i=0;i<nbOfComp;i++)
892                 v2[i]=pc1.first+i*pc1.second.second;
893               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
894             }
895           case 15:
896             {
897               ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
898               mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
899               std::vector<std::size_t> v2(nbOfComp);
900               for(mcIdType i=0;i<nbOfComp;i++)
901                 v2[i]=pc1.first+i*pc1.second.second;
902               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
903             }
904           case 16:
905             {
906               ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
907               mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
908               std::vector<std::size_t> v2(nbOfComp);
909               for(INT i=0;i<nbOfComp;i++)
910                 v2[i]=pc1.first+i*pc1.second.second;
911               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
912             }
913           default:
914             throw INTERP_KERNEL::Exception(msg);
915           }
916       }
917
918       ARRAY *__setitem__(PyObject *obj, PyObject *value)
919       {
920         self->checkAllocated();
921         const char msg[]="Unexpected situation in __setitem__ !";
922         mcIdType nbOfTuples=self->getNumberOfTuples();
923         int nbOfComponents=(int)self->getNumberOfComponents();
924         mcIdType sw1,sw2;
925         INT i1;
926         std::vector<INT> v1;
927         ARRAY *d1=0;
928         ARRAY ## Tuple *dd1=0;
929         convertIntStarLikePyObjToCpp(value,sw1,i1,v1,d1,dd1);
930         mcIdType it1,ic1;
931         std::vector<mcIdType> vt1,vc1;
932         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > pt1,pc1;
933         DataArrayIdType *dt1=0,*dc1=0;
934         convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
935         MCAuto<ARRAY> tmp;
936         switch(sw2)
937           {
938           case 1:
939             {
940               switch(sw1)
941                 {
942                 case 1:
943                   self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
944                   return self;
945                 case 2:
946                   tmp=ARRAY::New();
947                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
948                   self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
949                   return self;
950                 case 3:
951                   self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1);
952                   return self;
953                 case 4:
954                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
955                   self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1);
956                   return self;
957                 default:
958                   throw INTERP_KERNEL::Exception(msg);
959                 }
960               break;
961             }
962           case 2:
963             {
964               switch(sw1)
965                 {
966                 case 1:
967                   self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
968                   return self;
969                 case 2:
970                   tmp=ARRAY::New();
971                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
972                   self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
973                   return self;
974                 case 3:
975                   self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
976                   return self;
977                 case 4:
978                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
979                   self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
980                   return self;
981                 default:
982                   throw INTERP_KERNEL::Exception(msg);
983                 }
984               break;
985             }
986           case 3:
987             {
988               switch(sw1)
989                 {
990                 case 1:
991                   self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
992                   return self;
993                 case 2:
994                   tmp=ARRAY::New();
995                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
996                   self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
997                   return self;
998                 case 3:
999                   self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
1000                   return self;
1001                 case 4:
1002                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1003                   self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
1004                   return self;
1005                 default:
1006                   throw INTERP_KERNEL::Exception(msg);
1007                 }
1008               break;
1009             }
1010           case 4:
1011             {
1012               switch(sw1)
1013                 {
1014                 case 1:
1015                   self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
1016                   return self;
1017                 case 2:
1018                   tmp=ARRAY::New();
1019                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1020                   self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
1021                   return self;
1022                 case 3:
1023                   self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
1024                   return self;
1025                 case 4:
1026                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1027                   self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
1028                   return self;
1029                 default:
1030                   throw INTERP_KERNEL::Exception(msg);
1031                 }
1032               break;
1033             }
1034           case 5:
1035             {
1036               switch(sw1)
1037                 {
1038                 case 1:
1039                   self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
1040                   return self;
1041                 case 2:
1042                   tmp=ARRAY::New();
1043                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1044                   self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
1045                   return self;
1046                 case 3:
1047                   self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1);
1048                   return self;
1049                 case 4:
1050                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1051                   self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1);
1052                   return self;
1053                 default:
1054                   throw INTERP_KERNEL::Exception(msg);
1055                 }
1056               break;
1057             }
1058           case 6:
1059             {
1060               switch(sw1)
1061                 {
1062                 case 1:
1063                   self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
1064                   return self;
1065                 case 2:
1066                   tmp=ARRAY::New();
1067                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1068                   self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
1069                   return self;
1070                 case 3:
1071                   self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
1072                   return self;
1073                 case 4:
1074                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1075                   self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
1076                   return self;
1077                 default:
1078                   throw INTERP_KERNEL::Exception(msg);
1079                 }
1080               break;
1081             }
1082           case 7:
1083             {
1084               switch(sw1)
1085                 {
1086                 case 1:
1087                   self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
1088                   return self;
1089                 case 2:
1090                   tmp=ARRAY::New();
1091                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1092                   self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
1093                   return self;
1094                 case 3:
1095                   self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
1096                   return self;
1097                 case 4:
1098                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1099                   self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
1100                   return self;
1101                 default:
1102                   throw INTERP_KERNEL::Exception(msg);
1103                 }
1104               break;
1105             }
1106           case 8:
1107             {
1108               switch(sw1)
1109                 {
1110                 case 1:
1111                   self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
1112                   return self;
1113                 case 2:
1114                   tmp=ARRAY::New();
1115                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1116                   self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
1117                   return self;
1118                 case 3:
1119                   self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
1120                   return self;
1121                 case 4:
1122                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1123                   self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
1124                   return self;
1125                 default:
1126                   throw INTERP_KERNEL::Exception(msg);
1127                 }
1128               break;
1129             }
1130           case 9:
1131             {
1132               switch(sw1)
1133                 {
1134                 case 1:
1135                   self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
1136                   return self;
1137                 case 2:
1138                   tmp=ARRAY::New();
1139                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1140                   self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
1141                   return self;
1142                 case 3:
1143                   self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
1144                   return self;
1145                 case 4:
1146                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1147                   self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
1148                   return self;
1149                 default:
1150                   throw INTERP_KERNEL::Exception(msg);
1151                 }
1152               break;
1153             }
1154           case 10:
1155             {
1156               switch(sw1)
1157                 {
1158                 case 1:
1159                   self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
1160                   return self;
1161                 case 2:
1162                   tmp=ARRAY::New();
1163                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1164                   self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
1165                   return self;
1166                 case 3:
1167                   self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
1168                   return self;
1169                 case 4:
1170                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1171                   self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
1172                   return self;
1173                 default:
1174                   throw INTERP_KERNEL::Exception(msg);
1175                 }
1176               break;
1177             }
1178           case 11:
1179             {
1180               switch(sw1)
1181                 {
1182                 case 1:
1183                   self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
1184                   return self;
1185                 case 2:
1186                   tmp=ARRAY::New();
1187                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1188                   self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size(),false);
1189                   return self;
1190                 case 3:
1191                   self->setPartOfValues4(d1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
1192                   return self;
1193                 case 4:
1194                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1195                   self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
1196                   return self;
1197                 default:
1198                   throw INTERP_KERNEL::Exception(msg);
1199                 }
1200               break;
1201             }
1202           case 12:
1203             {
1204               switch(sw1)
1205                 {
1206                 case 1:
1207                   self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
1208                   return self;
1209                 case 2:
1210                   tmp=ARRAY::New();
1211                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1212                   self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
1213                   return self;
1214                 case 3:
1215                   self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
1216                   return self;
1217                 case 4:
1218                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1219                   self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
1220                   return self;
1221                 default:
1222                   throw INTERP_KERNEL::Exception(msg);
1223                 }
1224               break;
1225             }
1226           case 13:
1227             {
1228               switch(sw1)
1229                 {
1230                 case 1:
1231                   self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
1232                   return self;
1233                 case 2:
1234                   tmp=ARRAY::New();
1235                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1236                   self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
1237                   return self;
1238                 case 3:
1239                   self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
1240                   return self;
1241                 case 4:
1242                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1243                   self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
1244                   return self;
1245                 default:
1246                   throw INTERP_KERNEL::Exception(msg);
1247                 }
1248               break;
1249             }
1250           case 14:
1251             {
1252               switch(sw1)
1253                 {
1254                 case 1:
1255                   self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
1256                   return self;
1257                 case 2:
1258                   tmp=ARRAY::New();
1259                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1260                   self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false);
1261                   return self;
1262                 case 3:
1263                   self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
1264                   return self;
1265                 case 4:
1266                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1267                   self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
1268                   return self;
1269                 default:
1270                   throw INTERP_KERNEL::Exception(msg);
1271                 }
1272               break;
1273             }
1274           case 15:
1275             {
1276               switch(sw1)
1277                 {
1278                 case 1:
1279                   self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
1280                   return self;
1281                 case 2:
1282                   tmp=ARRAY::New();
1283                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1284                   self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false);
1285                   return self;
1286                 case 3:
1287                   self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
1288                   return self;
1289                 case 4:
1290                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1291                   self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
1292                   return self;
1293                 default:
1294                   throw INTERP_KERNEL::Exception(msg);
1295                 }
1296               break;
1297             }
1298           case 16:
1299             {
1300               switch(sw1)
1301                 {
1302                 case 1:
1303                   self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
1304                   return self;
1305                 case 2:
1306                   tmp=ARRAY::New();
1307                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1308                   self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false);
1309                   return self;
1310                 case 3:
1311                   self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
1312                   return self;
1313                 case 4:
1314                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1315                   self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
1316                   return self;
1317                 default:
1318                   throw INTERP_KERNEL::Exception(msg);
1319                 }
1320               break;
1321             }
1322           default:
1323             throw INTERP_KERNEL::Exception(msg);
1324           }
1325         return self;
1326       }
1327
1328       ARRAY *__neg__() const
1329       {
1330         return self->negate();
1331       }
1332  
1333       ARRAY *__add__(PyObject *obj)
1334       {
1335         const char msg[]="Unexpected situation in __add__ !";
1336         INT val;
1337         ARRAY *a;
1338         std::vector<INT> aa;
1339         ARRAY ## Tuple *aaa;
1340         mcIdType sw;
1341         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1342         switch(sw)
1343           {
1344           case 1:
1345             {
1346               MCAuto<ARRAY> ret=self->deepCopy();
1347               ret->applyLin(1,val);
1348               return ret.retn();
1349             }
1350           case 2:
1351             {
1352               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1353               return ARRAY::Add(self,aaaa);
1354             }
1355           case 3:
1356             {
1357               return ARRAY::Add(self,a);
1358             }
1359           case 4:
1360             {
1361               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1362               return ARRAY::Add(self,aaaa);
1363             }
1364           default:
1365             throw INTERP_KERNEL::Exception(msg);
1366           }
1367       }
1368
1369       ARRAY *__radd__(PyObject *obj)
1370       {
1371         const char msg[]="Unexpected situation in __radd__ !";
1372         INT val;
1373         ARRAY *a;
1374         std::vector<INT> aa;
1375         ARRAY ## Tuple *aaa;
1376         mcIdType sw;
1377         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1378         switch(sw)
1379           {
1380           case 1:
1381             {
1382               MCAuto<ARRAY> ret=self->deepCopy();
1383               ret->applyLin(1,val);
1384               return ret.retn();
1385             }
1386           case 2:
1387             {
1388               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1389               return ARRAY::Add(self,aaaa);
1390             }
1391           case 4:
1392             {
1393               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1394               return ARRAY::Add(self,aaaa);
1395             }
1396           default:
1397             throw INTERP_KERNEL::Exception(msg);
1398           }
1399       }
1400
1401       PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
1402       {
1403         const char msg[]="Unexpected situation in __iadd__ !";
1404         INT val;
1405         ARRAY *a;
1406         std::vector<INT> aa;
1407         ARRAY ## Tuple *aaa;
1408         mcIdType sw;
1409         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1410         switch(sw)
1411           {
1412           case 1:
1413             {
1414               self->applyLin(1,val);
1415               Py_XINCREF(trueSelf);
1416               return trueSelf;
1417             }
1418           case 2:
1419             {
1420               MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1421               self->addEqual(bb);
1422               Py_XINCREF(trueSelf);
1423               return trueSelf;
1424             }
1425           case 3:
1426             {
1427               self->addEqual(a);
1428               Py_XINCREF(trueSelf);
1429               return trueSelf;
1430             }
1431           case 4:
1432             {
1433               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1434               self->addEqual(aaaa);
1435               Py_XINCREF(trueSelf);
1436               return trueSelf;
1437             }
1438           default:
1439             throw INTERP_KERNEL::Exception(msg);
1440           }
1441       }
1442
1443       ARRAY *__sub__(PyObject *obj)
1444       {
1445         const char msg[]="Unexpected situation in __sub__ !";
1446         INT val;
1447         ARRAY *a;
1448         std::vector<INT> aa;
1449         ARRAY ## Tuple *aaa;
1450         mcIdType sw;
1451         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1452         switch(sw)
1453           {
1454           case 1:
1455             {
1456               MCAuto<ARRAY> ret=self->deepCopy();
1457               ret->applyLin(1,-val);
1458               return ret.retn();
1459             }
1460           case 2:
1461             {
1462               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1463               return ARRAY::Substract(self,aaaa);
1464             }
1465           case 3:
1466             {
1467               return ARRAY::Substract(self,a);
1468             }
1469           case 4:
1470             {
1471               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1472               return ARRAY::Substract(self,aaaa);
1473             }
1474           default:
1475             throw INTERP_KERNEL::Exception(msg);
1476           }
1477       }
1478
1479       ARRAY *__rsub__(PyObject *obj)
1480       {
1481         const char msg[]="Unexpected situation in __rsub__ !";
1482         INT val;
1483         ARRAY *a;
1484         std::vector<INT> aa;
1485         ARRAY ## Tuple *aaa;
1486         mcIdType sw;
1487         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1488         switch(sw)
1489           {
1490           case 1:
1491             {
1492               MCAuto<ARRAY> ret=self->deepCopy();
1493               ret->applyLin(-1,val);
1494               return ret.retn();
1495             }
1496           case 2:
1497             {
1498               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1499               return ARRAY::Substract(aaaa,self);
1500             }
1501           case 4:
1502             {
1503               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1504               return ARRAY::Substract(aaaa,self);
1505             }
1506           default:
1507             throw INTERP_KERNEL::Exception(msg);
1508           }
1509       }
1510
1511       PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
1512       {
1513         const char msg[]="Unexpected situation in __isub__ !";
1514         INT val;
1515         ARRAY *a;
1516         std::vector<INT> aa;
1517         ARRAY ## Tuple *aaa;
1518         mcIdType sw;
1519         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1520         switch(sw)
1521           {
1522           case 1:
1523             {
1524               self->applyLin(1,-val);
1525               Py_XINCREF(trueSelf);
1526               return trueSelf;
1527             }
1528           case 2:
1529             {
1530               MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1531               self->substractEqual(bb);
1532               Py_XINCREF(trueSelf);
1533               return trueSelf;
1534             }
1535           case 3:
1536             {
1537               self->substractEqual(a);
1538               Py_XINCREF(trueSelf);
1539               return trueSelf;
1540             }
1541           case 4:
1542             {
1543               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1544               self->substractEqual(aaaa);
1545               Py_XINCREF(trueSelf);
1546               return trueSelf;
1547             }
1548           default:
1549             throw INTERP_KERNEL::Exception(msg);
1550           }
1551       }
1552
1553       ARRAY *__mul__(PyObject *obj)
1554       {
1555         const char msg[]="Unexpected situation in __mul__ !";
1556         INT val;
1557         ARRAY *a;
1558         std::vector<INT> aa;
1559         ARRAY ## Tuple *aaa;
1560         mcIdType sw;
1561         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1562         switch(sw)
1563           {
1564           case 1:
1565             {
1566               MCAuto<ARRAY> ret=self->deepCopy();
1567               ret->applyLin(val,0);
1568               return ret.retn();
1569             }
1570           case 2:
1571             {
1572               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1573               return ARRAY::Multiply(self,aaaa);
1574             }
1575           case 3:
1576             {
1577               return ARRAY::Multiply(self,a);
1578             }
1579           case 4:
1580             {
1581               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1582               return ARRAY::Multiply(self,aaaa);
1583             }
1584           default:
1585             throw INTERP_KERNEL::Exception(msg);
1586           }
1587       }
1588
1589       ARRAY *__rmul__(PyObject *obj)
1590       {
1591         const char msg[]="Unexpected situation in __rmul__ !";
1592         INT val;
1593         ARRAY *a;
1594         std::vector<INT> aa;
1595         ARRAY ## Tuple *aaa;
1596         mcIdType sw;
1597         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1598         switch(sw)
1599           {
1600           case 1:
1601             {
1602               MCAuto<ARRAY> ret=self->deepCopy();
1603               ret->applyLin(val,0);
1604               return ret.retn();
1605             }
1606           case 2:
1607             {
1608               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1609               return ARRAY::Multiply(self,aaaa);
1610             }
1611           case 4:
1612             {
1613               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1614               return ARRAY::Multiply(self,aaaa);
1615             }
1616           default:
1617             throw INTERP_KERNEL::Exception(msg);
1618           }
1619       }
1620
1621       PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
1622       {
1623         const char msg[]="Unexpected situation in __imul__ !";
1624         INT val;
1625         ARRAY *a;
1626         std::vector<INT> aa;
1627         ARRAY ## Tuple *aaa;
1628         mcIdType sw;
1629         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1630         switch(sw)
1631           {
1632           case 1:
1633             {
1634               self->applyLin(val,0);
1635               Py_XINCREF(trueSelf);
1636               return trueSelf;
1637             }
1638           case 2:
1639             {
1640               MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1641               self->multiplyEqual(bb);
1642               Py_XINCREF(trueSelf);
1643               return trueSelf;
1644             }
1645           case 3:
1646             {
1647               self->multiplyEqual(a);
1648               Py_XINCREF(trueSelf);
1649               return trueSelf;
1650             }
1651           case 4:
1652             {
1653               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1654               self->multiplyEqual(aaaa);
1655               Py_XINCREF(trueSelf);
1656               return trueSelf;
1657             }
1658           default:
1659             throw INTERP_KERNEL::Exception(msg);
1660           }
1661       }
1662
1663       ARRAY *__div__(PyObject *obj)
1664       {
1665         const char msg[]="Unexpected situation in __div__ !";
1666         INT val;
1667         ARRAY *a;
1668         std::vector<INT> aa;
1669         ARRAY ## Tuple *aaa;
1670         mcIdType sw;
1671         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1672         switch(sw)
1673           {
1674           case 1:
1675             {
1676               MCAuto<ARRAY> ret=self->deepCopy();
1677               ret->applyDivideBy(val);
1678               return ret.retn();
1679             }
1680           case 2:
1681             {
1682               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1683               return ARRAY::Divide(self,aaaa);
1684             }
1685           case 3:
1686             {
1687               return ARRAY::Divide(self,a);
1688             }
1689           case 4:
1690             {
1691               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1692               return ARRAY::Divide(self,aaaa);
1693             }
1694           default:
1695             throw INTERP_KERNEL::Exception(msg);
1696           }
1697       }
1698
1699       ARRAY *__rdiv__(PyObject *obj)
1700       {
1701         const char msg[]="Unexpected situation in __rdiv__ !";
1702         INT val;
1703         ARRAY *a;
1704         std::vector<INT> aa;
1705         ARRAY ## Tuple *aaa;
1706         mcIdType sw;
1707         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1708         switch(sw)
1709           {
1710           case 1:
1711             {
1712               MCAuto<ARRAY> ret=self->deepCopy();
1713               ret->applyInv(val);
1714               return ret.retn();
1715             }
1716           case 2:
1717             {
1718               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1719               return ARRAY::Divide(aaaa,self);
1720             }
1721           case 4:
1722             {
1723               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1724               return ARRAY::Divide(aaaa,self);
1725             }
1726           default:
1727             throw INTERP_KERNEL::Exception(msg);
1728           }
1729       }
1730
1731       PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
1732       {
1733         const char msg[]="Unexpected situation in __idiv__ !";
1734         INT val;
1735         ARRAY *a;
1736         std::vector<INT> aa;
1737         ARRAY ## Tuple *aaa;
1738         mcIdType sw;
1739         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1740         switch(sw)
1741           {
1742           case 1:
1743             {
1744               self->applyDivideBy(val);
1745               Py_XINCREF(trueSelf);
1746               return trueSelf;
1747             }
1748           case 2:
1749             {
1750               MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1751               self->divideEqual(bb);
1752               Py_XINCREF(trueSelf);
1753               return trueSelf;
1754             }
1755           case 3:
1756             {
1757               self->divideEqual(a);
1758               Py_XINCREF(trueSelf);
1759               return trueSelf;
1760             }
1761           case 4:
1762             {
1763               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1764               self->divideEqual(aaaa);
1765               Py_XINCREF(trueSelf);
1766               return trueSelf;
1767             }
1768           default:
1769             throw INTERP_KERNEL::Exception(msg);
1770           }
1771       }
1772
1773       ARRAY *__mod__(PyObject *obj)
1774       {
1775         const char msg[]="Unexpected situation in __mod__ !";
1776         INT val;
1777         ARRAY *a;
1778         std::vector<INT> aa;
1779         ARRAY ## Tuple *aaa;
1780         mcIdType sw;
1781         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1782         switch(sw)
1783           {
1784           case 1:
1785             {
1786               MCAuto<ARRAY> ret=self->deepCopy();
1787               ret->applyModulus(val);
1788               return ret.retn();
1789             }
1790           case 2:
1791             {
1792               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1793               return ARRAY::Modulus(self,aaaa);
1794             }
1795           case 3:
1796             {
1797               return ARRAY::Modulus(self,a);
1798             }
1799           case 4:
1800             {
1801               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1802               return ARRAY::Modulus(self,aaaa);
1803             }
1804           default:
1805             throw INTERP_KERNEL::Exception(msg);
1806           }
1807       }
1808
1809       ARRAY *__rmod__(PyObject *obj)
1810       {
1811         const char msg[]="Unexpected situation in __rmod__ !";
1812         INT val;
1813         ARRAY *a;
1814         std::vector<INT> aa;
1815         ARRAY ## Tuple *aaa;
1816         mcIdType sw;
1817         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1818         switch(sw)
1819           {
1820           case 1:
1821             {
1822               MCAuto<ARRAY> ret=self->deepCopy();
1823               ret->applyRModulus(val);
1824               return ret.retn();
1825             }
1826           case 2:
1827             {
1828               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1829               return ARRAY::Modulus(aaaa,self);
1830             }
1831           case 3:
1832             {
1833               return ARRAY::Modulus(a,self);
1834             }
1835           case 4:
1836             {
1837               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1838               return ARRAY::Modulus(aaaa,self);
1839             }
1840           default:
1841             throw INTERP_KERNEL::Exception(msg);
1842           }
1843       }
1844
1845       PyObject *___imod___(PyObject *trueSelf, PyObject *obj)
1846       {
1847         const char msg[]="Unexpected situation in __imod__ !";
1848         INT val;
1849         ARRAY *a;
1850         std::vector<INT> aa;
1851         ARRAY ## Tuple *aaa;
1852         mcIdType sw;
1853         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1854         switch(sw)
1855           {
1856           case 1:
1857             {
1858               self->applyModulus(val);
1859               Py_XINCREF(trueSelf);
1860               return trueSelf;
1861             }
1862           case 3:
1863             {
1864               self->modulusEqual(a);
1865               Py_XINCREF(trueSelf);
1866               return trueSelf;
1867             }
1868           case 4:
1869             {
1870               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1871               self->modulusEqual(aaaa);
1872               Py_XINCREF(trueSelf);
1873               return trueSelf;
1874             }
1875           default:
1876             throw INTERP_KERNEL::Exception(msg);
1877           }
1878       }
1879
1880       ARRAY *__pow__(PyObject *obj)
1881       {
1882         const char msg[]="Unexpected situation in __pow__ !";
1883         INT val;
1884         ARRAY *a;
1885         std::vector<INT> aa;
1886         ARRAY ## Tuple *aaa;
1887         mcIdType sw;
1888         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1889         switch(sw)
1890           {
1891           case 1:
1892             {
1893               MCAuto<ARRAY> ret=self->deepCopy();
1894               ret->applyPow(val);
1895               return ret.retn();
1896             }
1897           case 2:
1898             {
1899               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1900               return ARRAY::Pow(self,aaaa);
1901             }
1902           case 3:
1903             {
1904               return ARRAY::Pow(self,a);
1905             }
1906           case 4:
1907             {
1908               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1909               return ARRAY::Pow(self,aaaa);
1910             }
1911           default:
1912             throw INTERP_KERNEL::Exception(msg);
1913           }
1914       }
1915
1916       ARRAY *__rpow__(PyObject *obj)
1917       {
1918         const char msg[]="Unexpected situation in __rpow__ !";
1919         INT val;
1920         ARRAY *a;
1921         std::vector<INT> aa;
1922         ARRAY ## Tuple *aaa;
1923         mcIdType sw;
1924         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1925         switch(sw)
1926           {
1927           case 1:
1928             {
1929               MCAuto<ARRAY> ret=self->deepCopy();
1930               ret->applyRPow(val);
1931               return ret.retn();
1932             }
1933           case 2:
1934             {
1935               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1936               return ARRAY::Pow(aaaa,self);
1937             }
1938           case 3:
1939             {
1940               return ARRAY::Pow(a,self);
1941             }
1942           case 4:
1943             {
1944               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1945               return ARRAY::Pow(aaaa,self);
1946             }
1947           default:
1948             throw INTERP_KERNEL::Exception(msg);
1949           }
1950       }
1951    
1952       PyObject *___ipow___(PyObject *trueSelf, PyObject *obj)
1953       {
1954         const char msg[]="Unexpected situation in __ipow__ !";
1955         INT val;
1956         ARRAY *a;
1957         std::vector<INT> aa;
1958         ARRAY ## Tuple *aaa;
1959         mcIdType sw;
1960         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1961         switch(sw)
1962           {
1963           case 1:
1964             {
1965               self->applyPow(val);
1966               Py_XINCREF(trueSelf);
1967               return trueSelf;
1968             }
1969           case 3:
1970             {
1971               self->powEqual(a);
1972               Py_XINCREF(trueSelf);
1973               return trueSelf;
1974             }
1975           case 4:
1976             {
1977               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1978               self->powEqual(aaaa);
1979               Py_XINCREF(trueSelf);
1980               return trueSelf;
1981             }
1982           default:
1983             throw INTERP_KERNEL::Exception(msg);
1984           }
1985       }
1986
1987       std::string __repr__() const
1988       {
1989         std::ostringstream oss;
1990         self->reprQuickOverview(oss);
1991         return oss.str();
1992       }
1993       
1994       void pushBackValsSilent(PyObject *li)
1995       {
1996         mcIdType szArr,sw;
1997         INT iTypppArr;
1998         std::vector<INT> stdvecTyyppArr;
1999         const INT *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr);
2000         self->pushBackValsSilent(tmp,tmp+szArr);
2001       }
2002       
2003       PyObject *partitionByDifferentValues() const
2004       {
2005         std::vector<INT> ret1;
2006         std::vector<DataArrayIdType *> ret0=self->partitionByDifferentValues(ret1);
2007         std::size_t sz=ret0.size();
2008         PyObject *pyRet=PyTuple_New(2);
2009         PyObject *pyRet0=PyList_New((INT)sz);
2010         PyObject *pyRet1=PyList_New((INT)sz);
2011         for(std::size_t i=0;i<sz;i++)
2012           {
2013             PyList_SetItem(pyRet0,i,SWIG_NewPointerObj(SWIG_as_voidptr(ret0[i]),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2014             PyList_SetItem(pyRet1,i,PyInt_FromLong(ret1[i]));
2015           }
2016         PyTuple_SetItem(pyRet,0,pyRet0);
2017         PyTuple_SetItem(pyRet,1,pyRet1);
2018         return pyRet;
2019       }
2020       
2021       PyObject *findIdsRangesInListOfIds(const ARRAY *listOfIds) const
2022       {
2023         DataArrayIdType *ret0=0;
2024         ARRAY *ret1=0;
2025         self->findIdsRangesInListOfIds(listOfIds,ret0,ret1);
2026         PyObject *pyRet=PyTuple_New(2);
2027         PyTuple_SetItem(pyRet,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2028         PyTuple_SetItem(pyRet,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
2029         return pyRet;
2030       }
2031
2032       PyObject *isRange() const
2033       {
2034         INT a(0),b(0),c(0);
2035         bool ret(self->isRange(a,b,c));
2036         PyObject *pyRet=PyTuple_New(2);
2037         PyObject *ret0Py=ret?Py_True:Py_False,*ret1Py(0);
2038         Py_XINCREF(ret0Py);
2039         PyTuple_SetItem(pyRet,0,ret0Py);
2040         if(ret)
2041           ret1Py=PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(c));
2042         else
2043           {
2044             ret1Py=Py_None;
2045             Py_XINCREF(ret1Py);
2046           }
2047         PyTuple_SetItem(pyRet,1,ret1Py);
2048         return pyRet;
2049       }
2050
2051       static bool RemoveIdsFromIndexedArrays(PyObject *li, ARRAY *arr, DataArrayIdType *arrIndx, mcIdType offsetForRemoval=0) throw(INTERP_KERNEL::Exception)
2052       {
2053         mcIdType sw;
2054         INT singleVal;
2055         std::vector<INT> multiVal;
2056         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2057         MEDCoupling::ARRAY *daIntTyypp=0;
2058         if(!arrIndx)
2059           throw INTERP_KERNEL::Exception("ARRAY::RemoveIdsFromIndexedArrays : null pointer as arrIndex !");
2060         convertIntStarOrSliceLikePyObjToCpp(li,arrIndx->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2061         switch(sw)
2062           {
2063           case 1:
2064             return ARRAY::RemoveIdsFromIndexedArrays(&singleVal,&singleVal+1,arr,arrIndx,offsetForRemoval);
2065           case 2:
2066             return ARRAY::RemoveIdsFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arr,arrIndx,offsetForRemoval);
2067           case 4:
2068             return ARRAY::RemoveIdsFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arr,arrIndx,offsetForRemoval);
2069           default:
2070             throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2071           }
2072       }
2073
2074       static PyObject *ExtractFromIndexedArrays(PyObject *li, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
2075       {
2076         ARRAY *arrOut=0;
2077         DataArrayIdType *arrIndexOut=0;
2078         mcIdType sw;
2079         mcIdType singleVal;
2080         std::vector<mcIdType> multiVal;
2081         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2082         MEDCoupling::DataArrayIdType *daIntTyypp=0;
2083         if(!arrIndxIn)
2084           throw INTERP_KERNEL::Exception("ARRAY::ExtractFromIndexedArrays : null pointer as arrIndxIn !");
2085         convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2086         switch(sw)
2087           {
2088           case 1:
2089             {
2090               ARRAY::ExtractFromIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,arrOut,arrIndexOut);
2091               break;
2092             }
2093           case 2:
2094             {
2095               ARRAY::ExtractFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,arrOut,arrIndexOut);
2096               break;
2097             }
2098           case 4:
2099             {
2100               ARRAY::ExtractFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,arrOut,arrIndexOut);
2101               break;
2102             }
2103           default:
2104             throw INTERP_KERNEL::Exception("ARRAY::ExtractFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2105           }
2106         PyObject *ret=PyTuple_New(2);
2107         PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2108         PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2109         return ret;
2110       }
2111
2112       static PyObject *ExtractFromIndexedArraysSlice(mcIdType strt, mcIdType stp, mcIdType step, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
2113       {
2114         ARRAY *arrOut=0;
2115         DataArrayIdType *arrIndexOut=0;
2116         ARRAY::ExtractFromIndexedArraysSlice(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut);
2117         PyObject *ret=PyTuple_New(2);
2118         PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2119         PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2120         return ret;
2121       }
2122
2123       static PyObject *ExtractFromIndexedArraysSlice(PyObject *slic, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
2124       {
2125         if(!PySlice_Check(slic))
2126           throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : the first param is not a pyslice !");
2127         Py_ssize_t strt=2,stp=2,step=2;
2128         if(!arrIndxIn)
2129           throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : last array is null !");
2130         arrIndxIn->checkAllocated();
2131         if(arrIndxIn->getNumberOfComponents()!=1)
2132           throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : number of components of last argument must be equal to one !");
2133         GetIndicesOfSlice(slic,arrIndxIn->getNumberOfTuples(),&strt,&stp,&step,"ExtractFromIndexedArraysSlice (wrap) : Invalid slice regarding nb of elements !");
2134         ARRAY *arrOut=0;
2135         DataArrayIdType *arrIndexOut=0;
2136         ARRAY::ExtractFromIndexedArraysSlice(ToIdType(strt),ToIdType(stp),ToIdType(step),arrIn,arrIndxIn,arrOut,arrIndexOut);
2137         PyObject *ret=PyTuple_New(2);
2138         PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2139         PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2140         return ret;
2141       }
2142
2143       static PyObject *SetPartOfIndexedArrays(PyObject *li,
2144                                               const ARRAY *arrIn, const DataArrayIdType *arrIndxIn,
2145                                               const ARRAY *srcArr, const DataArrayIdType *srcArrIndex) throw(INTERP_KERNEL::Exception)
2146       {
2147         ARRAY *arrOut=0;
2148         DataArrayIdType *arrIndexOut=0;
2149         mcIdType sw;
2150         mcIdType singleVal;
2151         std::vector<mcIdType> multiVal;
2152         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2153         MEDCoupling::DataArrayIdType *daIntTyypp=0;
2154         if(!arrIndxIn)
2155           throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArrays : null pointer as arrIndex !");
2156         convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2157         switch(sw)
2158           {
2159           case 1:
2160             {
2161               ARRAY::SetPartOfIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
2162               break;
2163             }
2164           case 2:
2165             {
2166               ARRAY::SetPartOfIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
2167               break;
2168             }
2169           case 4:
2170             {
2171               ARRAY::SetPartOfIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
2172               break;
2173             }
2174           default:
2175             throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2176           }
2177         PyObject *ret=PyTuple_New(2);
2178         PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2179         PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2180         return ret;
2181       }
2182
2183       static void SetPartOfIndexedArraysSameIdx(PyObject *li, ARRAY *arrIn, const DataArrayIdType *arrIndxIn,
2184                                                 const ARRAY *srcArr, const DataArrayIdType *srcArrIndex) throw(INTERP_KERNEL::Exception)
2185       {
2186         mcIdType sw;
2187         mcIdType singleVal;
2188         std::vector<mcIdType> multiVal;
2189         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2190         MEDCoupling::DataArrayIdType *daIntTyypp=0;
2191         if(!arrIndxIn)
2192           throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArraysSameIdx : null pointer as arrIndex !");
2193         convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2194         switch(sw)
2195           {
2196           case 1:
2197             {
2198               ARRAY::SetPartOfIndexedArraysSameIdx(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex);
2199               break;
2200             }
2201           case 2:
2202             {
2203               ARRAY::SetPartOfIndexedArraysSameIdx(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex);
2204               break;
2205             }
2206           case 4:
2207             {
2208               ARRAY::SetPartOfIndexedArraysSameIdx(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex);
2209               break;
2210             }
2211           default:
2212             throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArraysSameIdx : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2213           }
2214       }
2215
2216     } // end extent
2217   };
2218
2219   class ARRAY ## Tuple;
2220
2221   class ARRAY ## Iterator
2222   {
2223   public:
2224     ARRAY ## Iterator(ARRAY *da);
2225     ~ARRAY ## Iterator();
2226     %extend
2227     {
2228       PyObject *next()
2229       {
2230         ARRAY ## Tuple *ret=self->nextt();
2231         if(ret)
2232           return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_MEDCoupling__ ## ARRAY ## Tuple,SWIG_POINTER_OWN | 0);
2233         else
2234           {
2235             PyErr_SetString(PyExc_StopIteration,"No more data.");
2236             return 0;
2237           }
2238       }
2239     }
2240   };
2241
2242   class ARRAY ## Tuple
2243   {
2244   public:
2245     std::size_t getNumberOfCompo() const;
2246     ARRAY *buildDAInt(INT nbOfTuples, INT nbOfCompo) const;
2247     %extend
2248     {
2249       std::string __str__() const
2250       {
2251         return self->repr();
2252       }
2253
2254       INT __int__() const
2255       {
2256         return self->intValue();
2257       }
2258
2259       ARRAY *buildDAInt()
2260       {
2261         return self->buildDAInt(1,self->getNumberOfCompo());
2262       }
2263
2264       PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
2265       {
2266         MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2267         MEDCoupling_ ## ARRAY ## ____iadd___(ret,0,obj);
2268         Py_XINCREF(trueSelf);
2269         return trueSelf;
2270       }
2271   
2272       PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
2273       {
2274         MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2275         MEDCoupling_ ## ARRAY ## ____isub___(ret,0,obj);
2276         Py_XINCREF(trueSelf);
2277         return trueSelf;
2278       }
2279   
2280       PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
2281       {
2282         MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2283         MEDCoupling_ ## ARRAY ## ____imul___(ret,0,obj);
2284         Py_XINCREF(trueSelf);
2285         return trueSelf;
2286       }
2287       PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
2288       {
2289         MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2290         MEDCoupling_ ## ARRAY ## ____idiv___(ret,0,obj);
2291         Py_XINCREF(trueSelf);
2292         return trueSelf;
2293       }
2294
2295       PyObject *___imod___(PyObject *trueSelf, PyObject *obj)
2296       {
2297         MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2298         MEDCoupling_ ## ARRAY ## ____imod___(ret,0,obj);
2299         Py_XINCREF(trueSelf);
2300         return trueSelf;
2301       }
2302
2303       PyObject *__len__()
2304       {
2305         return PyInt_FromLong(self->getNumberOfCompo());
2306       }
2307   
2308       PyObject *__getitem__(PyObject *obj)
2309       {
2310         const char msg2[]="ARRAY ## Tuple::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
2311         mcIdType sw;
2312         INT singleVal;
2313         std::vector<INT> multiVal;
2314         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2315         MEDCoupling::DataArrayIdType *daIntTyypp=0;
2316         const INT *pt=self->getConstPointer();
2317         INT nbc=(INT)self->getNumberOfCompo();
2318         convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,ToIdType(nbc),sw,singleVal,multiVal,slic,daIntTyypp);
2319         switch(sw)
2320           {
2321           case 1:
2322             {
2323               if(singleVal>=(INT)nbc)
2324                 {
2325                   std::ostringstream oss;
2326                   oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
2327                   PyErr_SetString(PyExc_StopIteration,oss.str().c_str());
2328                   return 0;
2329                 }
2330               if(singleVal>=0)
2331                 return PyInt_FromLong(pt[singleVal]);
2332               else
2333                 {
2334                   if(nbc+singleVal>0)
2335                     return PyInt_FromLong(pt[nbc+singleVal]);
2336                   else
2337                     {
2338                       std::ostringstream oss;
2339                       oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
2340                       throw INTERP_KERNEL::Exception(oss.str().c_str());
2341                     }
2342                 }
2343             }
2344           case 2:
2345             {
2346               PyObject *t=PyTuple_New(multiVal.size());
2347               for(std::size_t j=0;j<multiVal.size();j++)
2348                 {
2349                   INT cid=multiVal[j];
2350                   if(cid>=(INT)nbc)
2351                     {
2352                       std::ostringstream oss;
2353                       oss << "Requesting for id #" << cid << " having only " << nbc << " components !";
2354                       throw INTERP_KERNEL::Exception(oss.str().c_str());
2355                     }
2356                   PyTuple_SetItem(t,j,PyInt_FromLong(pt[cid]));
2357                 }
2358               return t;
2359             }
2360           case 3:
2361             {
2362               mcIdType sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
2363               PyObject *t=PyTuple_New(sz);
2364               for(INT j=0;j<sz;j++)
2365                 PyTuple_SetItem(t,j,PyInt_FromLong(pt[slic.first+j*slic.second.second]));
2366               return t;
2367             }
2368           default:
2369             throw INTERP_KERNEL::Exception("ARRAY ## Tuple::__getitem__ : unrecognized type entered !");
2370           }
2371       }
2372
2373       ARRAY ## Tuple *__setitem__(PyObject *obj, PyObject *value)
2374       {
2375         const char msg[]="DataArrayIntTuple::__setitem__ : unrecognized type entered, int, slice, list<int>, tuple<int> !";
2376         const char msg2[]="DataArrayIntTuple::__setitem__ : Mismatch of slice values in 2nd parameter (components) !";
2377         mcIdType sw1,sw2;
2378         mcIdType singleValV;
2379         std::vector<mcIdType> multiValV;
2380         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slicV;
2381         MEDCoupling::ARRAY ## Tuple *daIntTyyppV=0;
2382         mcIdType nbc=ToIdType(self->getNumberOfCompo());
2383         convertObjToPossibleCpp22<INT>(value,nbc,sw1,singleValV,multiValV,slicV,daIntTyyppV);
2384         INT singleVal;
2385         std::vector<INT> multiVal;
2386         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2387         MEDCoupling::ARRAY *daIntTyypp=0;
2388         INT *pt=self->getPointer();
2389         convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
2390         switch(sw2)
2391           {
2392           case 1:
2393             {
2394               if(singleVal>=nbc)
2395                 {
2396                   std::ostringstream oss;
2397                   oss << "Requesting for setting id # " << singleVal << " having only " << nbc << " components !";
2398                   throw INTERP_KERNEL::Exception(oss.str().c_str());
2399                 }
2400               switch(sw1)
2401                 {
2402                 case 1:
2403                   {
2404                     pt[singleVal]=(INT)singleValV;
2405                     return self;
2406                   }
2407                 case 2:
2408                   {
2409                     if(multiValV.size()!=1)
2410                       {
2411                         std::ostringstream oss;
2412                         oss << "Requesting for setting id # " << singleVal << " with a list or tuple with size != 1 ! ";
2413                         throw INTERP_KERNEL::Exception(oss.str().c_str());
2414                       }
2415                     pt[singleVal]=(INT)multiValV[0];
2416                     return self;
2417                   }
2418                 case 4:
2419                   {
2420                     pt[singleVal]=daIntTyyppV->getConstPointer()[0];
2421                     return self;
2422                   }
2423                 default:
2424                   throw INTERP_KERNEL::Exception(msg);
2425                 }
2426             }
2427           case 2:
2428             {
2429               switch(sw1)
2430                 {
2431                 case 1:
2432                   {
2433                     for(std::vector<INT>::const_iterator it=multiVal.begin();it!=multiVal.end();it++)
2434                       {
2435                         if(*it>=nbc)
2436                           {
2437                             std::ostringstream oss;
2438                             oss << "Requesting for setting id # " << *it << " having only " << nbc << " components !";
2439                             throw INTERP_KERNEL::Exception(oss.str().c_str());
2440                           }
2441                         pt[*it]=(INT)singleValV;
2442                       }
2443                     return self;
2444                   }
2445                 case 2:
2446                   {
2447                     if(multiVal.size()!=multiValV.size())
2448                       {
2449                         std::ostringstream oss;
2450                         oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << multiVal.size() << " !";
2451                         throw INTERP_KERNEL::Exception(oss.str().c_str());
2452                       }
2453                     for(INT i=0;i<(INT)multiVal.size();i++)
2454                       {
2455                         INT pos=multiVal[i];
2456                         if(pos>=nbc)
2457                           {
2458                             std::ostringstream oss;
2459                             oss << "Requesting for setting id # " << pos << " having only " << nbc << " components !";
2460                             throw INTERP_KERNEL::Exception(oss.str().c_str());
2461                           }
2462                         pt[multiVal[i]]=(INT)multiValV[i];
2463                       }
2464                     return self;
2465                   }
2466                 case 4:
2467                   {
2468                     const INT *ptV=daIntTyyppV->getConstPointer();
2469                     if(nbc>(INT)daIntTyyppV->getNumberOfCompo())
2470                       {
2471                         std::ostringstream oss;
2472                         oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
2473                         throw INTERP_KERNEL::Exception(oss.str().c_str());
2474                       }
2475                     std::copy(ptV,ptV+nbc,pt);
2476                     return self;
2477                   }
2478                 default:
2479                   throw INTERP_KERNEL::Exception(msg);
2480                 }
2481             }
2482           case 3:
2483             {
2484               std::size_t sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
2485               switch(sw1)
2486                 {
2487                 case 1:
2488                   {
2489                     for(std::size_t j=0;j<sz;j++)
2490                       pt[slic.first+j*slic.second.second]=(INT)singleValV;
2491                     return self;
2492                   }
2493                 case 2:
2494                   {
2495                     if(sz!=multiValV.size())
2496                       {
2497                         std::ostringstream oss;
2498                         oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << sz << " !";
2499                         throw INTERP_KERNEL::Exception(oss.str().c_str());
2500                       }
2501                     for(std::size_t j=0;j<sz;j++)
2502                       pt[slic.first+j*slic.second.second]=(INT)multiValV[j];
2503                     return self;
2504                   }
2505                 case 4:
2506                   {
2507                     const INT *ptV=daIntTyyppV->getConstPointer();
2508                     if(sz>daIntTyyppV->getNumberOfCompo())
2509                       {
2510                         std::ostringstream oss;
2511                         oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
2512                         throw INTERP_KERNEL::Exception(oss.str().c_str());
2513                       }
2514                     for(std::size_t j=0;j<sz;j++)
2515                       pt[slic.first+j*slic.second.second]=ptV[j];
2516                     return self;
2517                   }
2518                 default:
2519                   throw INTERP_KERNEL::Exception(msg);
2520                 }
2521             }
2522           default:
2523             throw INTERP_KERNEL::Exception(msg);
2524           }
2525       }
2526     }
2527 //   };
2528 // }
2529 %enddef
2530
2531
2532 %define TRANSFORMWITHINDARR( ARRAY, INT )
2533 void transformWithIndArr(PyObject *li)
2534 {
2535   void *da=0;
2536   int res1(SWIG_ConvertPtr(li,&da,SWIGTITraits<INT>::TI, 0 |  0 ));
2537   if (!SWIG_IsOK(res1))
2538     {
2539       int res2(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__MapII, 0 |  0 ));
2540       if(SWIG_IsOK(res2))
2541         {
2542           MapII *m=reinterpret_cast<MapII *>(da);
2543           self->transformWithIndArr(*m);
2544         }
2545       else
2546         {
2547           mcIdType size;
2548           INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
2549           self->transformWithIndArr(tmp,tmp+size);
2550         }
2551     }
2552   else
2553     {
2554       ARRAY *da2=reinterpret_cast< ARRAY * >(da);
2555       self->transformWithIndArr(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
2556     }
2557 }
2558 %enddef
2559
2560 namespace MEDCoupling
2561 {
2562   typedef int      Int32;
2563 #ifdef WIN32
2564   typedef long long Int64;
2565 #else
2566   typedef long int  Int64;
2567 #endif
2568
2569   class DataArrayInt32Iterator;
2570
2571   class DataArrayInt32 : public DataArray
2572   {
2573     ARRAYDEF( DataArrayInt32, Int32 )
2574   };
2575   %extend DataArrayInt32 {
2576 #ifdef WITH_NUMPY
2577     PyObject *toNumPyArray() // not const. It is not a bug !
2578     {
2579       return ToNumPyArray<DataArrayInt32,MEDCoupling::Int32>(self,NPY_INT32,"DataArrayInt32");
2580     }
2581 #endif
2582 #ifndef MEDCOUPLING_USE_64BIT_IDS
2583     MCAuto< MapII > invertArrayN2O2O2NOptimized()
2584     {
2585       return self->invertArrayN2O2O2NOptimized();
2586     }
2587     MCAuto< MapII > giveN2OOptimized()
2588     {
2589       return self->giveN2OOptimized();
2590     }
2591     TRANSFORMWITHINDARR( DataArrayInt32, Int32 )
2592 #endif
2593   };
2594   
2595   class DataArrayInt64Iterator;
2596
2597   class DataArrayInt64 : public DataArray
2598   {
2599     ARRAYDEF( DataArrayInt64, Int64 )
2600   };
2601   %extend DataArrayInt64 {
2602 #ifdef WITH_NUMPY
2603     PyObject *toNumPyArray() // not const. It is not a bug !
2604     {
2605       return ToNumPyArray<DataArrayInt64,MEDCoupling::Int64>(self,NPY_INT64,"DataArrayInt64");
2606     }
2607 #endif
2608 #ifdef MEDCOUPLING_USE_64BIT_IDS
2609     MCAuto< MapII > invertArrayN2O2O2NOptimized()
2610     {
2611       return self->invertArrayN2O2O2NOptimized();
2612     }
2613     MCAuto< MapII > giveN2OOptimized()
2614     {
2615       return self->giveN2OOptimized();
2616     }
2617     TRANSFORMWITHINDARR( DataArrayInt64, Int64 )
2618 #endif
2619   };
2620
2621 }