1 // Copyright (C) 2007-2019 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 *buildPermutationArr(const ARRAY& other) const;
48 ARRAY *sumPerTuple() const;
49 void sort(bool asc=true);
51 void checkMonotonic(bool increasing) const;
52 bool isMonotonic(bool increasing) const;
53 void checkStrictlyMonotonic(bool increasing) const;
54 bool isStrictlyMonotonic(bool increasing) const;
56 void fillWithValue(INT val);
57 void iota(INT init=0);
58 std::string repr() const;
59 std::string reprZip() const;
60 std::string reprNotTooLong() const;
61 ARRAY *invertArrayO2N2N2O(mcIdType newNbOfElem) const;
62 ARRAY *invertArrayN2O2O2N(mcIdType oldNbOfElem) const;
63 ARRAY *invertArrayO2N2N2OBis(mcIdType newNbOfElem) const;
64 DataArrayIdType *indicesOfSubPart(const ARRAY& partOfThis) const;
65 ARRAY *fromNoInterlace() const;
66 ARRAY *toNoInterlace() const;
67 ARRAY *selectByTupleIdSafeSlice(mcIdType bg, mcIdType end, mcIdType step) const;
68 DataArrayIdType *checkAndPreparePermutation() const;
69 DataArrayIdType *buildPermArrPerLevel() const;
70 bool isIota(mcIdType sizeExpected) const;
71 bool isUniform(INT val) const;
72 INT checkUniformAndGuess() const;
73 bool hasUniqueValues() const;
74 ARRAY *subArray(mcIdType tupleIdBg, mcIdType tupleIdEnd=-1) const;
76 ARRAY *changeNbOfComponents(std::size_t newNbOfComp, INT dftValue) const;
77 void meldWith(const ARRAY *other);
78 void setPartOfValues1(const ARRAY *a, mcIdType bgTuples, mcIdType endTuples, mcIdType stepTuples, mcIdType bgComp, mcIdType endComp, mcIdType stepComp, bool strictCompoCompare=true);
79 void setPartOfValuesSimple1(INT a, mcIdType bgTuples, mcIdType endTuples, mcIdType stepTuples, mcIdType bgComp, mcIdType endComp, mcIdType stepComp);
80 void setPartOfValuesAdv(const ARRAY *a, const DataArrayIdType *tuplesSelec);
81 void getTuple(mcIdType tupleId, INT *res) const;
82 INT getIJ(std::size_t tupleId, std::size_t compoId) const;
83 INT getIJSafe(std::size_t tupleId, std::size_t compoId) const;
86 void setIJ(mcIdType tupleId, mcIdType compoId, INT newVal);
87 void setIJSilent(mcIdType tupleId, mcIdType compoId, INT newVal);
89 const INT *getConstPointer() const;
90 ARRAY ## Iterator *iterator();
91 const INT *begin() const;
92 const INT *end() const;
93 DataArrayIdType *findIdsEqual(INT val) const;
94 DataArrayIdType *findIdsNotEqual(INT val) const;
95 mcIdType changeValue(INT oldValue, INT newValue);
96 mcIdType findIdFirstEqualTuple(const std::vector<INT>& tupl) const;
97 mcIdType findIdFirstEqual(INT value) const;
98 mcIdType findIdFirstEqual(const std::vector<INT>& vals) const;
99 mcIdType findIdSequence(const std::vector<INT>& vals) const;
100 bool presenceOfTuple(const std::vector<INT>& tupl) const;
101 bool presenceOfValue(INT value) const;
102 bool presenceOfValue(const std::vector<INT>& vals) const;
103 INT count(INT value) const;
104 INT accumulate(INT compId) const;
105 INT getMaxValueInArray() const;
106 INT getMaxAbsValueInArray() const;
107 INT getMinValueInArray() const;
109 ARRAY *computeAbs() const;
110 void applyLin(INT a, INT b, INT compoId);
111 void applyLin(INT a, INT b);
112 void applyInv(INT numerator);
113 ARRAY *negate() const;
114 void applyDivideBy(INT val);
115 void applyModulus(INT val);
116 void applyRModulus(INT val);
117 void applyPow(INT val);
118 void applyRPow(INT val);
119 ARRAY *findIdsInRange(INT vmin, INT vmax) const;
120 ARRAY *findIdsNotInRange(INT vmin, INT vmax) const;
121 ARRAY *findIdsStrictlyNegative() const;
122 bool checkAllIdsInRange(INT vmin, INT vmax) const;
123 static ARRAY *Aggregate(const ARRAY *a1, const ARRAY *a2, INT offsetA2);
124 static ARRAY *Meld(const ARRAY *a1, const ARRAY *a2);
125 static DataArrayIdType *MakePartition(const std::vector<const ARRAY *>& groups, mcIdType newNb, std::vector< std::vector<mcIdType> >& fidsOfGroups);
126 static ARRAY *BuildUnion(const std::vector<const ARRAY *>& arr);
127 static ARRAY *BuildIntersection(const std::vector<const ARRAY *>& arr);
128 static DataArrayIdType *FindPermutationFromFirstToSecond(const ARRAY *ids1, const ARRAY *ids2);
129 DataArrayIdType *buildComplement(mcIdType nbOfElement) const;
130 ARRAY *buildSubstraction(const ARRAY *other) const;
131 ARRAY *buildSubstractionOptimized(const ARRAY *other) const;
132 ARRAY *buildUnion(const ARRAY *other) const;
133 ARRAY *buildIntersection(const ARRAY *other) const;
134 ARRAY *buildUnique() const;
135 ARRAY *buildUniqueNotSorted() const;
136 ARRAY *deltaShiftIndex() const;
137 void computeOffsets();
138 void computeOffsetsFull();
139 ARRAY *buildExplicitArrByRanges(const ARRAY *offsets) const;
140 DataArrayIdType *findRangeIdForEachTuple(const ARRAY *ranges) const;
141 ARRAY *findIdInRangeForEachTuple(const ARRAY *ranges) const;
142 void sortEachPairToMakeALinkedList();
143 ARRAY *duplicateEachTupleNTimes(mcIdType nbTimes) const;
144 ARRAY *getDifferentValues() const;
145 static ARRAY *Add(const ARRAY *a1, const ARRAY *a2);
146 void addEqual(const ARRAY *other);
147 static ARRAY *Substract(const ARRAY *a1, const ARRAY *a2);
148 void substractEqual(const ARRAY *other);
149 static ARRAY *Multiply(const ARRAY *a1, const ARRAY *a2);
150 void multiplyEqual(const ARRAY *other);
151 static ARRAY *Divide(const ARRAY *a1, const ARRAY *a2);
152 void divideEqual(const ARRAY *other);
153 static ARRAY *Modulus(const ARRAY *a1, const ARRAY *a2);
154 void modulusEqual(const ARRAY *other);
155 static ARRAY *Pow(const ARRAY *a1, const ARRAY *a2);
156 void powEqual(const ARRAY *other);
157 MCAuto<ARRAY> fromLinkedListOfPairToList() const;
158 MCAuto<DataArrayIdType> findIdsGreaterOrEqualTo(INT val) const;
159 MCAuto<DataArrayIdType> findIdsGreaterThan(INT val) const;
160 MCAuto<DataArrayIdType> findIdsLowerOrEqualTo(INT val) const;
161 MCAuto<DataArrayIdType> findIdsLowerThan(INT val) const;
162 MCAuto<ARRAY> selectPartDef(const PartDefinition* pd) const;
163 MCAuto<DataArrayDouble> convertToDblArr() const;
164 MCAuto<DataArrayFloat> convertToFloatArr() const;
166 static ARRAY *Range(INT begin, INT end, INT step);
174 static ARRAY *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
176 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)";
177 std::string msg(msgBase);
178 if ( MEDCouplingHasNumPyBindings() )
179 msg+="\n-ARRAY.New(numpy array with dtype=int32)";
182 if(PyList_Check(elt0) || PyTuple_Check(elt0))
186 if(PyInt_Check(nbOfTuples))
188 mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples));
190 throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive set of allocated memory !");
193 if(PyInt_Check(nbOfComp))
194 {//ARRAY.New([1,3,4,5],2,2)
195 mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp));
197 throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive number of components !");
198 MCAuto<ARRAY> ret=ARRAY::New();
199 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(elt0,nbOfTuples1,nbOfCompo);
200 ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
204 throw INTERP_KERNEL::Exception(msg.c_str());
207 {//ARRAY.New([1,3,4],3)
208 MCAuto<ARRAY> ret=ARRAY::New();
210 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(elt0,nbOfTuples1,tmpp1);
211 ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
216 throw INTERP_KERNEL::Exception(msg.c_str());
219 {// ARRAY.New([1,3,4])
220 MCAuto<ARRAY> ret=ARRAY::New();
221 mcIdType tmpp1=-1,tmpp2=-1;
222 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(elt0,tmpp1,tmpp2);
223 ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
227 else if(PyInt_Check(elt0))
229 INT nbOfTuples1=(INT)PyInt_AS_LONG(elt0);
231 throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive set of allocated memory !");
236 if(PyInt_Check(nbOfTuples))
238 INT nbOfCompo=(INT)PyInt_AS_LONG(nbOfTuples);
240 throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive number of components !");
241 MCAuto<ARRAY> ret=ARRAY::New();
242 ret->alloc(nbOfTuples1,nbOfCompo);
246 throw INTERP_KERNEL::Exception(msg.c_str());
249 throw INTERP_KERNEL::Exception(msg.c_str());
253 MCAuto<ARRAY> ret=ARRAY::New();
254 ret->alloc(nbOfTuples1,1);
258 else if(MEDCouplingHasNumPyBindings() && PyArray_Check(elt0) && nbOfTuples==NULL && nbOfComp==NULL)
259 {//ARRAY.New(numpyArray)
260 return BuildNewInstance<ARRAY,INT>(elt0,NPYTraits<INT>::NPYObjectType,NPYTraits<INT>::NPYFunc,MEDCoupling::Traits<INT>::NPYStr);
263 throw INTERP_KERNEL::Exception(msg.c_str());
264 throw INTERP_KERNEL::Exception(msg.c_str());//to make g++ happy
267 ARRAY(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
269 return MEDCoupling_ ## ARRAY ## _New__SWIG_1(elt0,nbOfTuples,nbOfComp);
272 std::string __str__() const
274 return self->reprNotTooLong();
277 mcIdType __len__() const
279 if(self->isAllocated())
281 return self->getNumberOfTuples();
285 throw INTERP_KERNEL::Exception("ARRAY::__len__ : Instance is NOT allocated !");
291 return self->intValue();
294 ARRAY ## Iterator *__iter__()
296 return self->iterator();
299 PyObject *accumulate() const
301 mcIdType sz=ToIdType(self->getNumberOfComponents());
302 INTERP_KERNEL::AutoPtr<INT> tmp=new INT[sz];
303 self->accumulate((INT *)tmp);
304 return convertIntArrToPyList((const INT *)tmp,sz);
307 ARRAY *accumulatePerChunck(PyObject *indexArr) const
310 std::vector<mcIdType> val2;
311 const mcIdType *bg=convertIntStarLikePyObjToCppIntStar(indexArr,sw,sz,val,val2);
312 return self->accumulatePerChunck(bg,bg+sz);
315 DataArrayIdType *findIdsEqualTuple(PyObject *inputTuple) const
319 std::vector<INT> val2;
320 const INT *bg(convertIntStarLikePyObjToCppIntStar(inputTuple,sw,sz,val,val2));
321 return self->findIdsEqualTuple(bg,bg+sz);
324 DataArrayIdType *findIdForEach(PyObject *vals) const
328 std::vector<INT> val2;
329 const INT *bg(convertIntStarLikePyObjToCppIntStar(vals,sw,sz,val,val2));
330 MCAuto<DataArrayIdType> ret(self->findIdForEach(bg,bg+sz));
334 PyObject *splitInBalancedSlices(mcIdType nbOfSlices) const
336 std::vector< std::pair<mcIdType,mcIdType> > slcs(self->splitInBalancedSlices(nbOfSlices));
337 PyObject *ret=PyList_New(slcs.size());
338 for(std::size_t i=0;i<slcs.size();i++)
339 PyList_SetItem(ret,i,PySlice_New(PyInt_FromLong(slcs[i].first),PyInt_FromLong(slcs[i].second),PyInt_FromLong(1)));
343 ARRAY *buildExplicitArrOfSliceOnScaledArr(PyObject *slic) const
345 if(!PySlice_Check(slic))
346 throw INTERP_KERNEL::Exception("ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : expecting a pyslice as second (first) parameter !");
347 Py_ssize_t strt=2,stp=2,step=2;
348 GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !");
349 if(strt==std::numeric_limits<INT>::max() || stp==std::numeric_limits<INT>::max())
350 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 !");
351 return self->buildExplicitArrOfSliceOnScaledArr((INT)strt,(INT)stp,(INT)step);
354 PyObject *getMinMaxValues() const
357 self->getMinMaxValues(a,b);
358 PyObject *ret=PyTuple_New(2);
359 PyTuple_SetItem(ret,0,PyInt_FromLong(a));
360 PyTuple_SetItem(ret,1,PyInt_FromLong(b));
364 static PyObject *ConvertIndexArrayToO2N(mcIdType nbOfOldTuples, PyObject *arr, PyObject *arrI)
366 mcIdType newNbOfTuples=-1;
367 mcIdType szArr,szArrI,sw,iTypppArr,iTypppArrI;
368 std::vector<mcIdType> stdvecTyyppArr;
369 std::vector<mcIdType> stdvecTyyppArrI;
370 const mcIdType *arrPtr=convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr);
371 const mcIdType *arrIPtr=convertIntStarLikePyObjToCppIntStar(arrI,sw,szArrI,iTypppArrI,stdvecTyyppArrI);
372 DataArrayIdType *ret0=MEDCoupling::ARRAY::ConvertIndexArrayToO2N(nbOfOldTuples,arrPtr,arrIPtr,arrIPtr+szArrI,newNbOfTuples);
373 PyObject *ret=PyTuple_New(2);
374 PyTuple_SetItem(ret,0,SWIG_NewPointerObj((void*)ret0,SWIGTITraits<mcIdType>::TI,SWIG_POINTER_OWN | 0));
375 PyTuple_SetItem(ret,1,PyInt_FromLong(newNbOfTuples));
379 static DataArrayIdType *CheckAndPreparePermutation(PyObject *arr)
381 MCAuto<DataArrayIdType> ret(DataArrayIdType::New());
384 std::vector<INT> stdvecTyyppArr;
385 const INT *arrPtr(convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr));
386 mcIdType *pt(MEDCoupling::ARRAY::CheckAndPreparePermutation(arrPtr,arrPtr+szArr));
387 ret->useArray(pt,true,MEDCoupling::DeallocType::C_DEALLOC,szArr,1);
391 void setValues(PyObject *li, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
393 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 !";
394 if(PyList_Check(li) || PyTuple_Check(li))
396 if(nbOfTuples && nbOfTuples != Py_None)
398 if(PyInt_Check(nbOfTuples))
400 mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples));
402 throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive set of allocated memory !");
403 if(nbOfComp && nbOfComp != Py_None)
405 if(PyInt_Check(nbOfComp))
406 {//ARRAY.setValues([1,3,4,5],2,2)
407 mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp));
409 throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive number of components !");
410 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,nbOfTuples1,nbOfCompo);
411 self->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),self->getPointer());
414 throw INTERP_KERNEL::Exception(msg);
417 {//ARRAY.setValues([1,3,4],3)
419 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,nbOfTuples1,tmpp1);
420 self->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),self->getPointer());
424 throw INTERP_KERNEL::Exception(msg);
427 {// ARRAY.setValues([1,3,4])
428 mcIdType tmpp1=-1,tmpp2=-1;
429 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,tmpp1,tmpp2);
430 self->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),self->getPointer());
434 throw INTERP_KERNEL::Exception(msg);
437 PyObject *getValues() const
439 const INT *vals=self->getConstPointer();
440 return convertIntArrToPyList(vals,self->getNbOfElems());
443 PyObject *isEqualIfNotWhy(const ARRAY& other) const
446 bool ret0=self->isEqualIfNotWhy(other,ret1);
447 PyObject *ret=PyTuple_New(2);
448 PyObject *ret0Py=ret0?Py_True:Py_False;
450 PyTuple_SetItem(ret,0,ret0Py);
451 PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str()));
455 PyObject *getValuesAsTuple() const
457 const INT *vals=self->getConstPointer();
458 mcIdType nbOfComp=ToIdType(self->getNumberOfComponents());
459 mcIdType nbOfTuples=self->getNumberOfTuples();
460 return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
463 static PyObject *MakePartition(PyObject *gps, mcIdType newNb)
465 std::vector<const ARRAY *> groups;
466 std::vector< std::vector<mcIdType> > fidsOfGroups;
467 convertFromPyObjVectorOfObj(gps,SWIGTITraits<INT>::TI,"ARRAY",groups);
468 DataArrayIdType *ret0=MEDCoupling::ARRAY::MakePartition(groups,newNb,fidsOfGroups);
469 PyObject *ret = PyList_New(2);
470 PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
471 std::size_t sz=fidsOfGroups.size();
472 PyObject *ret1 = PyList_New(sz);
473 for(std::size_t i=0;i<sz;i++)
474 PyList_SetItem(ret1,i,convertIntArrToPyList2(fidsOfGroups[i]));
475 PyList_SetItem(ret,1,ret1);
479 DataArrayIdType *findIdsEqualList(PyObject *obj)
483 std::vector<INT> multiVal;
484 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
486 convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
490 return self->findIdsEqualList(&singleVal,&singleVal+1);
492 return self->findIdsEqualList(&multiVal[0],&multiVal[0]+multiVal.size());
494 return self->findIdsEqualList(daIntTyypp->begin(),daIntTyypp->end());
496 throw INTERP_KERNEL::Exception("ARRAY::findIdsEqualList : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
500 DataArrayIdType *findIdsNotEqualList(PyObject *obj)
504 std::vector<INT> multiVal;
505 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
507 convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
511 return self->findIdsNotEqualList(&singleVal,&singleVal+1);
513 return self->findIdsNotEqualList(&multiVal[0],&multiVal[0]+multiVal.size());
515 return self->findIdsNotEqualList(daIntTyypp->begin(),daIntTyypp->end());
517 throw INTERP_KERNEL::Exception("ARRAY::findIdsNotEqualList : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
521 PyObject *splitByValueRange(PyObject *li) const
523 ARRAY *ret0=0,*ret1=0,*ret2=0;
525 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<INT>::TI, 0 | 0 );
526 if (!SWIG_IsOK(res1))
529 INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
530 self->splitByValueRange(tmp,(INT *)tmp+size,ret0,ret1,ret2);
534 ARRAY *da2=reinterpret_cast< ARRAY * >(da);
536 throw INTERP_KERNEL::Exception("Not null ARRAY instance expected !");
537 da2->checkAllocated();
538 self->splitByValueRange(da2->begin(),da2->end(),ret0,ret1,ret2);
540 PyObject *ret = PyList_New(3);
541 PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
542 PyList_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
543 PyList_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(ret2),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
547 DataArrayIdType *transformWithIndArrR(PyObject *li) const
550 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<INT>::TI, 0 | 0 );
551 if (!SWIG_IsOK(res1))
554 INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
555 return self->transformWithIndArrR(tmp,tmp+size);
559 ARRAY *da2=reinterpret_cast< ARRAY * >(da);
560 return self->transformWithIndArrR(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
564 ARRAY *renumberAndReduce(PyObject *li, mcIdType newNbOfTuple)
567 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 | 0 );
568 if (!SWIG_IsOK(res1))
571 INTERP_KERNEL::AutoPtr<mcIdType> tmp=convertPyToNewIntArr2(li,&size);
572 if(size!=self->getNumberOfTuples())
574 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
576 return self->renumberAndReduce(tmp,newNbOfTuple);
580 DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da);
582 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
583 da2->checkAllocated();
584 mcIdType size=self->getNumberOfTuples();
585 if(size!=self->getNumberOfTuples())
587 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
589 return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple);
593 ARRAY *renumber(PyObject *li)
596 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 | 0 );
597 if (!SWIG_IsOK(res1))
600 INTERP_KERNEL::AutoPtr<mcIdType> tmp=convertPyToNewIntArr2(li,&size);
601 if(size!=self->getNumberOfTuples())
603 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
605 return self->renumber(tmp);
609 DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da);
611 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
612 da2->checkAllocated();
613 mcIdType size=self->getNumberOfTuples();
614 if(size!=self->getNumberOfTuples())
616 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
618 return self->renumber(da2->getConstPointer());
622 ARRAY *renumberR(PyObject *li)
625 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 | 0 );
626 if (!SWIG_IsOK(res1))
629 INTERP_KERNEL::AutoPtr<mcIdType> tmp=convertPyToNewIntArr2(li,&size);
630 if(size!=self->getNumberOfTuples())
632 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
634 return self->renumberR(tmp);
638 DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da);
640 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
641 da2->checkAllocated();
642 mcIdType size=self->getNumberOfTuples();
643 if(size!=self->getNumberOfTuples())
645 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
647 return self->renumberR(da2->getConstPointer());
651 void setSelectedComponents(const ARRAY *a, PyObject *li)
653 std::vector<std::size_t> tmp;
654 convertPyToNewIntArr3(li,tmp);
655 self->setSelectedComponents(a,tmp);
658 PyObject *explodeComponents() const
660 std::vector< MCAuto<ARRAY> > retCpp(self->explodeComponents());
661 std::size_t sz(retCpp.size());
662 PyObject *res(PyList_New(sz));
663 for(std::size_t i=0;i<sz;i++)
664 PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(retCpp[i].retn()),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
668 PyObject *getTuple(mcIdType tupleId)
670 mcIdType sz=ToIdType(self->getNumberOfComponents());
671 INTERP_KERNEL::AutoPtr<INT> tmp=new INT[sz];
672 self->getTuple(tupleId,tmp);
673 return convertIntArrToPyList((const INT*)tmp,sz);
676 PyObject *changeSurjectiveFormat(INT targetNb) const
678 DataArrayIdType *arr=0;
679 DataArrayIdType *arrI=0;
680 self->changeSurjectiveFormat(targetNb,arr,arrI);
681 PyObject *res = PyList_New(2);
682 PyList_SetItem(res,0,SWIG_NewPointerObj((void*)arr,SWIGTITraits<mcIdType>::TI,SWIG_POINTER_OWN | 0));
683 PyList_SetItem(res,1,SWIG_NewPointerObj((void*)arrI,SWIGTITraits<mcIdType>::TI,SWIG_POINTER_OWN | 0));
687 static ARRAY *Meld(PyObject *li)
689 std::vector<const ARRAY *> tmp;
690 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
691 return ARRAY::Meld(tmp);
694 static ARRAY *Aggregate(PyObject *li)
696 std::vector<const ARRAY *> tmp;
697 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
698 return ARRAY::Aggregate(tmp);
701 static ARRAY *AggregateIndexes(PyObject *li)
703 std::vector<const ARRAY *> tmp;
704 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
705 return ARRAY::AggregateIndexes(tmp);
708 static ARRAY *BuildUnion(PyObject *li)
710 std::vector<const ARRAY *> tmp;
711 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
712 return ARRAY::BuildUnion(tmp);
715 static ARRAY *BuildIntersection(PyObject *li)
717 std::vector<const ARRAY *> tmp;
718 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
719 return ARRAY::BuildIntersection(tmp);
722 PyObject *getMaxValue() const
725 INT r1=self->getMaxValue(tmp);
726 PyObject *ret=PyTuple_New(2);
727 PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
728 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
732 PyObject *getMaxAbsValue(std::size_t& tupleId) const
735 INT r1=self->getMaxAbsValue(tmp);
736 PyObject *ret=PyTuple_New(2);
737 PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
738 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
742 PyObject *getMinValue() const
745 INT r1=self->getMinValue(tmp);
746 PyObject *ret=PyTuple_New(2);
747 PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
748 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
752 mcIdType index(PyObject *obj) const
754 std::size_t nbOfCompo=self->getNumberOfComponents();
761 INT val=(INT)PyInt_AS_LONG(obj);
762 return self->findIdFirstEqual(val);
765 throw INTERP_KERNEL::Exception("ARRAY::index : 'this' contains one component and trying to find an element which is not an integer !");
769 std::vector<INT> arr;
770 convertPyToNewIntArr3(obj,arr);
771 return self->findIdFirstEqualTuple(arr);
776 bool __contains__(PyObject *obj) const
778 std::size_t nbOfCompo=self->getNumberOfComponents();
787 INT val=(INT)PyInt_AS_LONG(obj);
788 return self->presenceOfValue(val);
791 throw INTERP_KERNEL::Exception("ARRAY::__contains__ : 'this' contains one component and trying to find an element which is not an integer !");
795 std::vector<INT> arr;
796 convertPyToNewIntArr3(obj,arr);
797 return self->presenceOfTuple(arr);
802 PyObject *__getitem__(PyObject *obj)
804 const char msg[]="Unexpected situation in ARRAY::__getitem__ !";
805 const char msg2[]="ARRAY::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
806 self->checkAllocated();
807 mcIdType nbOfTuples=self->getNumberOfTuples();
808 std::size_t nbOfComponents=self->getNumberOfComponents();
811 std::vector<mcIdType> vt1;
812 std::vector<std::size_t> vc1;
813 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > pt1,pc1;
814 DataArrayIdType *dt1=0,*dc1=0;
816 convertObjToPossibleCpp3(obj,nbOfTuples,(int)nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
822 if(nbOfComponents==1)
823 return PyInt_FromLong(self->getIJSafe(it1,0));
824 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&it1,&it1+1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
827 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size())),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
829 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
831 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems())),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
833 return PyInt_FromLong(self->getIJSafe(it1,ic1));
836 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
837 std::vector<std::size_t> v2(1,ic1);
838 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
842 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
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->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
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(&it1,&it1+1);
855 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
859 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
860 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
864 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
865 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
869 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
870 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
874 ret=self->selectByTupleIdSafe(&it1,&it1+1);
875 mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
876 std::vector<std::size_t> v2(nbOfComp);
877 for(INT i=0;i<nbOfComp;i++)
878 v2[i]=pc1.first+i*pc1.second.second;
879 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
883 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
884 mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
885 std::vector<std::size_t> v2(nbOfComp);
886 for(INT i=0;i<nbOfComp;i++)
887 v2[i]=pc1.first+i*pc1.second.second;
888 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
892 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
893 mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
894 std::vector<std::size_t> v2(nbOfComp);
895 for(mcIdType i=0;i<nbOfComp;i++)
896 v2[i]=pc1.first+i*pc1.second.second;
897 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
901 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
902 mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
903 std::vector<std::size_t> v2(nbOfComp);
904 for(INT i=0;i<nbOfComp;i++)
905 v2[i]=pc1.first+i*pc1.second.second;
906 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
909 throw INTERP_KERNEL::Exception(msg);
913 ARRAY *__setitem__(PyObject *obj, PyObject *value)
915 self->checkAllocated();
916 const char msg[]="Unexpected situation in __setitem__ !";
917 mcIdType nbOfTuples=self->getNumberOfTuples();
918 int nbOfComponents=(int)self->getNumberOfComponents();
923 ARRAY ## Tuple *dd1=0;
924 convertIntStarLikePyObjToCpp(value,sw1,i1,v1,d1,dd1);
926 std::vector<mcIdType> vt1,vc1;
927 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > pt1,pc1;
928 DataArrayIdType *dt1=0,*dc1=0;
929 convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
938 self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
942 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
943 self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
946 self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1);
949 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
950 self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1);
953 throw INTERP_KERNEL::Exception(msg);
962 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
966 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
967 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
970 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
973 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
974 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
977 throw INTERP_KERNEL::Exception(msg);
986 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
990 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
991 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
994 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
997 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
998 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
1001 throw INTERP_KERNEL::Exception(msg);
1010 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
1014 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1015 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
1018 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
1021 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1022 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
1025 throw INTERP_KERNEL::Exception(msg);
1034 self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
1038 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1039 self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
1042 self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1);
1045 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1046 self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1);
1049 throw INTERP_KERNEL::Exception(msg);
1058 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
1062 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1063 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
1066 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
1069 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1070 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
1073 throw INTERP_KERNEL::Exception(msg);
1082 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
1086 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1087 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
1090 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
1093 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1094 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
1097 throw INTERP_KERNEL::Exception(msg);
1106 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
1110 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1111 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
1114 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
1117 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1118 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
1121 throw INTERP_KERNEL::Exception(msg);
1130 self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
1134 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1135 self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
1138 self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
1141 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1142 self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
1145 throw INTERP_KERNEL::Exception(msg);
1154 self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
1158 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1159 self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
1162 self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
1165 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1166 self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
1169 throw INTERP_KERNEL::Exception(msg);
1178 self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
1182 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1183 self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size(),false);
1186 self->setPartOfValues4(d1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
1189 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1190 self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
1193 throw INTERP_KERNEL::Exception(msg);
1202 self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
1206 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1207 self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
1210 self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
1213 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1214 self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
1217 throw INTERP_KERNEL::Exception(msg);
1226 self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
1230 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1231 self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
1234 self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
1237 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1238 self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
1241 throw INTERP_KERNEL::Exception(msg);
1250 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
1254 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1255 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false);
1258 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
1261 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1262 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
1265 throw INTERP_KERNEL::Exception(msg);
1274 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
1278 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1279 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false);
1282 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
1285 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1286 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
1289 throw INTERP_KERNEL::Exception(msg);
1298 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
1302 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1303 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false);
1306 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
1309 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1310 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
1313 throw INTERP_KERNEL::Exception(msg);
1318 throw INTERP_KERNEL::Exception(msg);
1323 ARRAY *__neg__() const
1325 return self->negate();
1328 ARRAY *__add__(PyObject *obj)
1330 const char msg[]="Unexpected situation in __add__ !";
1333 std::vector<INT> aa;
1334 ARRAY ## Tuple *aaa;
1336 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1341 MCAuto<ARRAY> ret=self->deepCopy();
1342 ret->applyLin(1,val);
1347 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1348 return ARRAY::Add(self,aaaa);
1352 return ARRAY::Add(self,a);
1356 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1357 return ARRAY::Add(self,aaaa);
1360 throw INTERP_KERNEL::Exception(msg);
1364 ARRAY *__radd__(PyObject *obj)
1366 const char msg[]="Unexpected situation in __radd__ !";
1369 std::vector<INT> aa;
1370 ARRAY ## Tuple *aaa;
1372 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1377 MCAuto<ARRAY> ret=self->deepCopy();
1378 ret->applyLin(1,val);
1383 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1384 return ARRAY::Add(self,aaaa);
1388 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1389 return ARRAY::Add(self,aaaa);
1392 throw INTERP_KERNEL::Exception(msg);
1396 PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
1398 const char msg[]="Unexpected situation in __iadd__ !";
1401 std::vector<INT> aa;
1402 ARRAY ## Tuple *aaa;
1404 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1409 self->applyLin(1,val);
1410 Py_XINCREF(trueSelf);
1415 MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1417 Py_XINCREF(trueSelf);
1423 Py_XINCREF(trueSelf);
1428 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1429 self->addEqual(aaaa);
1430 Py_XINCREF(trueSelf);
1434 throw INTERP_KERNEL::Exception(msg);
1438 ARRAY *__sub__(PyObject *obj)
1440 const char msg[]="Unexpected situation in __sub__ !";
1443 std::vector<INT> aa;
1444 ARRAY ## Tuple *aaa;
1446 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1451 MCAuto<ARRAY> ret=self->deepCopy();
1452 ret->applyLin(1,-val);
1457 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1458 return ARRAY::Substract(self,aaaa);
1462 return ARRAY::Substract(self,a);
1466 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1467 return ARRAY::Substract(self,aaaa);
1470 throw INTERP_KERNEL::Exception(msg);
1474 ARRAY *__rsub__(PyObject *obj)
1476 const char msg[]="Unexpected situation in __rsub__ !";
1479 std::vector<INT> aa;
1480 ARRAY ## Tuple *aaa;
1482 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1487 MCAuto<ARRAY> ret=self->deepCopy();
1488 ret->applyLin(-1,val);
1493 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1494 return ARRAY::Substract(aaaa,self);
1498 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1499 return ARRAY::Substract(aaaa,self);
1502 throw INTERP_KERNEL::Exception(msg);
1506 PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
1508 const char msg[]="Unexpected situation in __isub__ !";
1511 std::vector<INT> aa;
1512 ARRAY ## Tuple *aaa;
1514 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1519 self->applyLin(1,-val);
1520 Py_XINCREF(trueSelf);
1525 MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1526 self->substractEqual(bb);
1527 Py_XINCREF(trueSelf);
1532 self->substractEqual(a);
1533 Py_XINCREF(trueSelf);
1538 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1539 self->substractEqual(aaaa);
1540 Py_XINCREF(trueSelf);
1544 throw INTERP_KERNEL::Exception(msg);
1548 ARRAY *__mul__(PyObject *obj)
1550 const char msg[]="Unexpected situation in __mul__ !";
1553 std::vector<INT> aa;
1554 ARRAY ## Tuple *aaa;
1556 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1561 MCAuto<ARRAY> ret=self->deepCopy();
1562 ret->applyLin(val,0);
1567 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1568 return ARRAY::Multiply(self,aaaa);
1572 return ARRAY::Multiply(self,a);
1576 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1577 return ARRAY::Multiply(self,aaaa);
1580 throw INTERP_KERNEL::Exception(msg);
1584 ARRAY *__rmul__(PyObject *obj)
1586 const char msg[]="Unexpected situation in __rmul__ !";
1589 std::vector<INT> aa;
1590 ARRAY ## Tuple *aaa;
1592 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1597 MCAuto<ARRAY> ret=self->deepCopy();
1598 ret->applyLin(val,0);
1603 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1604 return ARRAY::Multiply(self,aaaa);
1608 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1609 return ARRAY::Multiply(self,aaaa);
1612 throw INTERP_KERNEL::Exception(msg);
1616 PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
1618 const char msg[]="Unexpected situation in __imul__ !";
1621 std::vector<INT> aa;
1622 ARRAY ## Tuple *aaa;
1624 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1629 self->applyLin(val,0);
1630 Py_XINCREF(trueSelf);
1635 MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1636 self->multiplyEqual(bb);
1637 Py_XINCREF(trueSelf);
1642 self->multiplyEqual(a);
1643 Py_XINCREF(trueSelf);
1648 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1649 self->multiplyEqual(aaaa);
1650 Py_XINCREF(trueSelf);
1654 throw INTERP_KERNEL::Exception(msg);
1658 ARRAY *__div__(PyObject *obj)
1660 const char msg[]="Unexpected situation in __div__ !";
1663 std::vector<INT> aa;
1664 ARRAY ## Tuple *aaa;
1666 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1671 MCAuto<ARRAY> ret=self->deepCopy();
1672 ret->applyDivideBy(val);
1677 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1678 return ARRAY::Divide(self,aaaa);
1682 return ARRAY::Divide(self,a);
1686 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1687 return ARRAY::Divide(self,aaaa);
1690 throw INTERP_KERNEL::Exception(msg);
1694 ARRAY *__rdiv__(PyObject *obj)
1696 const char msg[]="Unexpected situation in __rdiv__ !";
1699 std::vector<INT> aa;
1700 ARRAY ## Tuple *aaa;
1702 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1707 MCAuto<ARRAY> ret=self->deepCopy();
1713 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1714 return ARRAY::Divide(aaaa,self);
1718 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1719 return ARRAY::Divide(aaaa,self);
1722 throw INTERP_KERNEL::Exception(msg);
1726 PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
1728 const char msg[]="Unexpected situation in __idiv__ !";
1731 std::vector<INT> aa;
1732 ARRAY ## Tuple *aaa;
1734 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1739 self->applyDivideBy(val);
1740 Py_XINCREF(trueSelf);
1745 MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1746 self->divideEqual(bb);
1747 Py_XINCREF(trueSelf);
1752 self->divideEqual(a);
1753 Py_XINCREF(trueSelf);
1758 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1759 self->divideEqual(aaaa);
1760 Py_XINCREF(trueSelf);
1764 throw INTERP_KERNEL::Exception(msg);
1768 ARRAY *__mod__(PyObject *obj)
1770 const char msg[]="Unexpected situation in __mod__ !";
1773 std::vector<INT> aa;
1774 ARRAY ## Tuple *aaa;
1776 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1781 MCAuto<ARRAY> ret=self->deepCopy();
1782 ret->applyModulus(val);
1787 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1788 return ARRAY::Modulus(self,aaaa);
1792 return ARRAY::Modulus(self,a);
1796 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1797 return ARRAY::Modulus(self,aaaa);
1800 throw INTERP_KERNEL::Exception(msg);
1804 ARRAY *__rmod__(PyObject *obj)
1806 const char msg[]="Unexpected situation in __rmod__ !";
1809 std::vector<INT> aa;
1810 ARRAY ## Tuple *aaa;
1812 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1817 MCAuto<ARRAY> ret=self->deepCopy();
1818 ret->applyRModulus(val);
1823 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1824 return ARRAY::Modulus(aaaa,self);
1828 return ARRAY::Modulus(a,self);
1832 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1833 return ARRAY::Modulus(aaaa,self);
1836 throw INTERP_KERNEL::Exception(msg);
1840 PyObject *___imod___(PyObject *trueSelf, PyObject *obj)
1842 const char msg[]="Unexpected situation in __imod__ !";
1845 std::vector<INT> aa;
1846 ARRAY ## Tuple *aaa;
1848 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1853 self->applyModulus(val);
1854 Py_XINCREF(trueSelf);
1859 self->modulusEqual(a);
1860 Py_XINCREF(trueSelf);
1865 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1866 self->modulusEqual(aaaa);
1867 Py_XINCREF(trueSelf);
1871 throw INTERP_KERNEL::Exception(msg);
1875 ARRAY *__pow__(PyObject *obj)
1877 const char msg[]="Unexpected situation in __pow__ !";
1880 std::vector<INT> aa;
1881 ARRAY ## Tuple *aaa;
1883 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1888 MCAuto<ARRAY> ret=self->deepCopy();
1894 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1895 return ARRAY::Pow(self,aaaa);
1899 return ARRAY::Pow(self,a);
1903 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1904 return ARRAY::Pow(self,aaaa);
1907 throw INTERP_KERNEL::Exception(msg);
1911 ARRAY *__rpow__(PyObject *obj)
1913 const char msg[]="Unexpected situation in __rpow__ !";
1916 std::vector<INT> aa;
1917 ARRAY ## Tuple *aaa;
1919 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1924 MCAuto<ARRAY> ret=self->deepCopy();
1925 ret->applyRPow(val);
1930 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1931 return ARRAY::Pow(aaaa,self);
1935 return ARRAY::Pow(a,self);
1939 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1940 return ARRAY::Pow(aaaa,self);
1943 throw INTERP_KERNEL::Exception(msg);
1947 PyObject *___ipow___(PyObject *trueSelf, PyObject *obj)
1949 const char msg[]="Unexpected situation in __ipow__ !";
1952 std::vector<INT> aa;
1953 ARRAY ## Tuple *aaa;
1955 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1960 self->applyPow(val);
1961 Py_XINCREF(trueSelf);
1967 Py_XINCREF(trueSelf);
1972 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1973 self->powEqual(aaaa);
1974 Py_XINCREF(trueSelf);
1978 throw INTERP_KERNEL::Exception(msg);
1982 std::string __repr__() const
1984 std::ostringstream oss;
1985 self->reprQuickOverview(oss);
1989 void pushBackValsSilent(PyObject *li)
1993 std::vector<INT> stdvecTyyppArr;
1994 const INT *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr);
1995 self->pushBackValsSilent(tmp,tmp+szArr);
1998 PyObject *partitionByDifferentValues() const
2000 std::vector<INT> ret1;
2001 std::vector<DataArrayIdType *> ret0=self->partitionByDifferentValues(ret1);
2002 std::size_t sz=ret0.size();
2003 PyObject *pyRet=PyTuple_New(2);
2004 PyObject *pyRet0=PyList_New((INT)sz);
2005 PyObject *pyRet1=PyList_New((INT)sz);
2006 for(std::size_t i=0;i<sz;i++)
2008 PyList_SetItem(pyRet0,i,SWIG_NewPointerObj(SWIG_as_voidptr(ret0[i]),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2009 PyList_SetItem(pyRet1,i,PyInt_FromLong(ret1[i]));
2011 PyTuple_SetItem(pyRet,0,pyRet0);
2012 PyTuple_SetItem(pyRet,1,pyRet1);
2016 PyObject *findIdsRangesInListOfIds(const ARRAY *listOfIds) const
2018 DataArrayIdType *ret0=0;
2020 self->findIdsRangesInListOfIds(listOfIds,ret0,ret1);
2021 PyObject *pyRet=PyTuple_New(2);
2022 PyTuple_SetItem(pyRet,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2023 PyTuple_SetItem(pyRet,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
2027 PyObject *isRange() const
2030 bool ret(self->isRange(a,b,c));
2031 PyObject *pyRet=PyTuple_New(2);
2032 PyObject *ret0Py=ret?Py_True:Py_False,*ret1Py(0);
2034 PyTuple_SetItem(pyRet,0,ret0Py);
2036 ret1Py=PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(c));
2042 PyTuple_SetItem(pyRet,1,ret1Py);
2046 static bool RemoveIdsFromIndexedArrays(PyObject *li, ARRAY *arr, DataArrayIdType *arrIndx, mcIdType offsetForRemoval=0) throw(INTERP_KERNEL::Exception)
2050 std::vector<INT> multiVal;
2051 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2052 MEDCoupling::ARRAY *daIntTyypp=0;
2054 throw INTERP_KERNEL::Exception("ARRAY::RemoveIdsFromIndexedArrays : null pointer as arrIndex !");
2055 convertIntStarOrSliceLikePyObjToCpp(li,arrIndx->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2059 return ARRAY::RemoveIdsFromIndexedArrays(&singleVal,&singleVal+1,arr,arrIndx,offsetForRemoval);
2061 return ARRAY::RemoveIdsFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arr,arrIndx,offsetForRemoval);
2063 return ARRAY::RemoveIdsFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arr,arrIndx,offsetForRemoval);
2065 throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2069 static PyObject *ExtractFromIndexedArrays(PyObject *li, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
2072 DataArrayIdType *arrIndexOut=0;
2075 std::vector<mcIdType> multiVal;
2076 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2077 MEDCoupling::DataArrayIdType *daIntTyypp=0;
2079 throw INTERP_KERNEL::Exception("ARRAY::ExtractFromIndexedArrays : null pointer as arrIndxIn !");
2080 convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2085 ARRAY::ExtractFromIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,arrOut,arrIndexOut);
2090 ARRAY::ExtractFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,arrOut,arrIndexOut);
2095 ARRAY::ExtractFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,arrOut,arrIndexOut);
2099 throw INTERP_KERNEL::Exception("ARRAY::ExtractFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2101 PyObject *ret=PyTuple_New(2);
2102 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2103 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2107 static PyObject *ExtractFromIndexedArraysSlice(mcIdType strt, mcIdType stp, mcIdType step, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
2110 DataArrayIdType *arrIndexOut=0;
2111 ARRAY::ExtractFromIndexedArraysSlice(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut);
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(PyObject *slic, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
2120 if(!PySlice_Check(slic))
2121 throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : the first param is not a pyslice !");
2122 Py_ssize_t strt=2,stp=2,step=2;
2124 throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : last array is null !");
2125 arrIndxIn->checkAllocated();
2126 if(arrIndxIn->getNumberOfComponents()!=1)
2127 throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : number of components of last argument must be equal to one !");
2128 GetIndicesOfSlice(slic,arrIndxIn->getNumberOfTuples(),&strt,&stp,&step,"ExtractFromIndexedArraysSlice (wrap) : Invalid slice regarding nb of elements !");
2130 DataArrayIdType *arrIndexOut=0;
2131 ARRAY::ExtractFromIndexedArraysSlice(ToIdType(strt),ToIdType(stp),ToIdType(step),arrIn,arrIndxIn,arrOut,arrIndexOut);
2132 PyObject *ret=PyTuple_New(2);
2133 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2134 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2138 static PyObject *SetPartOfIndexedArrays(PyObject *li,
2139 const ARRAY *arrIn, const DataArrayIdType *arrIndxIn,
2140 const ARRAY *srcArr, const DataArrayIdType *srcArrIndex) throw(INTERP_KERNEL::Exception)
2143 DataArrayIdType *arrIndexOut=0;
2146 std::vector<mcIdType> multiVal;
2147 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2148 MEDCoupling::DataArrayIdType *daIntTyypp=0;
2150 throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArrays : null pointer as arrIndex !");
2151 convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2156 ARRAY::SetPartOfIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
2161 ARRAY::SetPartOfIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
2166 ARRAY::SetPartOfIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
2170 throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2172 PyObject *ret=PyTuple_New(2);
2173 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2174 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2178 static void SetPartOfIndexedArraysSameIdx(PyObject *li, ARRAY *arrIn, const DataArrayIdType *arrIndxIn,
2179 const ARRAY *srcArr, const DataArrayIdType *srcArrIndex) throw(INTERP_KERNEL::Exception)
2183 std::vector<mcIdType> multiVal;
2184 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2185 MEDCoupling::DataArrayIdType *daIntTyypp=0;
2187 throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArraysSameIdx : null pointer as arrIndex !");
2188 convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2193 ARRAY::SetPartOfIndexedArraysSameIdx(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex);
2198 ARRAY::SetPartOfIndexedArraysSameIdx(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex);
2203 ARRAY::SetPartOfIndexedArraysSameIdx(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex);
2207 throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArraysSameIdx : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2214 class ARRAY ## Tuple;
2216 class ARRAY ## Iterator
2219 ARRAY ## Iterator(ARRAY *da);
2220 ~ARRAY ## Iterator();
2225 ARRAY ## Tuple *ret=self->nextt();
2227 return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_MEDCoupling__ ## ARRAY ## Tuple,SWIG_POINTER_OWN | 0);
2230 PyErr_SetString(PyExc_StopIteration,"No more data.");
2237 class ARRAY ## Tuple
2240 std::size_t getNumberOfCompo() const;
2241 ARRAY *buildDAInt(INT nbOfTuples, INT nbOfCompo) const;
2244 std::string __str__() const
2246 return self->repr();
2251 return self->intValue();
2256 return self->buildDAInt(1,self->getNumberOfCompo());
2259 PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
2261 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2262 MEDCoupling_ ## ARRAY ## ____iadd___(ret,0,obj);
2263 Py_XINCREF(trueSelf);
2267 PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
2269 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2270 MEDCoupling_ ## ARRAY ## ____isub___(ret,0,obj);
2271 Py_XINCREF(trueSelf);
2275 PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
2277 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2278 MEDCoupling_ ## ARRAY ## ____imul___(ret,0,obj);
2279 Py_XINCREF(trueSelf);
2282 PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
2284 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2285 MEDCoupling_ ## ARRAY ## ____idiv___(ret,0,obj);
2286 Py_XINCREF(trueSelf);
2290 PyObject *___imod___(PyObject *trueSelf, PyObject *obj)
2292 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2293 MEDCoupling_ ## ARRAY ## ____imod___(ret,0,obj);
2294 Py_XINCREF(trueSelf);
2300 return PyInt_FromLong(self->getNumberOfCompo());
2303 PyObject *__getitem__(PyObject *obj)
2305 const char msg2[]="ARRAY ## Tuple::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
2308 std::vector<INT> multiVal;
2309 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2310 MEDCoupling::DataArrayIdType *daIntTyypp=0;
2311 const INT *pt=self->getConstPointer();
2312 INT nbc=(INT)self->getNumberOfCompo();
2313 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,ToIdType(nbc),sw,singleVal,multiVal,slic,daIntTyypp);
2318 if(singleVal>=(INT)nbc)
2320 std::ostringstream oss;
2321 oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
2322 PyErr_SetString(PyExc_StopIteration,oss.str().c_str());
2326 return PyInt_FromLong(pt[singleVal]);
2330 return PyInt_FromLong(pt[nbc+singleVal]);
2333 std::ostringstream oss;
2334 oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
2335 throw INTERP_KERNEL::Exception(oss.str().c_str());
2341 PyObject *t=PyTuple_New(multiVal.size());
2342 for(std::size_t j=0;j<multiVal.size();j++)
2344 INT cid=multiVal[j];
2347 std::ostringstream oss;
2348 oss << "Requesting for id #" << cid << " having only " << nbc << " components !";
2349 throw INTERP_KERNEL::Exception(oss.str().c_str());
2351 PyTuple_SetItem(t,j,PyInt_FromLong(pt[cid]));
2357 mcIdType sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
2358 PyObject *t=PyTuple_New(sz);
2359 for(INT j=0;j<sz;j++)
2360 PyTuple_SetItem(t,j,PyInt_FromLong(pt[slic.first+j*slic.second.second]));
2364 throw INTERP_KERNEL::Exception("ARRAY ## Tuple::__getitem__ : unrecognized type entered !");
2368 ARRAY ## Tuple *__setitem__(PyObject *obj, PyObject *value)
2370 const char msg[]="DataArrayIntTuple::__setitem__ : unrecognized type entered, int, slice, list<int>, tuple<int> !";
2371 const char msg2[]="DataArrayIntTuple::__setitem__ : Mismatch of slice values in 2nd parameter (components) !";
2373 mcIdType singleValV;
2374 std::vector<mcIdType> multiValV;
2375 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slicV;
2376 MEDCoupling::ARRAY ## Tuple *daIntTyyppV=0;
2377 mcIdType nbc=ToIdType(self->getNumberOfCompo());
2378 convertObjToPossibleCpp22<INT>(value,nbc,sw1,singleValV,multiValV,slicV,daIntTyyppV);
2380 std::vector<INT> multiVal;
2381 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2382 MEDCoupling::ARRAY *daIntTyypp=0;
2383 INT *pt=self->getPointer();
2384 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
2391 std::ostringstream oss;
2392 oss << "Requesting for setting id # " << singleVal << " having only " << nbc << " components !";
2393 throw INTERP_KERNEL::Exception(oss.str().c_str());
2399 pt[singleVal]=(INT)singleValV;
2404 if(multiValV.size()!=1)
2406 std::ostringstream oss;
2407 oss << "Requesting for setting id # " << singleVal << " with a list or tuple with size != 1 ! ";
2408 throw INTERP_KERNEL::Exception(oss.str().c_str());
2410 pt[singleVal]=(INT)multiValV[0];
2415 pt[singleVal]=daIntTyyppV->getConstPointer()[0];
2419 throw INTERP_KERNEL::Exception(msg);
2428 for(std::vector<INT>::const_iterator it=multiVal.begin();it!=multiVal.end();it++)
2432 std::ostringstream oss;
2433 oss << "Requesting for setting id # " << *it << " having only " << nbc << " components !";
2434 throw INTERP_KERNEL::Exception(oss.str().c_str());
2436 pt[*it]=(INT)singleValV;
2442 if(multiVal.size()!=multiValV.size())
2444 std::ostringstream oss;
2445 oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << multiVal.size() << " !";
2446 throw INTERP_KERNEL::Exception(oss.str().c_str());
2448 for(INT i=0;i<(INT)multiVal.size();i++)
2450 INT pos=multiVal[i];
2453 std::ostringstream oss;
2454 oss << "Requesting for setting id # " << pos << " having only " << nbc << " components !";
2455 throw INTERP_KERNEL::Exception(oss.str().c_str());
2457 pt[multiVal[i]]=(INT)multiValV[i];
2463 const INT *ptV=daIntTyyppV->getConstPointer();
2464 if(nbc>(INT)daIntTyyppV->getNumberOfCompo())
2466 std::ostringstream oss;
2467 oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
2468 throw INTERP_KERNEL::Exception(oss.str().c_str());
2470 std::copy(ptV,ptV+nbc,pt);
2474 throw INTERP_KERNEL::Exception(msg);
2479 std::size_t sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
2484 for(std::size_t j=0;j<sz;j++)
2485 pt[slic.first+j*slic.second.second]=(INT)singleValV;
2490 if(sz!=multiValV.size())
2492 std::ostringstream oss;
2493 oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << sz << " !";
2494 throw INTERP_KERNEL::Exception(oss.str().c_str());
2496 for(std::size_t j=0;j<sz;j++)
2497 pt[slic.first+j*slic.second.second]=(INT)multiValV[j];
2502 const INT *ptV=daIntTyyppV->getConstPointer();
2503 if(sz>daIntTyyppV->getNumberOfCompo())
2505 std::ostringstream oss;
2506 oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
2507 throw INTERP_KERNEL::Exception(oss.str().c_str());
2509 for(std::size_t j=0;j<sz;j++)
2510 pt[slic.first+j*slic.second.second]=ptV[j];
2514 throw INTERP_KERNEL::Exception(msg);
2518 throw INTERP_KERNEL::Exception(msg);
2527 %define TRANSFORMWITHINDARR( ARRAY, INT )
2528 void transformWithIndArr(PyObject *li)
2531 int res1(SWIG_ConvertPtr(li,&da,SWIGTITraits<INT>::TI, 0 | 0 ));
2532 if (!SWIG_IsOK(res1))
2534 int res2(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__MapII, 0 | 0 ));
2537 MapII *m=reinterpret_cast<MapII *>(da);
2538 self->transformWithIndArr(*m);
2543 INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
2544 self->transformWithIndArr(tmp,tmp+size);
2549 ARRAY *da2=reinterpret_cast< ARRAY * >(da);
2550 self->transformWithIndArr(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
2555 namespace MEDCoupling
2558 typedef long int Int64;
2561 class DataArrayInt32Iterator;
2563 class DataArrayInt32 : public DataArray
2565 ARRAYDEF( DataArrayInt32, Int32 )
2567 %extend DataArrayInt32 {
2569 PyObject *toNumPyArray() // not const. It is not a bug !
2571 return ToNumPyArray<DataArrayInt32,MEDCoupling::Int32>(self,NPY_INT32,"DataArrayInt32");
2574 #ifndef MEDCOUPLING_USE_64BIT_IDS
2575 MCAuto< MapII > invertArrayN2O2O2NOptimized()
2577 return self->invertArrayN2O2O2NOptimized();
2579 MCAuto< MapII > giveN2OOptimized()
2581 return self->giveN2OOptimized();
2583 TRANSFORMWITHINDARR( DataArrayInt32, Int32 )
2587 class DataArrayInt64Iterator;
2589 class DataArrayInt64 : public DataArray
2591 ARRAYDEF( DataArrayInt64, Int64 )
2593 %extend DataArrayInt64 {
2595 PyObject *toNumPyArray() // not const. It is not a bug !
2597 return ToNumPyArray<DataArrayInt64,MEDCoupling::Int64>(self,NPY_INT64,"DataArrayInt64");
2600 #ifdef MEDCOUPLING_USE_64BIT_IDS
2601 MCAuto< MapII > invertArrayN2O2O2NOptimized()
2603 return self->invertArrayN2O2O2NOptimized();
2605 MCAuto< MapII > giveN2OOptimized()
2607 return self->giveN2OOptimized();
2609 TRANSFORMWITHINDARR( DataArrayInt64, Int64 )