1 // Copyright (C) 2007-2022 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (EDF R&D)
21 %include "MEDCouplingMemArray.i"
23 %define ARRAYDEF( ARRAY, INT )
25 // namespace MEDCoupling
27 // class ARRAY ## Iterator;
29 // class ARRAY : public DataArray -- #ifdef doesn't work inside
34 INT getHashCode() 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);
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);
52 void checkMonotonic(bool increasing) const;
53 bool isMonotonic(bool increasing) const;
54 void checkStrictlyMonotonic(bool increasing) const;
55 bool isStrictlyMonotonic(bool increasing) const;
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;
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;
87 void setIJ(mcIdType tupleId, mcIdType compoId, INT newVal);
88 void setIJSilent(mcIdType tupleId, mcIdType compoId, INT newVal);
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;
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 void sortToHaveConsecutivePairs();
147 ARRAY *duplicateEachTupleNTimes(mcIdType nbTimes) const;
148 ARRAY *getDifferentValues() const;
149 static ARRAY *Add(const ARRAY *a1, const ARRAY *a2);
150 void addEqual(const ARRAY *other);
151 static ARRAY *Substract(const ARRAY *a1, const ARRAY *a2);
152 void substractEqual(const ARRAY *other);
153 static ARRAY *Multiply(const ARRAY *a1, const ARRAY *a2);
154 void multiplyEqual(const ARRAY *other);
155 static ARRAY *Divide(const ARRAY *a1, const ARRAY *a2);
156 void divideEqual(const ARRAY *other);
157 static ARRAY *Modulus(const ARRAY *a1, const ARRAY *a2);
158 void modulusEqual(const ARRAY *other);
159 static ARRAY *Pow(const ARRAY *a1, const ARRAY *a2);
160 void powEqual(const ARRAY *other);
161 MCAuto<ARRAY> fromLinkedListOfPairToList() const;
162 MCAuto<DataArrayIdType> findIdsGreaterOrEqualTo(INT val) const;
163 MCAuto<DataArrayIdType> findIdsGreaterThan(INT val) const;
164 MCAuto<DataArrayIdType> findIdsLowerOrEqualTo(INT val) const;
165 MCAuto<DataArrayIdType> findIdsLowerThan(INT val) const;
166 MCAuto<ARRAY> selectPartDef(const PartDefinition* pd) const;
167 MCAuto<DataArrayDouble> convertToDblArr() const;
168 MCAuto<DataArrayFloat> convertToFloatArr() const;
170 static ARRAY *Range(INT begin, INT end, INT step);
178 static ARRAY *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
180 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)";
181 std::string msg(msgBase);
182 if ( MEDCouplingHasNumPyBindings() )
183 msg+="\n-ARRAY.New(numpy array with dtype=int32)";
186 if(PyList_Check(elt0) || PyTuple_Check(elt0))
190 if(PyInt_Check(nbOfTuples))
192 mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples));
194 throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive set of allocated memory !");
197 if(PyInt_Check(nbOfComp))
198 {//ARRAY.New([1,3,4,5],2,2)
199 mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp));
201 throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive number of components !");
202 MCAuto<ARRAY> ret=ARRAY::New();
203 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(elt0,nbOfTuples1,nbOfCompo);
204 ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
208 throw INTERP_KERNEL::Exception(msg.c_str());
211 {//ARRAY.New([1,3,4],3)
212 MCAuto<ARRAY> ret=ARRAY::New();
214 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(elt0,nbOfTuples1,tmpp1);
215 ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
220 throw INTERP_KERNEL::Exception(msg.c_str());
223 {// ARRAY.New([1,3,4])
224 MCAuto<ARRAY> ret=ARRAY::New();
225 mcIdType tmpp1=-1,tmpp2=-1;
226 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(elt0,tmpp1,tmpp2);
227 ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
231 else if(PyInt_Check(elt0))
233 INT nbOfTuples1=(INT)PyInt_AS_LONG(elt0);
235 throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive set of allocated memory !");
240 if(PyInt_Check(nbOfTuples))
242 INT nbOfCompo=(INT)PyInt_AS_LONG(nbOfTuples);
244 throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive number of components !");
245 MCAuto<ARRAY> ret=ARRAY::New();
246 ret->alloc(nbOfTuples1,nbOfCompo);
250 throw INTERP_KERNEL::Exception(msg.c_str());
253 throw INTERP_KERNEL::Exception(msg.c_str());
257 MCAuto<ARRAY> ret=ARRAY::New();
258 ret->alloc(nbOfTuples1,1);
262 #if defined(WITH_NUMPY)
263 else if(MEDCouplingHasNumPyBindings() && PyArray_Check(elt0) && nbOfTuples==NULL && nbOfComp==NULL)
264 {//ARRAY.New(numpyArray)
265 return BuildNewInstance<ARRAY,INT>(elt0,NPYTraits<INT>::NPYObjectType,NPYTraits<INT>::NPYFunc,MEDCoupling::Traits<INT>::NPYStr);
269 throw INTERP_KERNEL::Exception(msg.c_str());
270 throw INTERP_KERNEL::Exception(msg.c_str());//to make g++ happy
273 ARRAY(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
275 return MEDCoupling_ ## ARRAY ## _New__SWIG_1(elt0,nbOfTuples,nbOfComp);
278 std::string __str__() const
280 return self->reprNotTooLong();
283 mcIdType __len__() const
285 if(self->isAllocated())
287 return self->getNumberOfTuples();
291 throw INTERP_KERNEL::Exception("ARRAY::__len__ : Instance is NOT allocated !");
297 return self->intValue();
300 ARRAY ## Iterator *__iter__()
302 return self->iterator();
305 PyObject *accumulate() const
307 mcIdType sz=ToIdType(self->getNumberOfComponents());
308 INTERP_KERNEL::AutoPtr<INT> tmp=new INT[sz];
309 self->accumulate((INT *)tmp);
310 return convertIntArrToPyList((const INT *)tmp,sz);
313 ARRAY *accumulatePerChunck(PyObject *indexArr) const
316 std::vector<mcIdType> val2;
317 const mcIdType *bg=convertIntStarLikePyObjToCppIntStar(indexArr,sw,sz,val,val2);
318 return self->accumulatePerChunck(bg,bg+sz);
321 DataArrayIdType *findIdsEqualTuple(PyObject *inputTuple) const
325 std::vector<INT> val2;
326 const INT *bg(convertIntStarLikePyObjToCppIntStar(inputTuple,sw,sz,val,val2));
327 return self->findIdsEqualTuple(bg,bg+sz);
330 DataArrayIdType *findIdForEach(PyObject *vals) const
334 std::vector<INT> val2;
335 const INT *bg(convertIntStarLikePyObjToCppIntStar(vals,sw,sz,val,val2));
336 MCAuto<DataArrayIdType> ret(self->findIdForEach(bg,bg+sz));
340 PyObject *splitInBalancedSlices(mcIdType nbOfSlices) const
342 std::vector< std::pair<mcIdType,mcIdType> > slcs(self->splitInBalancedSlices(nbOfSlices));
343 PyObject *ret=PyList_New(slcs.size());
344 for(std::size_t i=0;i<slcs.size();i++)
345 PyList_SetItem(ret,i,PySlice_New(PyInt_FromLong(slcs[i].first),PyInt_FromLong(slcs[i].second),PyInt_FromLong(1)));
349 ARRAY *buildExplicitArrOfSliceOnScaledArr(PyObject *slic) const
351 if(!PySlice_Check(slic))
352 throw INTERP_KERNEL::Exception("ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : expecting a pyslice as second (first) parameter !");
353 Py_ssize_t strt=2,stp=2,step=2;
354 GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !");
355 if(strt==std::numeric_limits<INT>::max() || stp==std::numeric_limits<INT>::max())
356 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 !");
357 return self->buildExplicitArrOfSliceOnScaledArr((INT)strt,(INT)stp,(INT)step);
360 PyObject *getMinMaxValues() const
363 self->getMinMaxValues(a,b);
364 PyObject *ret=PyTuple_New(2);
365 PyTuple_SetItem(ret,0,PyInt_FromLong(a));
366 PyTuple_SetItem(ret,1,PyInt_FromLong(b));
370 static PyObject *ConvertIndexArrayToO2N(mcIdType nbOfOldTuples, PyObject *arr, PyObject *arrI)
372 mcIdType newNbOfTuples=-1;
373 mcIdType szArr,szArrI,sw,iTypppArr,iTypppArrI;
374 std::vector<mcIdType> stdvecTyyppArr;
375 std::vector<mcIdType> stdvecTyyppArrI;
376 const mcIdType *arrPtr=convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr);
377 const mcIdType *arrIPtr=convertIntStarLikePyObjToCppIntStar(arrI,sw,szArrI,iTypppArrI,stdvecTyyppArrI);
378 DataArrayIdType *ret0=MEDCoupling::ARRAY::ConvertIndexArrayToO2N(nbOfOldTuples,arrPtr,arrIPtr,arrIPtr+szArrI,newNbOfTuples);
379 PyObject *ret=PyTuple_New(2);
380 PyTuple_SetItem(ret,0,SWIG_NewPointerObj((void*)ret0,SWIGTITraits<mcIdType>::TI,SWIG_POINTER_OWN | 0));
381 PyTuple_SetItem(ret,1,PyInt_FromLong(newNbOfTuples));
385 static DataArrayIdType *CheckAndPreparePermutation(PyObject *arr)
387 MCAuto<DataArrayIdType> ret(DataArrayIdType::New());
390 std::vector<INT> stdvecTyyppArr;
391 const INT *arrPtr(convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr));
392 mcIdType *pt(MEDCoupling::ARRAY::CheckAndPreparePermutation(arrPtr,arrPtr+szArr));
393 ret->useArray(pt,true,MEDCoupling::DeallocType::C_DEALLOC,szArr,1);
397 void setValues(PyObject *li, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
399 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 !";
400 if(PyList_Check(li) || PyTuple_Check(li))
402 if(nbOfTuples && nbOfTuples != Py_None)
404 if(PyInt_Check(nbOfTuples))
406 mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples));
408 throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive set of allocated memory !");
409 if(nbOfComp && nbOfComp != Py_None)
411 if(PyInt_Check(nbOfComp))
412 {//ARRAY.setValues([1,3,4,5],2,2)
413 mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp));
415 throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive number of components !");
416 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,nbOfTuples1,nbOfCompo);
417 self->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),self->getPointer());
420 throw INTERP_KERNEL::Exception(msg);
423 {//ARRAY.setValues([1,3,4],3)
425 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,nbOfTuples1,tmpp1);
426 self->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),self->getPointer());
430 throw INTERP_KERNEL::Exception(msg);
433 {// ARRAY.setValues([1,3,4])
434 mcIdType tmpp1=-1,tmpp2=-1;
435 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,tmpp1,tmpp2);
436 self->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),self->getPointer());
440 throw INTERP_KERNEL::Exception(msg);
443 PyObject *getValues() const
445 const INT *vals=self->getConstPointer();
446 return convertIntArrToPyList(vals,self->getNbOfElems());
449 PyObject *isEqualIfNotWhy(const ARRAY& other) const
452 bool ret0=self->isEqualIfNotWhy(other,ret1);
453 PyObject *ret=PyTuple_New(2);
454 PyObject *ret0Py=ret0?Py_True:Py_False;
456 PyTuple_SetItem(ret,0,ret0Py);
457 PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str()));
461 PyObject *getValuesAsTuple() const
463 const INT *vals=self->getConstPointer();
464 mcIdType nbOfComp=ToIdType(self->getNumberOfComponents());
465 mcIdType nbOfTuples=self->getNumberOfTuples();
466 return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
469 static PyObject *MakePartition(PyObject *gps, mcIdType newNb)
471 std::vector<const ARRAY *> groups;
472 std::vector< std::vector<mcIdType> > fidsOfGroups;
473 convertFromPyObjVectorOfObj(gps,SWIGTITraits<INT>::TI,"ARRAY",groups);
474 DataArrayIdType *ret0=MEDCoupling::ARRAY::MakePartition(groups,newNb,fidsOfGroups);
475 PyObject *ret = PyList_New(2);
476 PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
477 std::size_t sz=fidsOfGroups.size();
478 PyObject *ret1 = PyList_New(sz);
479 for(std::size_t i=0;i<sz;i++)
480 PyList_SetItem(ret1,i,convertIntArrToPyList2(fidsOfGroups[i]));
481 PyList_SetItem(ret,1,ret1);
485 DataArrayIdType *findIdsEqualList(PyObject *obj)
489 std::vector<INT> multiVal;
490 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
492 convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
496 return self->findIdsEqualList(&singleVal,&singleVal+1);
498 return self->findIdsEqualList(&multiVal[0],&multiVal[0]+multiVal.size());
500 return self->findIdsEqualList(daIntTyypp->begin(),daIntTyypp->end());
502 throw INTERP_KERNEL::Exception("ARRAY::findIdsEqualList : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
506 DataArrayIdType *findIdsNotEqualList(PyObject *obj)
510 std::vector<INT> multiVal;
511 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
513 convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
517 return self->findIdsNotEqualList(&singleVal,&singleVal+1);
519 return self->findIdsNotEqualList(&multiVal[0],&multiVal[0]+multiVal.size());
521 return self->findIdsNotEqualList(daIntTyypp->begin(),daIntTyypp->end());
523 throw INTERP_KERNEL::Exception("ARRAY::findIdsNotEqualList : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
527 PyObject *splitByValueRange(PyObject *li) const
529 ARRAY *ret0=0,*ret1=0,*ret2=0;
531 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<INT>::TI, 0 | 0 );
532 if (!SWIG_IsOK(res1))
535 INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
536 self->splitByValueRange(tmp,(INT *)tmp+size,ret0,ret1,ret2);
540 ARRAY *da2=reinterpret_cast< ARRAY * >(da);
542 throw INTERP_KERNEL::Exception("Not null ARRAY instance expected !");
543 da2->checkAllocated();
544 self->splitByValueRange(da2->begin(),da2->end(),ret0,ret1,ret2);
546 PyObject *ret = PyList_New(3);
547 PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
548 PyList_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
549 PyList_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(ret2),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
553 DataArrayIdType *transformWithIndArrR(PyObject *li) const
556 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<INT>::TI, 0 | 0 );
557 if (!SWIG_IsOK(res1))
560 INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
561 return self->transformWithIndArrR(tmp,tmp+size);
565 ARRAY *da2=reinterpret_cast< ARRAY * >(da);
566 return self->transformWithIndArrR(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
570 ARRAY *renumberAndReduce(PyObject *li, mcIdType newNbOfTuple)
573 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 | 0 );
574 if (!SWIG_IsOK(res1))
577 INTERP_KERNEL::AutoPtr<mcIdType> tmp=convertPyToNewIntArr2(li,&size);
578 if(size!=self->getNumberOfTuples())
580 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
582 return self->renumberAndReduce(tmp,newNbOfTuple);
586 DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da);
588 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
589 da2->checkAllocated();
590 mcIdType size=self->getNumberOfTuples();
591 if(size!=self->getNumberOfTuples())
593 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
595 return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple);
599 ARRAY *renumber(PyObject *li)
602 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 | 0 );
603 if (!SWIG_IsOK(res1))
606 INTERP_KERNEL::AutoPtr<mcIdType> tmp=convertPyToNewIntArr2(li,&size);
607 if(size!=self->getNumberOfTuples())
609 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
611 return self->renumber(tmp);
615 DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da);
617 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
618 da2->checkAllocated();
619 mcIdType size=self->getNumberOfTuples();
620 if(size!=self->getNumberOfTuples())
622 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
624 return self->renumber(da2->getConstPointer());
628 ARRAY *renumberR(PyObject *li)
631 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 | 0 );
632 if (!SWIG_IsOK(res1))
635 INTERP_KERNEL::AutoPtr<mcIdType> tmp=convertPyToNewIntArr2(li,&size);
636 if(size!=self->getNumberOfTuples())
638 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
640 return self->renumberR(tmp);
644 DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da);
646 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
647 da2->checkAllocated();
648 mcIdType size=self->getNumberOfTuples();
649 if(size!=self->getNumberOfTuples())
651 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
653 return self->renumberR(da2->getConstPointer());
657 void setSelectedComponents(const ARRAY *a, PyObject *li)
659 std::vector<std::size_t> tmp;
660 convertPyToNewIntArr3(li,tmp);
661 self->setSelectedComponents(a,tmp);
664 PyObject *explodeComponents() const
666 std::vector< MCAuto<ARRAY> > retCpp(self->explodeComponents());
667 std::size_t sz(retCpp.size());
668 PyObject *res(PyList_New(sz));
669 for(std::size_t i=0;i<sz;i++)
670 PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(retCpp[i].retn()),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
674 PyObject *getTuple(mcIdType tupleId)
676 mcIdType sz=ToIdType(self->getNumberOfComponents());
677 INTERP_KERNEL::AutoPtr<INT> tmp=new INT[sz];
678 self->getTuple(tupleId,tmp);
679 return convertIntArrToPyList((const INT*)tmp,sz);
682 PyObject *changeSurjectiveFormat(INT targetNb) const
684 DataArrayIdType *arr=0;
685 DataArrayIdType *arrI=0;
686 self->changeSurjectiveFormat(targetNb,arr,arrI);
687 PyObject *res = PyList_New(2);
688 PyList_SetItem(res,0,SWIG_NewPointerObj((void*)arr,SWIGTITraits<mcIdType>::TI,SWIG_POINTER_OWN | 0));
689 PyList_SetItem(res,1,SWIG_NewPointerObj((void*)arrI,SWIGTITraits<mcIdType>::TI,SWIG_POINTER_OWN | 0));
693 static ARRAY *Meld(PyObject *li)
695 std::vector<const ARRAY *> tmp;
696 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
697 return ARRAY::Meld(tmp);
700 static ARRAY *Aggregate(PyObject *li)
702 std::vector<const ARRAY *> tmp;
703 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
704 return ARRAY::Aggregate(tmp);
707 static ARRAY *AggregateIndexes(PyObject *li)
709 std::vector<const ARRAY *> tmp;
710 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
711 return ARRAY::AggregateIndexes(tmp);
714 static ARRAY *BuildUnion(PyObject *li)
716 std::vector<const ARRAY *> tmp;
717 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
718 return ARRAY::BuildUnion(tmp);
721 static ARRAY *BuildIntersection(PyObject *li)
723 std::vector<const ARRAY *> tmp;
724 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
725 return ARRAY::BuildIntersection(tmp);
728 PyObject *getMaxValue() const
731 INT r1=self->getMaxValue(tmp);
732 PyObject *ret=PyTuple_New(2);
733 PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
734 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
738 PyObject *getMaxAbsValue(std::size_t& tupleId) const
741 INT r1=self->getMaxAbsValue(tmp);
742 PyObject *ret=PyTuple_New(2);
743 PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
744 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
748 PyObject *getMinValue() const
751 INT r1=self->getMinValue(tmp);
752 PyObject *ret=PyTuple_New(2);
753 PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
754 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
758 mcIdType index(PyObject *obj) const
760 std::size_t nbOfCompo=self->getNumberOfComponents();
767 INT val=(INT)PyInt_AS_LONG(obj);
768 return self->findIdFirstEqual(val);
771 throw INTERP_KERNEL::Exception("ARRAY::index : 'this' contains one component and trying to find an element which is not an integer !");
775 std::vector<INT> arr;
776 convertPyToNewIntArr3(obj,arr);
777 return self->findIdFirstEqualTuple(arr);
782 bool __contains__(PyObject *obj) const
784 std::size_t nbOfCompo=self->getNumberOfComponents();
793 INT val=(INT)PyInt_AS_LONG(obj);
794 return self->presenceOfValue(val);
797 throw INTERP_KERNEL::Exception("ARRAY::__contains__ : 'this' contains one component and trying to find an element which is not an integer !");
801 std::vector<INT> arr;
802 convertPyToNewIntArr3(obj,arr);
803 return self->presenceOfTuple(arr);
808 PyObject *__getitem__(PyObject *obj)
810 const char msg[]="Unexpected situation in ARRAY::__getitem__ !";
811 const char msg2[]="ARRAY::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
812 self->checkAllocated();
813 mcIdType nbOfTuples=self->getNumberOfTuples();
814 std::size_t nbOfComponents=self->getNumberOfComponents();
817 std::vector<mcIdType> vt1;
818 std::vector<std::size_t> vc1;
819 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > pt1,pc1;
820 DataArrayIdType *dt1=0,*dc1=0;
822 convertObjToPossibleCpp3(obj,nbOfTuples,(int)nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
828 if(nbOfComponents==1)
829 return PyInt_FromLong(self->getIJSafe(it1,0));
830 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&it1,&it1+1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
833 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size())),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
835 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
837 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems())),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
839 return PyInt_FromLong(self->getIJSafe(it1,ic1));
842 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
843 std::vector<std::size_t> v2(1,ic1);
844 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
848 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
849 std::vector<std::size_t> v2(1,ic1);
850 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
854 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
855 std::vector<std::size_t> v2(1,ic1);
856 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
860 ret=self->selectByTupleIdSafe(&it1,&it1+1);
861 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
865 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
866 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
870 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
871 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
875 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
876 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
880 ret=self->selectByTupleIdSafe(&it1,&it1+1);
881 mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
882 std::vector<std::size_t> v2(nbOfComp);
883 for(INT i=0;i<nbOfComp;i++)
884 v2[i]=pc1.first+i*pc1.second.second;
885 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
889 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
890 mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
891 std::vector<std::size_t> v2(nbOfComp);
892 for(INT i=0;i<nbOfComp;i++)
893 v2[i]=pc1.first+i*pc1.second.second;
894 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
898 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
899 mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
900 std::vector<std::size_t> v2(nbOfComp);
901 for(mcIdType i=0;i<nbOfComp;i++)
902 v2[i]=pc1.first+i*pc1.second.second;
903 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
907 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
908 mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
909 std::vector<std::size_t> v2(nbOfComp);
910 for(INT i=0;i<nbOfComp;i++)
911 v2[i]=pc1.first+i*pc1.second.second;
912 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
915 throw INTERP_KERNEL::Exception(msg);
919 ARRAY *__setitem__(PyObject *obj, PyObject *value)
921 self->checkAllocated();
922 const char msg[]="Unexpected situation in __setitem__ !";
923 mcIdType nbOfTuples=self->getNumberOfTuples();
924 int nbOfComponents=(int)self->getNumberOfComponents();
929 ARRAY ## Tuple *dd1=0;
930 convertIntStarLikePyObjToCpp(value,sw1,i1,v1,d1,dd1);
932 std::vector<mcIdType> vt1,vc1;
933 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > pt1,pc1;
934 DataArrayIdType *dt1=0,*dc1=0;
935 convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
944 self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
948 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
949 self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
952 self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1);
955 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
956 self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1);
959 throw INTERP_KERNEL::Exception(msg);
968 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
972 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
973 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
976 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
979 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
980 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
983 throw INTERP_KERNEL::Exception(msg);
992 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
996 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
997 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
1000 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
1003 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1004 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
1007 throw INTERP_KERNEL::Exception(msg);
1016 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
1020 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1021 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
1024 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
1027 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1028 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
1031 throw INTERP_KERNEL::Exception(msg);
1040 self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
1044 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1045 self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
1048 self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1);
1051 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1052 self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1);
1055 throw INTERP_KERNEL::Exception(msg);
1064 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
1068 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1069 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
1072 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
1075 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1076 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
1079 throw INTERP_KERNEL::Exception(msg);
1088 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
1092 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1093 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
1096 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
1099 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1100 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
1103 throw INTERP_KERNEL::Exception(msg);
1112 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
1116 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1117 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
1120 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
1123 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1124 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
1127 throw INTERP_KERNEL::Exception(msg);
1136 self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
1140 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1141 self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
1144 self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
1147 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1148 self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
1151 throw INTERP_KERNEL::Exception(msg);
1160 self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
1164 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1165 self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
1168 self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
1171 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1172 self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
1175 throw INTERP_KERNEL::Exception(msg);
1184 self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
1188 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1189 self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size(),false);
1192 self->setPartOfValues4(d1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
1195 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1196 self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
1199 throw INTERP_KERNEL::Exception(msg);
1208 self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
1212 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1213 self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
1216 self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
1219 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1220 self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
1223 throw INTERP_KERNEL::Exception(msg);
1232 self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
1236 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1237 self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
1240 self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
1243 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1244 self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
1247 throw INTERP_KERNEL::Exception(msg);
1256 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
1260 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1261 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false);
1264 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
1267 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1268 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
1271 throw INTERP_KERNEL::Exception(msg);
1280 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
1284 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1285 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false);
1288 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
1291 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1292 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
1295 throw INTERP_KERNEL::Exception(msg);
1304 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
1308 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1309 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false);
1312 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
1315 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1316 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
1319 throw INTERP_KERNEL::Exception(msg);
1324 throw INTERP_KERNEL::Exception(msg);
1329 ARRAY *__neg__() const
1331 return self->negate();
1334 ARRAY *__add__(PyObject *obj)
1336 const char msg[]="Unexpected situation in __add__ !";
1339 std::vector<INT> aa;
1340 ARRAY ## Tuple *aaa;
1342 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1347 MCAuto<ARRAY> ret=self->deepCopy();
1348 ret->applyLin(1,val);
1353 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1354 return ARRAY::Add(self,aaaa);
1358 return ARRAY::Add(self,a);
1362 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1363 return ARRAY::Add(self,aaaa);
1366 throw INTERP_KERNEL::Exception(msg);
1370 ARRAY *__radd__(PyObject *obj)
1372 const char msg[]="Unexpected situation in __radd__ !";
1375 std::vector<INT> aa;
1376 ARRAY ## Tuple *aaa;
1378 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1383 MCAuto<ARRAY> ret=self->deepCopy();
1384 ret->applyLin(1,val);
1389 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1390 return ARRAY::Add(self,aaaa);
1394 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1395 return ARRAY::Add(self,aaaa);
1398 throw INTERP_KERNEL::Exception(msg);
1402 PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
1404 const char msg[]="Unexpected situation in __iadd__ !";
1407 std::vector<INT> aa;
1408 ARRAY ## Tuple *aaa;
1410 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1415 self->applyLin(1,val);
1416 Py_XINCREF(trueSelf);
1421 MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1423 Py_XINCREF(trueSelf);
1429 Py_XINCREF(trueSelf);
1434 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1435 self->addEqual(aaaa);
1436 Py_XINCREF(trueSelf);
1440 throw INTERP_KERNEL::Exception(msg);
1444 ARRAY *__sub__(PyObject *obj)
1446 const char msg[]="Unexpected situation in __sub__ !";
1449 std::vector<INT> aa;
1450 ARRAY ## Tuple *aaa;
1452 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1457 MCAuto<ARRAY> ret=self->deepCopy();
1458 ret->applyLin(1,-val);
1463 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1464 return ARRAY::Substract(self,aaaa);
1468 return ARRAY::Substract(self,a);
1472 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1473 return ARRAY::Substract(self,aaaa);
1476 throw INTERP_KERNEL::Exception(msg);
1480 ARRAY *__rsub__(PyObject *obj)
1482 const char msg[]="Unexpected situation in __rsub__ !";
1485 std::vector<INT> aa;
1486 ARRAY ## Tuple *aaa;
1488 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1493 MCAuto<ARRAY> ret=self->deepCopy();
1494 ret->applyLin(-1,val);
1499 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1500 return ARRAY::Substract(aaaa,self);
1504 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1505 return ARRAY::Substract(aaaa,self);
1508 throw INTERP_KERNEL::Exception(msg);
1512 PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
1514 const char msg[]="Unexpected situation in __isub__ !";
1517 std::vector<INT> aa;
1518 ARRAY ## Tuple *aaa;
1520 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1525 self->applyLin(1,-val);
1526 Py_XINCREF(trueSelf);
1531 MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1532 self->substractEqual(bb);
1533 Py_XINCREF(trueSelf);
1538 self->substractEqual(a);
1539 Py_XINCREF(trueSelf);
1544 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1545 self->substractEqual(aaaa);
1546 Py_XINCREF(trueSelf);
1550 throw INTERP_KERNEL::Exception(msg);
1554 ARRAY *__mul__(PyObject *obj)
1556 const char msg[]="Unexpected situation in __mul__ !";
1559 std::vector<INT> aa;
1560 ARRAY ## Tuple *aaa;
1562 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1567 MCAuto<ARRAY> ret=self->deepCopy();
1568 ret->applyLin(val,0);
1573 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1574 return ARRAY::Multiply(self,aaaa);
1578 return ARRAY::Multiply(self,a);
1582 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1583 return ARRAY::Multiply(self,aaaa);
1586 throw INTERP_KERNEL::Exception(msg);
1590 ARRAY *__rmul__(PyObject *obj)
1592 const char msg[]="Unexpected situation in __rmul__ !";
1595 std::vector<INT> aa;
1596 ARRAY ## Tuple *aaa;
1598 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1603 MCAuto<ARRAY> ret=self->deepCopy();
1604 ret->applyLin(val,0);
1609 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1610 return ARRAY::Multiply(self,aaaa);
1614 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1615 return ARRAY::Multiply(self,aaaa);
1618 throw INTERP_KERNEL::Exception(msg);
1622 PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
1624 const char msg[]="Unexpected situation in __imul__ !";
1627 std::vector<INT> aa;
1628 ARRAY ## Tuple *aaa;
1630 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1635 self->applyLin(val,0);
1636 Py_XINCREF(trueSelf);
1641 MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1642 self->multiplyEqual(bb);
1643 Py_XINCREF(trueSelf);
1648 self->multiplyEqual(a);
1649 Py_XINCREF(trueSelf);
1654 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1655 self->multiplyEqual(aaaa);
1656 Py_XINCREF(trueSelf);
1660 throw INTERP_KERNEL::Exception(msg);
1664 ARRAY *__div__(PyObject *obj)
1666 const char msg[]="Unexpected situation in __div__ !";
1669 std::vector<INT> aa;
1670 ARRAY ## Tuple *aaa;
1672 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1677 MCAuto<ARRAY> ret=self->deepCopy();
1678 ret->applyDivideBy(val);
1683 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1684 return ARRAY::Divide(self,aaaa);
1688 return ARRAY::Divide(self,a);
1692 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1693 return ARRAY::Divide(self,aaaa);
1696 throw INTERP_KERNEL::Exception(msg);
1700 ARRAY *__rdiv__(PyObject *obj)
1702 const char msg[]="Unexpected situation in __rdiv__ !";
1705 std::vector<INT> aa;
1706 ARRAY ## Tuple *aaa;
1708 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1713 MCAuto<ARRAY> ret=self->deepCopy();
1719 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1720 return ARRAY::Divide(aaaa,self);
1724 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1725 return ARRAY::Divide(aaaa,self);
1728 throw INTERP_KERNEL::Exception(msg);
1732 PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
1734 const char msg[]="Unexpected situation in __idiv__ !";
1737 std::vector<INT> aa;
1738 ARRAY ## Tuple *aaa;
1740 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1745 self->applyDivideBy(val);
1746 Py_XINCREF(trueSelf);
1751 MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1752 self->divideEqual(bb);
1753 Py_XINCREF(trueSelf);
1758 self->divideEqual(a);
1759 Py_XINCREF(trueSelf);
1764 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1765 self->divideEqual(aaaa);
1766 Py_XINCREF(trueSelf);
1770 throw INTERP_KERNEL::Exception(msg);
1774 ARRAY *__mod__(PyObject *obj)
1776 const char msg[]="Unexpected situation in __mod__ !";
1779 std::vector<INT> aa;
1780 ARRAY ## Tuple *aaa;
1782 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1787 MCAuto<ARRAY> ret=self->deepCopy();
1788 ret->applyModulus(val);
1793 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1794 return ARRAY::Modulus(self,aaaa);
1798 return ARRAY::Modulus(self,a);
1802 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1803 return ARRAY::Modulus(self,aaaa);
1806 throw INTERP_KERNEL::Exception(msg);
1810 ARRAY *__rmod__(PyObject *obj)
1812 const char msg[]="Unexpected situation in __rmod__ !";
1815 std::vector<INT> aa;
1816 ARRAY ## Tuple *aaa;
1818 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1823 MCAuto<ARRAY> ret=self->deepCopy();
1824 ret->applyRModulus(val);
1829 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1830 return ARRAY::Modulus(aaaa,self);
1834 return ARRAY::Modulus(a,self);
1838 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1839 return ARRAY::Modulus(aaaa,self);
1842 throw INTERP_KERNEL::Exception(msg);
1846 PyObject *___imod___(PyObject *trueSelf, PyObject *obj)
1848 const char msg[]="Unexpected situation in __imod__ !";
1851 std::vector<INT> aa;
1852 ARRAY ## Tuple *aaa;
1854 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1859 self->applyModulus(val);
1860 Py_XINCREF(trueSelf);
1865 self->modulusEqual(a);
1866 Py_XINCREF(trueSelf);
1871 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1872 self->modulusEqual(aaaa);
1873 Py_XINCREF(trueSelf);
1877 throw INTERP_KERNEL::Exception(msg);
1881 ARRAY *__pow__(PyObject *obj)
1883 const char msg[]="Unexpected situation in __pow__ !";
1886 std::vector<INT> aa;
1887 ARRAY ## Tuple *aaa;
1889 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1894 MCAuto<ARRAY> ret=self->deepCopy();
1900 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1901 return ARRAY::Pow(self,aaaa);
1905 return ARRAY::Pow(self,a);
1909 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1910 return ARRAY::Pow(self,aaaa);
1913 throw INTERP_KERNEL::Exception(msg);
1917 ARRAY *__rpow__(PyObject *obj)
1919 const char msg[]="Unexpected situation in __rpow__ !";
1922 std::vector<INT> aa;
1923 ARRAY ## Tuple *aaa;
1925 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1930 MCAuto<ARRAY> ret=self->deepCopy();
1931 ret->applyRPow(val);
1936 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1937 return ARRAY::Pow(aaaa,self);
1941 return ARRAY::Pow(a,self);
1945 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1946 return ARRAY::Pow(aaaa,self);
1949 throw INTERP_KERNEL::Exception(msg);
1953 PyObject *___ipow___(PyObject *trueSelf, PyObject *obj)
1955 const char msg[]="Unexpected situation in __ipow__ !";
1958 std::vector<INT> aa;
1959 ARRAY ## Tuple *aaa;
1961 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1966 self->applyPow(val);
1967 Py_XINCREF(trueSelf);
1973 Py_XINCREF(trueSelf);
1978 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1979 self->powEqual(aaaa);
1980 Py_XINCREF(trueSelf);
1984 throw INTERP_KERNEL::Exception(msg);
1988 std::string __repr__() const
1990 std::ostringstream oss;
1991 self->reprQuickOverview(oss);
1995 void pushBackValsSilent(PyObject *li)
1999 std::vector<INT> stdvecTyyppArr;
2000 const INT *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr);
2001 self->pushBackValsSilent(tmp,tmp+szArr);
2004 PyObject *partitionByDifferentValues() const
2006 std::vector<INT> ret1;
2007 std::vector<DataArrayIdType *> ret0=self->partitionByDifferentValues(ret1);
2008 std::size_t sz=ret0.size();
2009 PyObject *pyRet=PyTuple_New(2);
2010 PyObject *pyRet0=PyList_New((INT)sz);
2011 PyObject *pyRet1=PyList_New((INT)sz);
2012 for(std::size_t i=0;i<sz;i++)
2014 PyList_SetItem(pyRet0,i,SWIG_NewPointerObj(SWIG_as_voidptr(ret0[i]),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2015 PyList_SetItem(pyRet1,i,PyInt_FromLong(ret1[i]));
2017 PyTuple_SetItem(pyRet,0,pyRet0);
2018 PyTuple_SetItem(pyRet,1,pyRet1);
2022 DataArrayIdType *locateComponentId(const ARRAY *valToSearchIntoTuples, const DataArrayIdType *tupleIdHint) const
2024 return self->locateComponentId(valToSearchIntoTuples,tupleIdHint);
2027 PyObject *findIdsRangesInListOfIds(const ARRAY *listOfIds) const
2029 DataArrayIdType *ret0=0;
2031 self->findIdsRangesInListOfIds(listOfIds,ret0,ret1);
2032 PyObject *pyRet=PyTuple_New(2);
2033 PyTuple_SetItem(pyRet,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2034 PyTuple_SetItem(pyRet,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
2038 PyObject *isRange() const
2041 bool ret(self->isRange(a,b,c));
2042 PyObject *pyRet=PyTuple_New(2);
2043 PyObject *ret0Py=ret?Py_True:Py_False,*ret1Py(0);
2045 PyTuple_SetItem(pyRet,0,ret0Py);
2047 ret1Py=PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(c));
2053 PyTuple_SetItem(pyRet,1,ret1Py);
2057 static bool RemoveIdsFromIndexedArrays(PyObject *li, ARRAY *arr, DataArrayIdType *arrIndx, mcIdType offsetForRemoval=0) throw(INTERP_KERNEL::Exception)
2061 std::vector<INT> multiVal;
2062 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2063 MEDCoupling::ARRAY *daIntTyypp=0;
2065 throw INTERP_KERNEL::Exception("ARRAY::RemoveIdsFromIndexedArrays : null pointer as arrIndex !");
2066 convertIntStarOrSliceLikePyObjToCpp(li,arrIndx->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2070 return ARRAY::RemoveIdsFromIndexedArrays(&singleVal,&singleVal+1,arr,arrIndx,offsetForRemoval);
2072 return ARRAY::RemoveIdsFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arr,arrIndx,offsetForRemoval);
2074 return ARRAY::RemoveIdsFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arr,arrIndx,offsetForRemoval);
2076 throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2080 static PyObject *ExtractFromIndexedArrays(PyObject *li, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
2083 DataArrayIdType *arrIndexOut=0;
2086 std::vector<mcIdType> multiVal;
2087 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2088 MEDCoupling::DataArrayIdType *daIntTyypp=0;
2090 throw INTERP_KERNEL::Exception("ARRAY::ExtractFromIndexedArrays : null pointer as arrIndxIn !");
2091 convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2096 ARRAY::ExtractFromIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,arrOut,arrIndexOut);
2101 ARRAY::ExtractFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,arrOut,arrIndexOut);
2106 ARRAY::ExtractFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,arrOut,arrIndexOut);
2110 throw INTERP_KERNEL::Exception("ARRAY::ExtractFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2112 PyObject *ret=PyTuple_New(2);
2113 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2114 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2118 static PyObject *ExtractFromIndexedArraysSlice(mcIdType strt, mcIdType stp, mcIdType step, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
2121 DataArrayIdType *arrIndexOut=0;
2122 ARRAY::ExtractFromIndexedArraysSlice(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut);
2123 PyObject *ret=PyTuple_New(2);
2124 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2125 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2129 static PyObject *ExtractFromIndexedArraysSlice(PyObject *slic, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
2131 if(!PySlice_Check(slic))
2132 throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : the first param is not a pyslice !");
2133 Py_ssize_t strt=2,stp=2,step=2;
2135 throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : last array is null !");
2136 arrIndxIn->checkAllocated();
2137 if(arrIndxIn->getNumberOfComponents()!=1)
2138 throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : number of components of last argument must be equal to one !");
2139 GetIndicesOfSlice(slic,arrIndxIn->getNumberOfTuples(),&strt,&stp,&step,"ExtractFromIndexedArraysSlice (wrap) : Invalid slice regarding nb of elements !");
2141 DataArrayIdType *arrIndexOut=0;
2142 ARRAY::ExtractFromIndexedArraysSlice(ToIdType(strt),ToIdType(stp),ToIdType(step),arrIn,arrIndxIn,arrOut,arrIndexOut);
2143 PyObject *ret=PyTuple_New(2);
2144 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2145 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2149 static PyObject *SetPartOfIndexedArrays(PyObject *li,
2150 const ARRAY *arrIn, const DataArrayIdType *arrIndxIn,
2151 const ARRAY *srcArr, const DataArrayIdType *srcArrIndex) throw(INTERP_KERNEL::Exception)
2154 DataArrayIdType *arrIndexOut=0;
2157 std::vector<mcIdType> multiVal;
2158 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2159 MEDCoupling::DataArrayIdType *daIntTyypp=0;
2161 throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArrays : null pointer as arrIndex !");
2162 convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2167 ARRAY::SetPartOfIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
2172 ARRAY::SetPartOfIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
2177 ARRAY::SetPartOfIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
2181 throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2183 PyObject *ret=PyTuple_New(2);
2184 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2185 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2189 static void SetPartOfIndexedArraysSameIdx(PyObject *li, ARRAY *arrIn, const DataArrayIdType *arrIndxIn,
2190 const ARRAY *srcArr, const DataArrayIdType *srcArrIndex) throw(INTERP_KERNEL::Exception)
2194 std::vector<mcIdType> multiVal;
2195 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2196 MEDCoupling::DataArrayIdType *daIntTyypp=0;
2198 throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArraysSameIdx : null pointer as arrIndex !");
2199 convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2204 ARRAY::SetPartOfIndexedArraysSameIdx(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex);
2209 ARRAY::SetPartOfIndexedArraysSameIdx(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex);
2214 ARRAY::SetPartOfIndexedArraysSameIdx(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex);
2218 throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArraysSameIdx : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2225 class ARRAY ## Tuple;
2227 class ARRAY ## Iterator
2230 ARRAY ## Iterator(ARRAY *da);
2231 ~ARRAY ## Iterator();
2236 ARRAY ## Tuple *ret=self->nextt();
2238 return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_MEDCoupling__ ## ARRAY ## Tuple,SWIG_POINTER_OWN | 0);
2241 PyErr_SetString(PyExc_StopIteration,"No more data.");
2248 class ARRAY ## Tuple
2251 std::size_t getNumberOfCompo() const;
2252 ARRAY *buildDAInt(INT nbOfTuples, INT nbOfCompo) const;
2255 std::string __str__() const
2257 return self->repr();
2262 return self->intValue();
2267 return self->buildDAInt(1,self->getNumberOfCompo());
2270 PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
2272 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2273 MEDCoupling_ ## ARRAY ## ____iadd___(ret,0,obj);
2274 Py_XINCREF(trueSelf);
2278 PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
2280 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2281 MEDCoupling_ ## ARRAY ## ____isub___(ret,0,obj);
2282 Py_XINCREF(trueSelf);
2286 PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
2288 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2289 MEDCoupling_ ## ARRAY ## ____imul___(ret,0,obj);
2290 Py_XINCREF(trueSelf);
2293 PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
2295 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2296 MEDCoupling_ ## ARRAY ## ____idiv___(ret,0,obj);
2297 Py_XINCREF(trueSelf);
2301 PyObject *___imod___(PyObject *trueSelf, PyObject *obj)
2303 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2304 MEDCoupling_ ## ARRAY ## ____imod___(ret,0,obj);
2305 Py_XINCREF(trueSelf);
2311 return PyInt_FromLong(self->getNumberOfCompo());
2314 PyObject *__getitem__(PyObject *obj)
2316 const char msg2[]="ARRAY ## Tuple::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
2319 std::vector<INT> multiVal;
2320 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2321 MEDCoupling::DataArrayIdType *daIntTyypp=0;
2322 const INT *pt=self->getConstPointer();
2323 INT nbc=(INT)self->getNumberOfCompo();
2324 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,ToIdType(nbc),sw,singleVal,multiVal,slic,daIntTyypp);
2329 if(singleVal>=(INT)nbc)
2331 std::ostringstream oss;
2332 oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
2333 PyErr_SetString(PyExc_StopIteration,oss.str().c_str());
2337 return PyInt_FromLong(pt[singleVal]);
2341 return PyInt_FromLong(pt[nbc+singleVal]);
2344 std::ostringstream oss;
2345 oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
2346 throw INTERP_KERNEL::Exception(oss.str().c_str());
2352 PyObject *t=PyTuple_New(multiVal.size());
2353 for(std::size_t j=0;j<multiVal.size();j++)
2355 INT cid=multiVal[j];
2358 std::ostringstream oss;
2359 oss << "Requesting for id #" << cid << " having only " << nbc << " components !";
2360 throw INTERP_KERNEL::Exception(oss.str().c_str());
2362 PyTuple_SetItem(t,j,PyInt_FromLong(pt[cid]));
2368 mcIdType sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
2369 PyObject *t=PyTuple_New(sz);
2370 for(INT j=0;j<sz;j++)
2371 PyTuple_SetItem(t,j,PyInt_FromLong(pt[slic.first+j*slic.second.second]));
2375 throw INTERP_KERNEL::Exception("ARRAY ## Tuple::__getitem__ : unrecognized type entered !");
2379 ARRAY ## Tuple *__setitem__(PyObject *obj, PyObject *value)
2381 const char msg[]="DataArrayIntTuple::__setitem__ : unrecognized type entered, int, slice, list<int>, tuple<int> !";
2382 const char msg2[]="DataArrayIntTuple::__setitem__ : Mismatch of slice values in 2nd parameter (components) !";
2384 mcIdType singleValV;
2385 std::vector<mcIdType> multiValV;
2386 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slicV;
2387 MEDCoupling::ARRAY ## Tuple *daIntTyyppV=0;
2388 mcIdType nbc=ToIdType(self->getNumberOfCompo());
2389 convertObjToPossibleCpp22<INT>(value,nbc,sw1,singleValV,multiValV,slicV,daIntTyyppV);
2391 std::vector<INT> multiVal;
2392 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2393 MEDCoupling::ARRAY *daIntTyypp=0;
2394 INT *pt=self->getPointer();
2395 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
2402 std::ostringstream oss;
2403 oss << "Requesting for setting id # " << singleVal << " having only " << nbc << " components !";
2404 throw INTERP_KERNEL::Exception(oss.str().c_str());
2410 pt[singleVal]=(INT)singleValV;
2415 if(multiValV.size()!=1)
2417 std::ostringstream oss;
2418 oss << "Requesting for setting id # " << singleVal << " with a list or tuple with size != 1 ! ";
2419 throw INTERP_KERNEL::Exception(oss.str().c_str());
2421 pt[singleVal]=(INT)multiValV[0];
2426 pt[singleVal]=daIntTyyppV->getConstPointer()[0];
2430 throw INTERP_KERNEL::Exception(msg);
2439 for(std::vector<INT>::const_iterator it=multiVal.begin();it!=multiVal.end();it++)
2443 std::ostringstream oss;
2444 oss << "Requesting for setting id # " << *it << " having only " << nbc << " components !";
2445 throw INTERP_KERNEL::Exception(oss.str().c_str());
2447 pt[*it]=(INT)singleValV;
2453 if(multiVal.size()!=multiValV.size())
2455 std::ostringstream oss;
2456 oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << multiVal.size() << " !";
2457 throw INTERP_KERNEL::Exception(oss.str().c_str());
2459 for(INT i=0;i<(INT)multiVal.size();i++)
2461 INT pos=multiVal[i];
2464 std::ostringstream oss;
2465 oss << "Requesting for setting id # " << pos << " having only " << nbc << " components !";
2466 throw INTERP_KERNEL::Exception(oss.str().c_str());
2468 pt[multiVal[i]]=(INT)multiValV[i];
2474 const INT *ptV=daIntTyyppV->getConstPointer();
2475 if(nbc>(INT)daIntTyyppV->getNumberOfCompo())
2477 std::ostringstream oss;
2478 oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
2479 throw INTERP_KERNEL::Exception(oss.str().c_str());
2481 std::copy(ptV,ptV+nbc,pt);
2485 throw INTERP_KERNEL::Exception(msg);
2490 std::size_t sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
2495 for(std::size_t j=0;j<sz;j++)
2496 pt[slic.first+j*slic.second.second]=(INT)singleValV;
2501 if(sz!=multiValV.size())
2503 std::ostringstream oss;
2504 oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << sz << " !";
2505 throw INTERP_KERNEL::Exception(oss.str().c_str());
2507 for(std::size_t j=0;j<sz;j++)
2508 pt[slic.first+j*slic.second.second]=(INT)multiValV[j];
2513 const INT *ptV=daIntTyyppV->getConstPointer();
2514 if(sz>daIntTyyppV->getNumberOfCompo())
2516 std::ostringstream oss;
2517 oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
2518 throw INTERP_KERNEL::Exception(oss.str().c_str());
2520 for(std::size_t j=0;j<sz;j++)
2521 pt[slic.first+j*slic.second.second]=ptV[j];
2525 throw INTERP_KERNEL::Exception(msg);
2529 throw INTERP_KERNEL::Exception(msg);
2538 %define TRANSFORMWITHINDARR( ARRAY, INT )
2539 void transformWithIndArr(PyObject *li)
2542 int res1(SWIG_ConvertPtr(li,&da,SWIGTITraits<INT>::TI, 0 | 0 ));
2543 if (!SWIG_IsOK(res1))
2545 int res2(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__MapII, 0 | 0 ));
2548 MapII *m=reinterpret_cast<MapII *>(da);
2549 self->transformWithIndArr(*m);
2554 INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
2555 self->transformWithIndArr(tmp,tmp+size);
2560 ARRAY *da2=reinterpret_cast< ARRAY * >(da);
2561 self->transformWithIndArr(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
2566 namespace MEDCoupling
2570 typedef long long Int64;
2572 typedef long int Int64;
2575 class DataArrayInt32Iterator;
2577 class DataArrayInt32 : public DataArray
2579 ARRAYDEF( DataArrayInt32, Int32 )
2581 %extend DataArrayInt32 {
2582 DataArrayInt64 *convertToInt64Arr() const
2584 MCAuto<DataArrayInt64> ret(self->convertToInt64Arr());
2588 PyObject *toNumPyArray() // not const. It is not a bug !
2590 return ToNumPyArray<DataArrayInt32,MEDCoupling::Int32>(self,NPY_INT32,"DataArrayInt32");
2593 #ifndef MEDCOUPLING_USE_64BIT_IDS
2594 MCAuto< MapII > invertArrayN2O2O2NOptimized()
2596 return self->invertArrayN2O2O2NOptimized();
2598 MCAuto< MapII > giveN2OOptimized()
2600 return self->giveN2OOptimized();
2602 TRANSFORMWITHINDARR( DataArrayInt32, Int32 )
2606 class DataArrayInt64Iterator;
2608 class DataArrayInt64 : public DataArray
2610 ARRAYDEF( DataArrayInt64, Int64 )
2612 %extend DataArrayInt64 {
2613 DataArrayInt32 *convertToInt32Arr() const
2615 MCAuto<DataArrayInt32> ret(self->convertToInt32Arr());
2619 PyObject *toNumPyArray() // not const. It is not a bug !
2621 return ToNumPyArray<DataArrayInt64,MEDCoupling::Int64>(self,NPY_INT64,"DataArrayInt64");
2624 #ifdef MEDCOUPLING_USE_64BIT_IDS
2625 MCAuto< MapII > invertArrayN2O2O2NOptimized()
2627 return self->invertArrayN2O2O2NOptimized();
2629 MCAuto< MapII > giveN2OOptimized()
2631 return self->giveN2OOptimized();
2633 TRANSFORMWITHINDARR( DataArrayInt64, Int64 )