1 // Copyright (C) 2007-2020 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 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;
169 static ARRAY *Range(INT begin, INT end, INT step);
177 static ARRAY *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
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)";
185 if(PyList_Check(elt0) || PyTuple_Check(elt0))
189 if(PyInt_Check(nbOfTuples))
191 mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples));
193 throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive set of allocated memory !");
196 if(PyInt_Check(nbOfComp))
197 {//ARRAY.New([1,3,4,5],2,2)
198 mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp));
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());
207 throw INTERP_KERNEL::Exception(msg.c_str());
210 {//ARRAY.New([1,3,4],3)
211 MCAuto<ARRAY> ret=ARRAY::New();
213 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(elt0,nbOfTuples1,tmpp1);
214 ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
219 throw INTERP_KERNEL::Exception(msg.c_str());
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());
230 else if(PyInt_Check(elt0))
232 INT nbOfTuples1=(INT)PyInt_AS_LONG(elt0);
234 throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive set of allocated memory !");
239 if(PyInt_Check(nbOfTuples))
241 INT nbOfCompo=(INT)PyInt_AS_LONG(nbOfTuples);
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);
249 throw INTERP_KERNEL::Exception(msg.c_str());
252 throw INTERP_KERNEL::Exception(msg.c_str());
256 MCAuto<ARRAY> ret=ARRAY::New();
257 ret->alloc(nbOfTuples1,1);
261 else if(MEDCouplingHasNumPyBindings() && PyArray_Check(elt0) && nbOfTuples==NULL && nbOfComp==NULL)
262 {//ARRAY.New(numpyArray)
263 return BuildNewInstance<ARRAY,INT>(elt0,NPYTraits<INT>::NPYObjectType,NPYTraits<INT>::NPYFunc,MEDCoupling::Traits<INT>::NPYStr);
266 throw INTERP_KERNEL::Exception(msg.c_str());
267 throw INTERP_KERNEL::Exception(msg.c_str());//to make g++ happy
270 ARRAY(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
272 return MEDCoupling_ ## ARRAY ## _New__SWIG_1(elt0,nbOfTuples,nbOfComp);
275 std::string __str__() const
277 return self->reprNotTooLong();
280 mcIdType __len__() const
282 if(self->isAllocated())
284 return self->getNumberOfTuples();
288 throw INTERP_KERNEL::Exception("ARRAY::__len__ : Instance is NOT allocated !");
294 return self->intValue();
297 ARRAY ## Iterator *__iter__()
299 return self->iterator();
302 PyObject *accumulate() const
304 mcIdType sz=ToIdType(self->getNumberOfComponents());
305 INTERP_KERNEL::AutoPtr<INT> tmp=new INT[sz];
306 self->accumulate((INT *)tmp);
307 return convertIntArrToPyList((const INT *)tmp,sz);
310 ARRAY *accumulatePerChunck(PyObject *indexArr) const
313 std::vector<mcIdType> val2;
314 const mcIdType *bg=convertIntStarLikePyObjToCppIntStar(indexArr,sw,sz,val,val2);
315 return self->accumulatePerChunck(bg,bg+sz);
318 DataArrayIdType *findIdsEqualTuple(PyObject *inputTuple) const
322 std::vector<INT> val2;
323 const INT *bg(convertIntStarLikePyObjToCppIntStar(inputTuple,sw,sz,val,val2));
324 return self->findIdsEqualTuple(bg,bg+sz);
327 DataArrayIdType *findIdForEach(PyObject *vals) const
331 std::vector<INT> val2;
332 const INT *bg(convertIntStarLikePyObjToCppIntStar(vals,sw,sz,val,val2));
333 MCAuto<DataArrayIdType> ret(self->findIdForEach(bg,bg+sz));
337 PyObject *splitInBalancedSlices(mcIdType nbOfSlices) const
339 std::vector< std::pair<mcIdType,mcIdType> > slcs(self->splitInBalancedSlices(nbOfSlices));
340 PyObject *ret=PyList_New(slcs.size());
341 for(std::size_t i=0;i<slcs.size();i++)
342 PyList_SetItem(ret,i,PySlice_New(PyInt_FromLong(slcs[i].first),PyInt_FromLong(slcs[i].second),PyInt_FromLong(1)));
346 ARRAY *buildExplicitArrOfSliceOnScaledArr(PyObject *slic) const
348 if(!PySlice_Check(slic))
349 throw INTERP_KERNEL::Exception("ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : expecting a pyslice as second (first) parameter !");
350 Py_ssize_t strt=2,stp=2,step=2;
351 GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !");
352 if(strt==std::numeric_limits<INT>::max() || stp==std::numeric_limits<INT>::max())
353 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 !");
354 return self->buildExplicitArrOfSliceOnScaledArr((INT)strt,(INT)stp,(INT)step);
357 PyObject *getMinMaxValues() const
360 self->getMinMaxValues(a,b);
361 PyObject *ret=PyTuple_New(2);
362 PyTuple_SetItem(ret,0,PyInt_FromLong(a));
363 PyTuple_SetItem(ret,1,PyInt_FromLong(b));
367 static PyObject *ConvertIndexArrayToO2N(mcIdType nbOfOldTuples, PyObject *arr, PyObject *arrI)
369 mcIdType newNbOfTuples=-1;
370 mcIdType szArr,szArrI,sw,iTypppArr,iTypppArrI;
371 std::vector<mcIdType> stdvecTyyppArr;
372 std::vector<mcIdType> stdvecTyyppArrI;
373 const mcIdType *arrPtr=convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr);
374 const mcIdType *arrIPtr=convertIntStarLikePyObjToCppIntStar(arrI,sw,szArrI,iTypppArrI,stdvecTyyppArrI);
375 DataArrayIdType *ret0=MEDCoupling::ARRAY::ConvertIndexArrayToO2N(nbOfOldTuples,arrPtr,arrIPtr,arrIPtr+szArrI,newNbOfTuples);
376 PyObject *ret=PyTuple_New(2);
377 PyTuple_SetItem(ret,0,SWIG_NewPointerObj((void*)ret0,SWIGTITraits<mcIdType>::TI,SWIG_POINTER_OWN | 0));
378 PyTuple_SetItem(ret,1,PyInt_FromLong(newNbOfTuples));
382 static DataArrayIdType *CheckAndPreparePermutation(PyObject *arr)
384 MCAuto<DataArrayIdType> ret(DataArrayIdType::New());
387 std::vector<INT> stdvecTyyppArr;
388 const INT *arrPtr(convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr));
389 mcIdType *pt(MEDCoupling::ARRAY::CheckAndPreparePermutation(arrPtr,arrPtr+szArr));
390 ret->useArray(pt,true,MEDCoupling::DeallocType::C_DEALLOC,szArr,1);
394 void setValues(PyObject *li, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
396 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 !";
397 if(PyList_Check(li) || PyTuple_Check(li))
399 if(nbOfTuples && nbOfTuples != Py_None)
401 if(PyInt_Check(nbOfTuples))
403 mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples));
405 throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive set of allocated memory !");
406 if(nbOfComp && nbOfComp != Py_None)
408 if(PyInt_Check(nbOfComp))
409 {//ARRAY.setValues([1,3,4,5],2,2)
410 mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp));
412 throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive number of components !");
413 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,nbOfTuples1,nbOfCompo);
414 self->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),self->getPointer());
417 throw INTERP_KERNEL::Exception(msg);
420 {//ARRAY.setValues([1,3,4],3)
422 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,nbOfTuples1,tmpp1);
423 self->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),self->getPointer());
427 throw INTERP_KERNEL::Exception(msg);
430 {// ARRAY.setValues([1,3,4])
431 mcIdType tmpp1=-1,tmpp2=-1;
432 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,tmpp1,tmpp2);
433 self->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),self->getPointer());
437 throw INTERP_KERNEL::Exception(msg);
440 PyObject *getValues() const
442 const INT *vals=self->getConstPointer();
443 return convertIntArrToPyList(vals,self->getNbOfElems());
446 PyObject *isEqualIfNotWhy(const ARRAY& other) const
449 bool ret0=self->isEqualIfNotWhy(other,ret1);
450 PyObject *ret=PyTuple_New(2);
451 PyObject *ret0Py=ret0?Py_True:Py_False;
453 PyTuple_SetItem(ret,0,ret0Py);
454 PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str()));
458 PyObject *getValuesAsTuple() const
460 const INT *vals=self->getConstPointer();
461 mcIdType nbOfComp=ToIdType(self->getNumberOfComponents());
462 mcIdType nbOfTuples=self->getNumberOfTuples();
463 return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
466 static PyObject *MakePartition(PyObject *gps, mcIdType newNb)
468 std::vector<const ARRAY *> groups;
469 std::vector< std::vector<mcIdType> > fidsOfGroups;
470 convertFromPyObjVectorOfObj(gps,SWIGTITraits<INT>::TI,"ARRAY",groups);
471 DataArrayIdType *ret0=MEDCoupling::ARRAY::MakePartition(groups,newNb,fidsOfGroups);
472 PyObject *ret = PyList_New(2);
473 PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
474 std::size_t sz=fidsOfGroups.size();
475 PyObject *ret1 = PyList_New(sz);
476 for(std::size_t i=0;i<sz;i++)
477 PyList_SetItem(ret1,i,convertIntArrToPyList2(fidsOfGroups[i]));
478 PyList_SetItem(ret,1,ret1);
482 DataArrayIdType *findIdsEqualList(PyObject *obj)
486 std::vector<INT> multiVal;
487 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
489 convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
493 return self->findIdsEqualList(&singleVal,&singleVal+1);
495 return self->findIdsEqualList(&multiVal[0],&multiVal[0]+multiVal.size());
497 return self->findIdsEqualList(daIntTyypp->begin(),daIntTyypp->end());
499 throw INTERP_KERNEL::Exception("ARRAY::findIdsEqualList : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
503 DataArrayIdType *findIdsNotEqualList(PyObject *obj)
507 std::vector<INT> multiVal;
508 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
510 convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
514 return self->findIdsNotEqualList(&singleVal,&singleVal+1);
516 return self->findIdsNotEqualList(&multiVal[0],&multiVal[0]+multiVal.size());
518 return self->findIdsNotEqualList(daIntTyypp->begin(),daIntTyypp->end());
520 throw INTERP_KERNEL::Exception("ARRAY::findIdsNotEqualList : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
524 PyObject *splitByValueRange(PyObject *li) const
526 ARRAY *ret0=0,*ret1=0,*ret2=0;
528 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<INT>::TI, 0 | 0 );
529 if (!SWIG_IsOK(res1))
532 INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
533 self->splitByValueRange(tmp,(INT *)tmp+size,ret0,ret1,ret2);
537 ARRAY *da2=reinterpret_cast< ARRAY * >(da);
539 throw INTERP_KERNEL::Exception("Not null ARRAY instance expected !");
540 da2->checkAllocated();
541 self->splitByValueRange(da2->begin(),da2->end(),ret0,ret1,ret2);
543 PyObject *ret = PyList_New(3);
544 PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
545 PyList_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
546 PyList_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(ret2),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
550 DataArrayIdType *transformWithIndArrR(PyObject *li) const
553 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<INT>::TI, 0 | 0 );
554 if (!SWIG_IsOK(res1))
557 INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
558 return self->transformWithIndArrR(tmp,tmp+size);
562 ARRAY *da2=reinterpret_cast< ARRAY * >(da);
563 return self->transformWithIndArrR(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
567 ARRAY *renumberAndReduce(PyObject *li, mcIdType newNbOfTuple)
570 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 | 0 );
571 if (!SWIG_IsOK(res1))
574 INTERP_KERNEL::AutoPtr<mcIdType> tmp=convertPyToNewIntArr2(li,&size);
575 if(size!=self->getNumberOfTuples())
577 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
579 return self->renumberAndReduce(tmp,newNbOfTuple);
583 DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da);
585 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
586 da2->checkAllocated();
587 mcIdType size=self->getNumberOfTuples();
588 if(size!=self->getNumberOfTuples())
590 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
592 return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple);
596 ARRAY *renumber(PyObject *li)
599 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 | 0 );
600 if (!SWIG_IsOK(res1))
603 INTERP_KERNEL::AutoPtr<mcIdType> tmp=convertPyToNewIntArr2(li,&size);
604 if(size!=self->getNumberOfTuples())
606 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
608 return self->renumber(tmp);
612 DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da);
614 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
615 da2->checkAllocated();
616 mcIdType size=self->getNumberOfTuples();
617 if(size!=self->getNumberOfTuples())
619 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
621 return self->renumber(da2->getConstPointer());
625 ARRAY *renumberR(PyObject *li)
628 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 | 0 );
629 if (!SWIG_IsOK(res1))
632 INTERP_KERNEL::AutoPtr<mcIdType> tmp=convertPyToNewIntArr2(li,&size);
633 if(size!=self->getNumberOfTuples())
635 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
637 return self->renumberR(tmp);
641 DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da);
643 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
644 da2->checkAllocated();
645 mcIdType size=self->getNumberOfTuples();
646 if(size!=self->getNumberOfTuples())
648 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
650 return self->renumberR(da2->getConstPointer());
654 void setSelectedComponents(const ARRAY *a, PyObject *li)
656 std::vector<std::size_t> tmp;
657 convertPyToNewIntArr3(li,tmp);
658 self->setSelectedComponents(a,tmp);
661 PyObject *explodeComponents() const
663 std::vector< MCAuto<ARRAY> > retCpp(self->explodeComponents());
664 std::size_t sz(retCpp.size());
665 PyObject *res(PyList_New(sz));
666 for(std::size_t i=0;i<sz;i++)
667 PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(retCpp[i].retn()),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
671 PyObject *getTuple(mcIdType tupleId)
673 mcIdType sz=ToIdType(self->getNumberOfComponents());
674 INTERP_KERNEL::AutoPtr<INT> tmp=new INT[sz];
675 self->getTuple(tupleId,tmp);
676 return convertIntArrToPyList((const INT*)tmp,sz);
679 PyObject *changeSurjectiveFormat(INT targetNb) const
681 DataArrayIdType *arr=0;
682 DataArrayIdType *arrI=0;
683 self->changeSurjectiveFormat(targetNb,arr,arrI);
684 PyObject *res = PyList_New(2);
685 PyList_SetItem(res,0,SWIG_NewPointerObj((void*)arr,SWIGTITraits<mcIdType>::TI,SWIG_POINTER_OWN | 0));
686 PyList_SetItem(res,1,SWIG_NewPointerObj((void*)arrI,SWIGTITraits<mcIdType>::TI,SWIG_POINTER_OWN | 0));
690 static ARRAY *Meld(PyObject *li)
692 std::vector<const ARRAY *> tmp;
693 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
694 return ARRAY::Meld(tmp);
697 static ARRAY *Aggregate(PyObject *li)
699 std::vector<const ARRAY *> tmp;
700 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
701 return ARRAY::Aggregate(tmp);
704 static ARRAY *AggregateIndexes(PyObject *li)
706 std::vector<const ARRAY *> tmp;
707 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
708 return ARRAY::AggregateIndexes(tmp);
711 static ARRAY *BuildUnion(PyObject *li)
713 std::vector<const ARRAY *> tmp;
714 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
715 return ARRAY::BuildUnion(tmp);
718 static ARRAY *BuildIntersection(PyObject *li)
720 std::vector<const ARRAY *> tmp;
721 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
722 return ARRAY::BuildIntersection(tmp);
725 PyObject *getMaxValue() const
728 INT r1=self->getMaxValue(tmp);
729 PyObject *ret=PyTuple_New(2);
730 PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
731 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
735 PyObject *getMaxAbsValue(std::size_t& tupleId) const
738 INT r1=self->getMaxAbsValue(tmp);
739 PyObject *ret=PyTuple_New(2);
740 PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
741 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
745 PyObject *getMinValue() const
748 INT r1=self->getMinValue(tmp);
749 PyObject *ret=PyTuple_New(2);
750 PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
751 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
755 mcIdType index(PyObject *obj) const
757 std::size_t nbOfCompo=self->getNumberOfComponents();
764 INT val=(INT)PyInt_AS_LONG(obj);
765 return self->findIdFirstEqual(val);
768 throw INTERP_KERNEL::Exception("ARRAY::index : 'this' contains one component and trying to find an element which is not an integer !");
772 std::vector<INT> arr;
773 convertPyToNewIntArr3(obj,arr);
774 return self->findIdFirstEqualTuple(arr);
779 bool __contains__(PyObject *obj) const
781 std::size_t nbOfCompo=self->getNumberOfComponents();
790 INT val=(INT)PyInt_AS_LONG(obj);
791 return self->presenceOfValue(val);
794 throw INTERP_KERNEL::Exception("ARRAY::__contains__ : 'this' contains one component and trying to find an element which is not an integer !");
798 std::vector<INT> arr;
799 convertPyToNewIntArr3(obj,arr);
800 return self->presenceOfTuple(arr);
805 PyObject *__getitem__(PyObject *obj)
807 const char msg[]="Unexpected situation in ARRAY::__getitem__ !";
808 const char msg2[]="ARRAY::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
809 self->checkAllocated();
810 mcIdType nbOfTuples=self->getNumberOfTuples();
811 std::size_t nbOfComponents=self->getNumberOfComponents();
814 std::vector<mcIdType> vt1;
815 std::vector<std::size_t> vc1;
816 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > pt1,pc1;
817 DataArrayIdType *dt1=0,*dc1=0;
819 convertObjToPossibleCpp3(obj,nbOfTuples,(int)nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
825 if(nbOfComponents==1)
826 return PyInt_FromLong(self->getIJSafe(it1,0));
827 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&it1,&it1+1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
830 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size())),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
832 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
834 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems())),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
836 return PyInt_FromLong(self->getIJSafe(it1,ic1));
839 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
840 std::vector<std::size_t> v2(1,ic1);
841 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
845 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
846 std::vector<std::size_t> v2(1,ic1);
847 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
851 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
852 std::vector<std::size_t> v2(1,ic1);
853 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
857 ret=self->selectByTupleIdSafe(&it1,&it1+1);
858 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
862 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
863 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
867 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
868 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
872 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
873 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
877 ret=self->selectByTupleIdSafe(&it1,&it1+1);
878 mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
879 std::vector<std::size_t> v2(nbOfComp);
880 for(INT i=0;i<nbOfComp;i++)
881 v2[i]=pc1.first+i*pc1.second.second;
882 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
886 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
887 mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
888 std::vector<std::size_t> v2(nbOfComp);
889 for(INT i=0;i<nbOfComp;i++)
890 v2[i]=pc1.first+i*pc1.second.second;
891 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
895 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
896 mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
897 std::vector<std::size_t> v2(nbOfComp);
898 for(mcIdType i=0;i<nbOfComp;i++)
899 v2[i]=pc1.first+i*pc1.second.second;
900 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
904 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
905 mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
906 std::vector<std::size_t> v2(nbOfComp);
907 for(INT i=0;i<nbOfComp;i++)
908 v2[i]=pc1.first+i*pc1.second.second;
909 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
912 throw INTERP_KERNEL::Exception(msg);
916 ARRAY *__setitem__(PyObject *obj, PyObject *value)
918 self->checkAllocated();
919 const char msg[]="Unexpected situation in __setitem__ !";
920 mcIdType nbOfTuples=self->getNumberOfTuples();
921 int nbOfComponents=(int)self->getNumberOfComponents();
926 ARRAY ## Tuple *dd1=0;
927 convertIntStarLikePyObjToCpp(value,sw1,i1,v1,d1,dd1);
929 std::vector<mcIdType> vt1,vc1;
930 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > pt1,pc1;
931 DataArrayIdType *dt1=0,*dc1=0;
932 convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
941 self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
945 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
946 self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
949 self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1);
952 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
953 self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1);
956 throw INTERP_KERNEL::Exception(msg);
965 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
969 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
970 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
973 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
976 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
977 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
980 throw INTERP_KERNEL::Exception(msg);
989 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
993 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
994 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
997 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
1000 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1001 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
1004 throw INTERP_KERNEL::Exception(msg);
1013 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
1017 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1018 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
1021 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
1024 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1025 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
1028 throw INTERP_KERNEL::Exception(msg);
1037 self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
1041 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1042 self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
1045 self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1);
1048 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1049 self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1);
1052 throw INTERP_KERNEL::Exception(msg);
1061 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
1065 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1066 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
1069 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
1072 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1073 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
1076 throw INTERP_KERNEL::Exception(msg);
1085 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
1089 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1090 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
1093 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
1096 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1097 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
1100 throw INTERP_KERNEL::Exception(msg);
1109 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
1113 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1114 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
1117 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
1120 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1121 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
1124 throw INTERP_KERNEL::Exception(msg);
1133 self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
1137 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1138 self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
1141 self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
1144 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1145 self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
1148 throw INTERP_KERNEL::Exception(msg);
1157 self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
1161 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1162 self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
1165 self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
1168 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1169 self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
1172 throw INTERP_KERNEL::Exception(msg);
1181 self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
1185 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1186 self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size(),false);
1189 self->setPartOfValues4(d1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
1192 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1193 self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
1196 throw INTERP_KERNEL::Exception(msg);
1205 self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
1209 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1210 self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
1213 self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
1216 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1217 self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
1220 throw INTERP_KERNEL::Exception(msg);
1229 self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
1233 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1234 self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
1237 self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
1240 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1241 self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
1244 throw INTERP_KERNEL::Exception(msg);
1253 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
1257 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1258 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false);
1261 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
1264 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1265 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
1268 throw INTERP_KERNEL::Exception(msg);
1277 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
1281 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1282 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false);
1285 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
1288 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1289 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
1292 throw INTERP_KERNEL::Exception(msg);
1301 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
1305 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1306 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false);
1309 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
1312 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1313 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
1316 throw INTERP_KERNEL::Exception(msg);
1321 throw INTERP_KERNEL::Exception(msg);
1326 ARRAY *__neg__() const
1328 return self->negate();
1331 ARRAY *__add__(PyObject *obj)
1333 const char msg[]="Unexpected situation in __add__ !";
1336 std::vector<INT> aa;
1337 ARRAY ## Tuple *aaa;
1339 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1344 MCAuto<ARRAY> ret=self->deepCopy();
1345 ret->applyLin(1,val);
1350 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1351 return ARRAY::Add(self,aaaa);
1355 return ARRAY::Add(self,a);
1359 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1360 return ARRAY::Add(self,aaaa);
1363 throw INTERP_KERNEL::Exception(msg);
1367 ARRAY *__radd__(PyObject *obj)
1369 const char msg[]="Unexpected situation in __radd__ !";
1372 std::vector<INT> aa;
1373 ARRAY ## Tuple *aaa;
1375 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1380 MCAuto<ARRAY> ret=self->deepCopy();
1381 ret->applyLin(1,val);
1386 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1387 return ARRAY::Add(self,aaaa);
1391 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1392 return ARRAY::Add(self,aaaa);
1395 throw INTERP_KERNEL::Exception(msg);
1399 PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
1401 const char msg[]="Unexpected situation in __iadd__ !";
1404 std::vector<INT> aa;
1405 ARRAY ## Tuple *aaa;
1407 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1412 self->applyLin(1,val);
1413 Py_XINCREF(trueSelf);
1418 MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1420 Py_XINCREF(trueSelf);
1426 Py_XINCREF(trueSelf);
1431 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1432 self->addEqual(aaaa);
1433 Py_XINCREF(trueSelf);
1437 throw INTERP_KERNEL::Exception(msg);
1441 ARRAY *__sub__(PyObject *obj)
1443 const char msg[]="Unexpected situation in __sub__ !";
1446 std::vector<INT> aa;
1447 ARRAY ## Tuple *aaa;
1449 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1454 MCAuto<ARRAY> ret=self->deepCopy();
1455 ret->applyLin(1,-val);
1460 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1461 return ARRAY::Substract(self,aaaa);
1465 return ARRAY::Substract(self,a);
1469 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1470 return ARRAY::Substract(self,aaaa);
1473 throw INTERP_KERNEL::Exception(msg);
1477 ARRAY *__rsub__(PyObject *obj)
1479 const char msg[]="Unexpected situation in __rsub__ !";
1482 std::vector<INT> aa;
1483 ARRAY ## Tuple *aaa;
1485 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1490 MCAuto<ARRAY> ret=self->deepCopy();
1491 ret->applyLin(-1,val);
1496 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1497 return ARRAY::Substract(aaaa,self);
1501 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1502 return ARRAY::Substract(aaaa,self);
1505 throw INTERP_KERNEL::Exception(msg);
1509 PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
1511 const char msg[]="Unexpected situation in __isub__ !";
1514 std::vector<INT> aa;
1515 ARRAY ## Tuple *aaa;
1517 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1522 self->applyLin(1,-val);
1523 Py_XINCREF(trueSelf);
1528 MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1529 self->substractEqual(bb);
1530 Py_XINCREF(trueSelf);
1535 self->substractEqual(a);
1536 Py_XINCREF(trueSelf);
1541 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1542 self->substractEqual(aaaa);
1543 Py_XINCREF(trueSelf);
1547 throw INTERP_KERNEL::Exception(msg);
1551 ARRAY *__mul__(PyObject *obj)
1553 const char msg[]="Unexpected situation in __mul__ !";
1556 std::vector<INT> aa;
1557 ARRAY ## Tuple *aaa;
1559 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1564 MCAuto<ARRAY> ret=self->deepCopy();
1565 ret->applyLin(val,0);
1570 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1571 return ARRAY::Multiply(self,aaaa);
1575 return ARRAY::Multiply(self,a);
1579 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1580 return ARRAY::Multiply(self,aaaa);
1583 throw INTERP_KERNEL::Exception(msg);
1587 ARRAY *__rmul__(PyObject *obj)
1589 const char msg[]="Unexpected situation in __rmul__ !";
1592 std::vector<INT> aa;
1593 ARRAY ## Tuple *aaa;
1595 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1600 MCAuto<ARRAY> ret=self->deepCopy();
1601 ret->applyLin(val,0);
1606 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1607 return ARRAY::Multiply(self,aaaa);
1611 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1612 return ARRAY::Multiply(self,aaaa);
1615 throw INTERP_KERNEL::Exception(msg);
1619 PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
1621 const char msg[]="Unexpected situation in __imul__ !";
1624 std::vector<INT> aa;
1625 ARRAY ## Tuple *aaa;
1627 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1632 self->applyLin(val,0);
1633 Py_XINCREF(trueSelf);
1638 MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1639 self->multiplyEqual(bb);
1640 Py_XINCREF(trueSelf);
1645 self->multiplyEqual(a);
1646 Py_XINCREF(trueSelf);
1651 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1652 self->multiplyEqual(aaaa);
1653 Py_XINCREF(trueSelf);
1657 throw INTERP_KERNEL::Exception(msg);
1661 ARRAY *__div__(PyObject *obj)
1663 const char msg[]="Unexpected situation in __div__ !";
1666 std::vector<INT> aa;
1667 ARRAY ## Tuple *aaa;
1669 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1674 MCAuto<ARRAY> ret=self->deepCopy();
1675 ret->applyDivideBy(val);
1680 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1681 return ARRAY::Divide(self,aaaa);
1685 return ARRAY::Divide(self,a);
1689 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1690 return ARRAY::Divide(self,aaaa);
1693 throw INTERP_KERNEL::Exception(msg);
1697 ARRAY *__rdiv__(PyObject *obj)
1699 const char msg[]="Unexpected situation in __rdiv__ !";
1702 std::vector<INT> aa;
1703 ARRAY ## Tuple *aaa;
1705 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1710 MCAuto<ARRAY> ret=self->deepCopy();
1716 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1717 return ARRAY::Divide(aaaa,self);
1721 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1722 return ARRAY::Divide(aaaa,self);
1725 throw INTERP_KERNEL::Exception(msg);
1729 PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
1731 const char msg[]="Unexpected situation in __idiv__ !";
1734 std::vector<INT> aa;
1735 ARRAY ## Tuple *aaa;
1737 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1742 self->applyDivideBy(val);
1743 Py_XINCREF(trueSelf);
1748 MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1749 self->divideEqual(bb);
1750 Py_XINCREF(trueSelf);
1755 self->divideEqual(a);
1756 Py_XINCREF(trueSelf);
1761 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1762 self->divideEqual(aaaa);
1763 Py_XINCREF(trueSelf);
1767 throw INTERP_KERNEL::Exception(msg);
1771 ARRAY *__mod__(PyObject *obj)
1773 const char msg[]="Unexpected situation in __mod__ !";
1776 std::vector<INT> aa;
1777 ARRAY ## Tuple *aaa;
1779 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1784 MCAuto<ARRAY> ret=self->deepCopy();
1785 ret->applyModulus(val);
1790 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1791 return ARRAY::Modulus(self,aaaa);
1795 return ARRAY::Modulus(self,a);
1799 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1800 return ARRAY::Modulus(self,aaaa);
1803 throw INTERP_KERNEL::Exception(msg);
1807 ARRAY *__rmod__(PyObject *obj)
1809 const char msg[]="Unexpected situation in __rmod__ !";
1812 std::vector<INT> aa;
1813 ARRAY ## Tuple *aaa;
1815 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1820 MCAuto<ARRAY> ret=self->deepCopy();
1821 ret->applyRModulus(val);
1826 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1827 return ARRAY::Modulus(aaaa,self);
1831 return ARRAY::Modulus(a,self);
1835 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1836 return ARRAY::Modulus(aaaa,self);
1839 throw INTERP_KERNEL::Exception(msg);
1843 PyObject *___imod___(PyObject *trueSelf, PyObject *obj)
1845 const char msg[]="Unexpected situation in __imod__ !";
1848 std::vector<INT> aa;
1849 ARRAY ## Tuple *aaa;
1851 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1856 self->applyModulus(val);
1857 Py_XINCREF(trueSelf);
1862 self->modulusEqual(a);
1863 Py_XINCREF(trueSelf);
1868 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1869 self->modulusEqual(aaaa);
1870 Py_XINCREF(trueSelf);
1874 throw INTERP_KERNEL::Exception(msg);
1878 ARRAY *__pow__(PyObject *obj)
1880 const char msg[]="Unexpected situation in __pow__ !";
1883 std::vector<INT> aa;
1884 ARRAY ## Tuple *aaa;
1886 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1891 MCAuto<ARRAY> ret=self->deepCopy();
1897 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1898 return ARRAY::Pow(self,aaaa);
1902 return ARRAY::Pow(self,a);
1906 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1907 return ARRAY::Pow(self,aaaa);
1910 throw INTERP_KERNEL::Exception(msg);
1914 ARRAY *__rpow__(PyObject *obj)
1916 const char msg[]="Unexpected situation in __rpow__ !";
1919 std::vector<INT> aa;
1920 ARRAY ## Tuple *aaa;
1922 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1927 MCAuto<ARRAY> ret=self->deepCopy();
1928 ret->applyRPow(val);
1933 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1934 return ARRAY::Pow(aaaa,self);
1938 return ARRAY::Pow(a,self);
1942 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1943 return ARRAY::Pow(aaaa,self);
1946 throw INTERP_KERNEL::Exception(msg);
1950 PyObject *___ipow___(PyObject *trueSelf, PyObject *obj)
1952 const char msg[]="Unexpected situation in __ipow__ !";
1955 std::vector<INT> aa;
1956 ARRAY ## Tuple *aaa;
1958 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1963 self->applyPow(val);
1964 Py_XINCREF(trueSelf);
1970 Py_XINCREF(trueSelf);
1975 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1976 self->powEqual(aaaa);
1977 Py_XINCREF(trueSelf);
1981 throw INTERP_KERNEL::Exception(msg);
1985 std::string __repr__() const
1987 std::ostringstream oss;
1988 self->reprQuickOverview(oss);
1992 void pushBackValsSilent(PyObject *li)
1996 std::vector<INT> stdvecTyyppArr;
1997 const INT *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr);
1998 self->pushBackValsSilent(tmp,tmp+szArr);
2001 PyObject *partitionByDifferentValues() const
2003 std::vector<INT> ret1;
2004 std::vector<DataArrayIdType *> ret0=self->partitionByDifferentValues(ret1);
2005 std::size_t sz=ret0.size();
2006 PyObject *pyRet=PyTuple_New(2);
2007 PyObject *pyRet0=PyList_New((INT)sz);
2008 PyObject *pyRet1=PyList_New((INT)sz);
2009 for(std::size_t i=0;i<sz;i++)
2011 PyList_SetItem(pyRet0,i,SWIG_NewPointerObj(SWIG_as_voidptr(ret0[i]),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2012 PyList_SetItem(pyRet1,i,PyInt_FromLong(ret1[i]));
2014 PyTuple_SetItem(pyRet,0,pyRet0);
2015 PyTuple_SetItem(pyRet,1,pyRet1);
2019 PyObject *findIdsRangesInListOfIds(const ARRAY *listOfIds) const
2021 DataArrayIdType *ret0=0;
2023 self->findIdsRangesInListOfIds(listOfIds,ret0,ret1);
2024 PyObject *pyRet=PyTuple_New(2);
2025 PyTuple_SetItem(pyRet,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2026 PyTuple_SetItem(pyRet,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
2030 PyObject *isRange() const
2033 bool ret(self->isRange(a,b,c));
2034 PyObject *pyRet=PyTuple_New(2);
2035 PyObject *ret0Py=ret?Py_True:Py_False,*ret1Py(0);
2037 PyTuple_SetItem(pyRet,0,ret0Py);
2039 ret1Py=PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(c));
2045 PyTuple_SetItem(pyRet,1,ret1Py);
2049 static bool RemoveIdsFromIndexedArrays(PyObject *li, ARRAY *arr, DataArrayIdType *arrIndx, mcIdType offsetForRemoval=0) throw(INTERP_KERNEL::Exception)
2053 std::vector<INT> multiVal;
2054 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2055 MEDCoupling::ARRAY *daIntTyypp=0;
2057 throw INTERP_KERNEL::Exception("ARRAY::RemoveIdsFromIndexedArrays : null pointer as arrIndex !");
2058 convertIntStarOrSliceLikePyObjToCpp(li,arrIndx->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2062 return ARRAY::RemoveIdsFromIndexedArrays(&singleVal,&singleVal+1,arr,arrIndx,offsetForRemoval);
2064 return ARRAY::RemoveIdsFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arr,arrIndx,offsetForRemoval);
2066 return ARRAY::RemoveIdsFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arr,arrIndx,offsetForRemoval);
2068 throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2072 static PyObject *ExtractFromIndexedArrays(PyObject *li, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
2075 DataArrayIdType *arrIndexOut=0;
2078 std::vector<mcIdType> multiVal;
2079 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2080 MEDCoupling::DataArrayIdType *daIntTyypp=0;
2082 throw INTERP_KERNEL::Exception("ARRAY::ExtractFromIndexedArrays : null pointer as arrIndxIn !");
2083 convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2088 ARRAY::ExtractFromIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,arrOut,arrIndexOut);
2093 ARRAY::ExtractFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,arrOut,arrIndexOut);
2098 ARRAY::ExtractFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,arrOut,arrIndexOut);
2102 throw INTERP_KERNEL::Exception("ARRAY::ExtractFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2104 PyObject *ret=PyTuple_New(2);
2105 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2106 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2110 static PyObject *ExtractFromIndexedArraysSlice(mcIdType strt, mcIdType stp, mcIdType step, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
2113 DataArrayIdType *arrIndexOut=0;
2114 ARRAY::ExtractFromIndexedArraysSlice(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut);
2115 PyObject *ret=PyTuple_New(2);
2116 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2117 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2121 static PyObject *ExtractFromIndexedArraysSlice(PyObject *slic, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
2123 if(!PySlice_Check(slic))
2124 throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : the first param is not a pyslice !");
2125 Py_ssize_t strt=2,stp=2,step=2;
2127 throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : last array is null !");
2128 arrIndxIn->checkAllocated();
2129 if(arrIndxIn->getNumberOfComponents()!=1)
2130 throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : number of components of last argument must be equal to one !");
2131 GetIndicesOfSlice(slic,arrIndxIn->getNumberOfTuples(),&strt,&stp,&step,"ExtractFromIndexedArraysSlice (wrap) : Invalid slice regarding nb of elements !");
2133 DataArrayIdType *arrIndexOut=0;
2134 ARRAY::ExtractFromIndexedArraysSlice(ToIdType(strt),ToIdType(stp),ToIdType(step),arrIn,arrIndxIn,arrOut,arrIndexOut);
2135 PyObject *ret=PyTuple_New(2);
2136 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2137 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2141 static PyObject *SetPartOfIndexedArrays(PyObject *li,
2142 const ARRAY *arrIn, const DataArrayIdType *arrIndxIn,
2143 const ARRAY *srcArr, const DataArrayIdType *srcArrIndex) throw(INTERP_KERNEL::Exception)
2146 DataArrayIdType *arrIndexOut=0;
2149 std::vector<mcIdType> multiVal;
2150 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2151 MEDCoupling::DataArrayIdType *daIntTyypp=0;
2153 throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArrays : null pointer as arrIndex !");
2154 convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2159 ARRAY::SetPartOfIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
2164 ARRAY::SetPartOfIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
2169 ARRAY::SetPartOfIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
2173 throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2175 PyObject *ret=PyTuple_New(2);
2176 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2177 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2181 static void SetPartOfIndexedArraysSameIdx(PyObject *li, ARRAY *arrIn, const DataArrayIdType *arrIndxIn,
2182 const ARRAY *srcArr, const DataArrayIdType *srcArrIndex) throw(INTERP_KERNEL::Exception)
2186 std::vector<mcIdType> multiVal;
2187 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2188 MEDCoupling::DataArrayIdType *daIntTyypp=0;
2190 throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArraysSameIdx : null pointer as arrIndex !");
2191 convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2196 ARRAY::SetPartOfIndexedArraysSameIdx(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex);
2201 ARRAY::SetPartOfIndexedArraysSameIdx(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex);
2206 ARRAY::SetPartOfIndexedArraysSameIdx(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex);
2210 throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArraysSameIdx : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2217 class ARRAY ## Tuple;
2219 class ARRAY ## Iterator
2222 ARRAY ## Iterator(ARRAY *da);
2223 ~ARRAY ## Iterator();
2228 ARRAY ## Tuple *ret=self->nextt();
2230 return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_MEDCoupling__ ## ARRAY ## Tuple,SWIG_POINTER_OWN | 0);
2233 PyErr_SetString(PyExc_StopIteration,"No more data.");
2240 class ARRAY ## Tuple
2243 std::size_t getNumberOfCompo() const;
2244 ARRAY *buildDAInt(INT nbOfTuples, INT nbOfCompo) const;
2247 std::string __str__() const
2249 return self->repr();
2254 return self->intValue();
2259 return self->buildDAInt(1,self->getNumberOfCompo());
2262 PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
2264 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2265 MEDCoupling_ ## ARRAY ## ____iadd___(ret,0,obj);
2266 Py_XINCREF(trueSelf);
2270 PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
2272 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2273 MEDCoupling_ ## ARRAY ## ____isub___(ret,0,obj);
2274 Py_XINCREF(trueSelf);
2278 PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
2280 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2281 MEDCoupling_ ## ARRAY ## ____imul___(ret,0,obj);
2282 Py_XINCREF(trueSelf);
2285 PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
2287 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2288 MEDCoupling_ ## ARRAY ## ____idiv___(ret,0,obj);
2289 Py_XINCREF(trueSelf);
2293 PyObject *___imod___(PyObject *trueSelf, PyObject *obj)
2295 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2296 MEDCoupling_ ## ARRAY ## ____imod___(ret,0,obj);
2297 Py_XINCREF(trueSelf);
2303 return PyInt_FromLong(self->getNumberOfCompo());
2306 PyObject *__getitem__(PyObject *obj)
2308 const char msg2[]="ARRAY ## Tuple::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
2311 std::vector<INT> multiVal;
2312 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2313 MEDCoupling::DataArrayIdType *daIntTyypp=0;
2314 const INT *pt=self->getConstPointer();
2315 INT nbc=(INT)self->getNumberOfCompo();
2316 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,ToIdType(nbc),sw,singleVal,multiVal,slic,daIntTyypp);
2321 if(singleVal>=(INT)nbc)
2323 std::ostringstream oss;
2324 oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
2325 PyErr_SetString(PyExc_StopIteration,oss.str().c_str());
2329 return PyInt_FromLong(pt[singleVal]);
2333 return PyInt_FromLong(pt[nbc+singleVal]);
2336 std::ostringstream oss;
2337 oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
2338 throw INTERP_KERNEL::Exception(oss.str().c_str());
2344 PyObject *t=PyTuple_New(multiVal.size());
2345 for(std::size_t j=0;j<multiVal.size();j++)
2347 INT cid=multiVal[j];
2350 std::ostringstream oss;
2351 oss << "Requesting for id #" << cid << " having only " << nbc << " components !";
2352 throw INTERP_KERNEL::Exception(oss.str().c_str());
2354 PyTuple_SetItem(t,j,PyInt_FromLong(pt[cid]));
2360 mcIdType sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
2361 PyObject *t=PyTuple_New(sz);
2362 for(INT j=0;j<sz;j++)
2363 PyTuple_SetItem(t,j,PyInt_FromLong(pt[slic.first+j*slic.second.second]));
2367 throw INTERP_KERNEL::Exception("ARRAY ## Tuple::__getitem__ : unrecognized type entered !");
2371 ARRAY ## Tuple *__setitem__(PyObject *obj, PyObject *value)
2373 const char msg[]="DataArrayIntTuple::__setitem__ : unrecognized type entered, int, slice, list<int>, tuple<int> !";
2374 const char msg2[]="DataArrayIntTuple::__setitem__ : Mismatch of slice values in 2nd parameter (components) !";
2376 mcIdType singleValV;
2377 std::vector<mcIdType> multiValV;
2378 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slicV;
2379 MEDCoupling::ARRAY ## Tuple *daIntTyyppV=0;
2380 mcIdType nbc=ToIdType(self->getNumberOfCompo());
2381 convertObjToPossibleCpp22<INT>(value,nbc,sw1,singleValV,multiValV,slicV,daIntTyyppV);
2383 std::vector<INT> multiVal;
2384 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2385 MEDCoupling::ARRAY *daIntTyypp=0;
2386 INT *pt=self->getPointer();
2387 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
2394 std::ostringstream oss;
2395 oss << "Requesting for setting id # " << singleVal << " having only " << nbc << " components !";
2396 throw INTERP_KERNEL::Exception(oss.str().c_str());
2402 pt[singleVal]=(INT)singleValV;
2407 if(multiValV.size()!=1)
2409 std::ostringstream oss;
2410 oss << "Requesting for setting id # " << singleVal << " with a list or tuple with size != 1 ! ";
2411 throw INTERP_KERNEL::Exception(oss.str().c_str());
2413 pt[singleVal]=(INT)multiValV[0];
2418 pt[singleVal]=daIntTyyppV->getConstPointer()[0];
2422 throw INTERP_KERNEL::Exception(msg);
2431 for(std::vector<INT>::const_iterator it=multiVal.begin();it!=multiVal.end();it++)
2435 std::ostringstream oss;
2436 oss << "Requesting for setting id # " << *it << " having only " << nbc << " components !";
2437 throw INTERP_KERNEL::Exception(oss.str().c_str());
2439 pt[*it]=(INT)singleValV;
2445 if(multiVal.size()!=multiValV.size())
2447 std::ostringstream oss;
2448 oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << multiVal.size() << " !";
2449 throw INTERP_KERNEL::Exception(oss.str().c_str());
2451 for(INT i=0;i<(INT)multiVal.size();i++)
2453 INT pos=multiVal[i];
2456 std::ostringstream oss;
2457 oss << "Requesting for setting id # " << pos << " having only " << nbc << " components !";
2458 throw INTERP_KERNEL::Exception(oss.str().c_str());
2460 pt[multiVal[i]]=(INT)multiValV[i];
2466 const INT *ptV=daIntTyyppV->getConstPointer();
2467 if(nbc>(INT)daIntTyyppV->getNumberOfCompo())
2469 std::ostringstream oss;
2470 oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
2471 throw INTERP_KERNEL::Exception(oss.str().c_str());
2473 std::copy(ptV,ptV+nbc,pt);
2477 throw INTERP_KERNEL::Exception(msg);
2482 std::size_t sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
2487 for(std::size_t j=0;j<sz;j++)
2488 pt[slic.first+j*slic.second.second]=(INT)singleValV;
2493 if(sz!=multiValV.size())
2495 std::ostringstream oss;
2496 oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << sz << " !";
2497 throw INTERP_KERNEL::Exception(oss.str().c_str());
2499 for(std::size_t j=0;j<sz;j++)
2500 pt[slic.first+j*slic.second.second]=(INT)multiValV[j];
2505 const INT *ptV=daIntTyyppV->getConstPointer();
2506 if(sz>daIntTyyppV->getNumberOfCompo())
2508 std::ostringstream oss;
2509 oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
2510 throw INTERP_KERNEL::Exception(oss.str().c_str());
2512 for(std::size_t j=0;j<sz;j++)
2513 pt[slic.first+j*slic.second.second]=ptV[j];
2517 throw INTERP_KERNEL::Exception(msg);
2521 throw INTERP_KERNEL::Exception(msg);
2530 %define TRANSFORMWITHINDARR( ARRAY, INT )
2531 void transformWithIndArr(PyObject *li)
2534 int res1(SWIG_ConvertPtr(li,&da,SWIGTITraits<INT>::TI, 0 | 0 ));
2535 if (!SWIG_IsOK(res1))
2537 int res2(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__MapII, 0 | 0 ));
2540 MapII *m=reinterpret_cast<MapII *>(da);
2541 self->transformWithIndArr(*m);
2546 INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
2547 self->transformWithIndArr(tmp,tmp+size);
2552 ARRAY *da2=reinterpret_cast< ARRAY * >(da);
2553 self->transformWithIndArr(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
2558 namespace MEDCoupling
2562 typedef long long Int64;
2564 typedef long int Int64;
2567 class DataArrayInt32Iterator;
2569 class DataArrayInt32 : public DataArray
2571 ARRAYDEF( DataArrayInt32, Int32 )
2573 %extend DataArrayInt32 {
2575 PyObject *toNumPyArray() // not const. It is not a bug !
2577 return ToNumPyArray<DataArrayInt32,MEDCoupling::Int32>(self,NPY_INT32,"DataArrayInt32");
2580 #ifndef MEDCOUPLING_USE_64BIT_IDS
2581 MCAuto< MapII > invertArrayN2O2O2NOptimized()
2583 return self->invertArrayN2O2O2NOptimized();
2585 MCAuto< MapII > giveN2OOptimized()
2587 return self->giveN2OOptimized();
2589 TRANSFORMWITHINDARR( DataArrayInt32, Int32 )
2593 class DataArrayInt64Iterator;
2595 class DataArrayInt64 : public DataArray
2597 ARRAYDEF( DataArrayInt64, Int64 )
2599 %extend DataArrayInt64 {
2601 PyObject *toNumPyArray() // not const. It is not a bug !
2603 return ToNumPyArray<DataArrayInt64,MEDCoupling::Int64>(self,NPY_INT64,"DataArrayInt64");
2606 #ifdef MEDCOUPLING_USE_64BIT_IDS
2607 MCAuto< MapII > invertArrayN2O2O2NOptimized()
2609 return self->invertArrayN2O2O2NOptimized();
2611 MCAuto< MapII > giveN2OOptimized()
2613 return self->giveN2OOptimized();
2615 TRANSFORMWITHINDARR( DataArrayInt64, Int64 )