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 #if defined(WITH_NUMPY)
262 else if(MEDCouplingHasNumPyBindings() && PyArray_Check(elt0) && nbOfTuples==NULL && nbOfComp==NULL)
263 {//ARRAY.New(numpyArray)
264 return BuildNewInstance<ARRAY,INT>(elt0,NPYTraits<INT>::NPYObjectType,NPYTraits<INT>::NPYFunc,MEDCoupling::Traits<INT>::NPYStr);
268 throw INTERP_KERNEL::Exception(msg.c_str());
269 throw INTERP_KERNEL::Exception(msg.c_str());//to make g++ happy
272 ARRAY(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
274 return MEDCoupling_ ## ARRAY ## _New__SWIG_1(elt0,nbOfTuples,nbOfComp);
277 std::string __str__() const
279 return self->reprNotTooLong();
282 mcIdType __len__() const
284 if(self->isAllocated())
286 return self->getNumberOfTuples();
290 throw INTERP_KERNEL::Exception("ARRAY::__len__ : Instance is NOT allocated !");
296 return self->intValue();
299 ARRAY ## Iterator *__iter__()
301 return self->iterator();
304 PyObject *accumulate() const
306 mcIdType sz=ToIdType(self->getNumberOfComponents());
307 INTERP_KERNEL::AutoPtr<INT> tmp=new INT[sz];
308 self->accumulate((INT *)tmp);
309 return convertIntArrToPyList((const INT *)tmp,sz);
312 ARRAY *accumulatePerChunck(PyObject *indexArr) const
315 std::vector<mcIdType> val2;
316 const mcIdType *bg=convertIntStarLikePyObjToCppIntStar(indexArr,sw,sz,val,val2);
317 return self->accumulatePerChunck(bg,bg+sz);
320 DataArrayIdType *findIdsEqualTuple(PyObject *inputTuple) const
324 std::vector<INT> val2;
325 const INT *bg(convertIntStarLikePyObjToCppIntStar(inputTuple,sw,sz,val,val2));
326 return self->findIdsEqualTuple(bg,bg+sz);
329 DataArrayIdType *findIdForEach(PyObject *vals) const
333 std::vector<INT> val2;
334 const INT *bg(convertIntStarLikePyObjToCppIntStar(vals,sw,sz,val,val2));
335 MCAuto<DataArrayIdType> ret(self->findIdForEach(bg,bg+sz));
339 PyObject *splitInBalancedSlices(mcIdType nbOfSlices) const
341 std::vector< std::pair<mcIdType,mcIdType> > slcs(self->splitInBalancedSlices(nbOfSlices));
342 PyObject *ret=PyList_New(slcs.size());
343 for(std::size_t i=0;i<slcs.size();i++)
344 PyList_SetItem(ret,i,PySlice_New(PyInt_FromLong(slcs[i].first),PyInt_FromLong(slcs[i].second),PyInt_FromLong(1)));
348 ARRAY *buildExplicitArrOfSliceOnScaledArr(PyObject *slic) const
350 if(!PySlice_Check(slic))
351 throw INTERP_KERNEL::Exception("ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : expecting a pyslice as second (first) parameter !");
352 Py_ssize_t strt=2,stp=2,step=2;
353 GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !");
354 if(strt==std::numeric_limits<INT>::max() || stp==std::numeric_limits<INT>::max())
355 throw INTERP_KERNEL::Exception("ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice contains some unknowns that can't be determined in static method ! Call DataArray::getSlice (non static) instead !");
356 return self->buildExplicitArrOfSliceOnScaledArr((INT)strt,(INT)stp,(INT)step);
359 PyObject *getMinMaxValues() const
362 self->getMinMaxValues(a,b);
363 PyObject *ret=PyTuple_New(2);
364 PyTuple_SetItem(ret,0,PyInt_FromLong(a));
365 PyTuple_SetItem(ret,1,PyInt_FromLong(b));
369 static PyObject *ConvertIndexArrayToO2N(mcIdType nbOfOldTuples, PyObject *arr, PyObject *arrI)
371 mcIdType newNbOfTuples=-1;
372 mcIdType szArr,szArrI,sw,iTypppArr,iTypppArrI;
373 std::vector<mcIdType> stdvecTyyppArr;
374 std::vector<mcIdType> stdvecTyyppArrI;
375 const mcIdType *arrPtr=convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr);
376 const mcIdType *arrIPtr=convertIntStarLikePyObjToCppIntStar(arrI,sw,szArrI,iTypppArrI,stdvecTyyppArrI);
377 DataArrayIdType *ret0=MEDCoupling::ARRAY::ConvertIndexArrayToO2N(nbOfOldTuples,arrPtr,arrIPtr,arrIPtr+szArrI,newNbOfTuples);
378 PyObject *ret=PyTuple_New(2);
379 PyTuple_SetItem(ret,0,SWIG_NewPointerObj((void*)ret0,SWIGTITraits<mcIdType>::TI,SWIG_POINTER_OWN | 0));
380 PyTuple_SetItem(ret,1,PyInt_FromLong(newNbOfTuples));
384 static DataArrayIdType *CheckAndPreparePermutation(PyObject *arr)
386 MCAuto<DataArrayIdType> ret(DataArrayIdType::New());
389 std::vector<INT> stdvecTyyppArr;
390 const INT *arrPtr(convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr));
391 mcIdType *pt(MEDCoupling::ARRAY::CheckAndPreparePermutation(arrPtr,arrPtr+szArr));
392 ret->useArray(pt,true,MEDCoupling::DeallocType::C_DEALLOC,szArr,1);
396 void setValues(PyObject *li, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
398 const char *msg="MEDCoupling::ARRAY::setValues : Available API are : \n-ARRAY.setValues([1,3,4])\n-ARRAY.setValues([1,3,4],3)\n-ARRAY.setValues([1,3,4,5],2,2)\n-ARRAY.New(5)\n !";
399 if(PyList_Check(li) || PyTuple_Check(li))
401 if(nbOfTuples && nbOfTuples != Py_None)
403 if(PyInt_Check(nbOfTuples))
405 mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples));
407 throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive set of allocated memory !");
408 if(nbOfComp && nbOfComp != Py_None)
410 if(PyInt_Check(nbOfComp))
411 {//ARRAY.setValues([1,3,4,5],2,2)
412 mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp));
414 throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive number of components !");
415 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,nbOfTuples1,nbOfCompo);
416 self->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),self->getPointer());
419 throw INTERP_KERNEL::Exception(msg);
422 {//ARRAY.setValues([1,3,4],3)
424 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,nbOfTuples1,tmpp1);
425 self->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),self->getPointer());
429 throw INTERP_KERNEL::Exception(msg);
432 {// ARRAY.setValues([1,3,4])
433 mcIdType tmpp1=-1,tmpp2=-1;
434 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,tmpp1,tmpp2);
435 self->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),self->getPointer());
439 throw INTERP_KERNEL::Exception(msg);
442 PyObject *getValues() const
444 const INT *vals=self->getConstPointer();
445 return convertIntArrToPyList(vals,self->getNbOfElems());
448 PyObject *isEqualIfNotWhy(const ARRAY& other) const
451 bool ret0=self->isEqualIfNotWhy(other,ret1);
452 PyObject *ret=PyTuple_New(2);
453 PyObject *ret0Py=ret0?Py_True:Py_False;
455 PyTuple_SetItem(ret,0,ret0Py);
456 PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str()));
460 PyObject *getValuesAsTuple() const
462 const INT *vals=self->getConstPointer();
463 mcIdType nbOfComp=ToIdType(self->getNumberOfComponents());
464 mcIdType nbOfTuples=self->getNumberOfTuples();
465 return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
468 static PyObject *MakePartition(PyObject *gps, mcIdType newNb)
470 std::vector<const ARRAY *> groups;
471 std::vector< std::vector<mcIdType> > fidsOfGroups;
472 convertFromPyObjVectorOfObj(gps,SWIGTITraits<INT>::TI,"ARRAY",groups);
473 DataArrayIdType *ret0=MEDCoupling::ARRAY::MakePartition(groups,newNb,fidsOfGroups);
474 PyObject *ret = PyList_New(2);
475 PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
476 std::size_t sz=fidsOfGroups.size();
477 PyObject *ret1 = PyList_New(sz);
478 for(std::size_t i=0;i<sz;i++)
479 PyList_SetItem(ret1,i,convertIntArrToPyList2(fidsOfGroups[i]));
480 PyList_SetItem(ret,1,ret1);
484 DataArrayIdType *findIdsEqualList(PyObject *obj)
488 std::vector<INT> multiVal;
489 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
491 convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
495 return self->findIdsEqualList(&singleVal,&singleVal+1);
497 return self->findIdsEqualList(&multiVal[0],&multiVal[0]+multiVal.size());
499 return self->findIdsEqualList(daIntTyypp->begin(),daIntTyypp->end());
501 throw INTERP_KERNEL::Exception("ARRAY::findIdsEqualList : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
505 DataArrayIdType *findIdsNotEqualList(PyObject *obj)
509 std::vector<INT> multiVal;
510 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
512 convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
516 return self->findIdsNotEqualList(&singleVal,&singleVal+1);
518 return self->findIdsNotEqualList(&multiVal[0],&multiVal[0]+multiVal.size());
520 return self->findIdsNotEqualList(daIntTyypp->begin(),daIntTyypp->end());
522 throw INTERP_KERNEL::Exception("ARRAY::findIdsNotEqualList : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
526 PyObject *splitByValueRange(PyObject *li) const
528 ARRAY *ret0=0,*ret1=0,*ret2=0;
530 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<INT>::TI, 0 | 0 );
531 if (!SWIG_IsOK(res1))
534 INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
535 self->splitByValueRange(tmp,(INT *)tmp+size,ret0,ret1,ret2);
539 ARRAY *da2=reinterpret_cast< ARRAY * >(da);
541 throw INTERP_KERNEL::Exception("Not null ARRAY instance expected !");
542 da2->checkAllocated();
543 self->splitByValueRange(da2->begin(),da2->end(),ret0,ret1,ret2);
545 PyObject *ret = PyList_New(3);
546 PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
547 PyList_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
548 PyList_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(ret2),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
552 DataArrayIdType *transformWithIndArrR(PyObject *li) const
555 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<INT>::TI, 0 | 0 );
556 if (!SWIG_IsOK(res1))
559 INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
560 return self->transformWithIndArrR(tmp,tmp+size);
564 ARRAY *da2=reinterpret_cast< ARRAY * >(da);
565 return self->transformWithIndArrR(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
569 ARRAY *renumberAndReduce(PyObject *li, mcIdType newNbOfTuple)
572 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 | 0 );
573 if (!SWIG_IsOK(res1))
576 INTERP_KERNEL::AutoPtr<mcIdType> tmp=convertPyToNewIntArr2(li,&size);
577 if(size!=self->getNumberOfTuples())
579 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
581 return self->renumberAndReduce(tmp,newNbOfTuple);
585 DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da);
587 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
588 da2->checkAllocated();
589 mcIdType size=self->getNumberOfTuples();
590 if(size!=self->getNumberOfTuples())
592 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
594 return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple);
598 ARRAY *renumber(PyObject *li)
601 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 | 0 );
602 if (!SWIG_IsOK(res1))
605 INTERP_KERNEL::AutoPtr<mcIdType> tmp=convertPyToNewIntArr2(li,&size);
606 if(size!=self->getNumberOfTuples())
608 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
610 return self->renumber(tmp);
614 DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da);
616 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
617 da2->checkAllocated();
618 mcIdType size=self->getNumberOfTuples();
619 if(size!=self->getNumberOfTuples())
621 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
623 return self->renumber(da2->getConstPointer());
627 ARRAY *renumberR(PyObject *li)
630 int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 | 0 );
631 if (!SWIG_IsOK(res1))
634 INTERP_KERNEL::AutoPtr<mcIdType> tmp=convertPyToNewIntArr2(li,&size);
635 if(size!=self->getNumberOfTuples())
637 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
639 return self->renumberR(tmp);
643 DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da);
645 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
646 da2->checkAllocated();
647 mcIdType size=self->getNumberOfTuples();
648 if(size!=self->getNumberOfTuples())
650 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
652 return self->renumberR(da2->getConstPointer());
656 void setSelectedComponents(const ARRAY *a, PyObject *li)
658 std::vector<std::size_t> tmp;
659 convertPyToNewIntArr3(li,tmp);
660 self->setSelectedComponents(a,tmp);
663 PyObject *explodeComponents() const
665 std::vector< MCAuto<ARRAY> > retCpp(self->explodeComponents());
666 std::size_t sz(retCpp.size());
667 PyObject *res(PyList_New(sz));
668 for(std::size_t i=0;i<sz;i++)
669 PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(retCpp[i].retn()),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
673 PyObject *getTuple(mcIdType tupleId)
675 mcIdType sz=ToIdType(self->getNumberOfComponents());
676 INTERP_KERNEL::AutoPtr<INT> tmp=new INT[sz];
677 self->getTuple(tupleId,tmp);
678 return convertIntArrToPyList((const INT*)tmp,sz);
681 PyObject *changeSurjectiveFormat(INT targetNb) const
683 DataArrayIdType *arr=0;
684 DataArrayIdType *arrI=0;
685 self->changeSurjectiveFormat(targetNb,arr,arrI);
686 PyObject *res = PyList_New(2);
687 PyList_SetItem(res,0,SWIG_NewPointerObj((void*)arr,SWIGTITraits<mcIdType>::TI,SWIG_POINTER_OWN | 0));
688 PyList_SetItem(res,1,SWIG_NewPointerObj((void*)arrI,SWIGTITraits<mcIdType>::TI,SWIG_POINTER_OWN | 0));
692 static ARRAY *Meld(PyObject *li)
694 std::vector<const ARRAY *> tmp;
695 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
696 return ARRAY::Meld(tmp);
699 static ARRAY *Aggregate(PyObject *li)
701 std::vector<const ARRAY *> tmp;
702 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
703 return ARRAY::Aggregate(tmp);
706 static ARRAY *AggregateIndexes(PyObject *li)
708 std::vector<const ARRAY *> tmp;
709 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
710 return ARRAY::AggregateIndexes(tmp);
713 static ARRAY *BuildUnion(PyObject *li)
715 std::vector<const ARRAY *> tmp;
716 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
717 return ARRAY::BuildUnion(tmp);
720 static ARRAY *BuildIntersection(PyObject *li)
722 std::vector<const ARRAY *> tmp;
723 convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
724 return ARRAY::BuildIntersection(tmp);
727 PyObject *getMaxValue() const
730 INT r1=self->getMaxValue(tmp);
731 PyObject *ret=PyTuple_New(2);
732 PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
733 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
737 PyObject *getMaxAbsValue(std::size_t& tupleId) const
740 INT r1=self->getMaxAbsValue(tmp);
741 PyObject *ret=PyTuple_New(2);
742 PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
743 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
747 PyObject *getMinValue() const
750 INT r1=self->getMinValue(tmp);
751 PyObject *ret=PyTuple_New(2);
752 PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
753 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
757 mcIdType index(PyObject *obj) const
759 std::size_t nbOfCompo=self->getNumberOfComponents();
766 INT val=(INT)PyInt_AS_LONG(obj);
767 return self->findIdFirstEqual(val);
770 throw INTERP_KERNEL::Exception("ARRAY::index : 'this' contains one component and trying to find an element which is not an integer !");
774 std::vector<INT> arr;
775 convertPyToNewIntArr3(obj,arr);
776 return self->findIdFirstEqualTuple(arr);
781 bool __contains__(PyObject *obj) const
783 std::size_t nbOfCompo=self->getNumberOfComponents();
792 INT val=(INT)PyInt_AS_LONG(obj);
793 return self->presenceOfValue(val);
796 throw INTERP_KERNEL::Exception("ARRAY::__contains__ : 'this' contains one component and trying to find an element which is not an integer !");
800 std::vector<INT> arr;
801 convertPyToNewIntArr3(obj,arr);
802 return self->presenceOfTuple(arr);
807 PyObject *__getitem__(PyObject *obj)
809 const char msg[]="Unexpected situation in ARRAY::__getitem__ !";
810 const char msg2[]="ARRAY::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
811 self->checkAllocated();
812 mcIdType nbOfTuples=self->getNumberOfTuples();
813 std::size_t nbOfComponents=self->getNumberOfComponents();
816 std::vector<mcIdType> vt1;
817 std::vector<std::size_t> vc1;
818 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > pt1,pc1;
819 DataArrayIdType *dt1=0,*dc1=0;
821 convertObjToPossibleCpp3(obj,nbOfTuples,(int)nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
827 if(nbOfComponents==1)
828 return PyInt_FromLong(self->getIJSafe(it1,0));
829 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&it1,&it1+1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
832 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size())),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
834 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
836 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems())),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
838 return PyInt_FromLong(self->getIJSafe(it1,ic1));
841 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
842 std::vector<std::size_t> v2(1,ic1);
843 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
847 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
848 std::vector<std::size_t> v2(1,ic1);
849 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
853 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
854 std::vector<std::size_t> v2(1,ic1);
855 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
859 ret=self->selectByTupleIdSafe(&it1,&it1+1);
860 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
864 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
865 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
869 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
870 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
874 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
875 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
879 ret=self->selectByTupleIdSafe(&it1,&it1+1);
880 mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
881 std::vector<std::size_t> v2(nbOfComp);
882 for(INT i=0;i<nbOfComp;i++)
883 v2[i]=pc1.first+i*pc1.second.second;
884 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
888 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
889 mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
890 std::vector<std::size_t> v2(nbOfComp);
891 for(INT i=0;i<nbOfComp;i++)
892 v2[i]=pc1.first+i*pc1.second.second;
893 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
897 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
898 mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
899 std::vector<std::size_t> v2(nbOfComp);
900 for(mcIdType i=0;i<nbOfComp;i++)
901 v2[i]=pc1.first+i*pc1.second.second;
902 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
906 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
907 mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
908 std::vector<std::size_t> v2(nbOfComp);
909 for(INT i=0;i<nbOfComp;i++)
910 v2[i]=pc1.first+i*pc1.second.second;
911 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
914 throw INTERP_KERNEL::Exception(msg);
918 ARRAY *__setitem__(PyObject *obj, PyObject *value)
920 self->checkAllocated();
921 const char msg[]="Unexpected situation in __setitem__ !";
922 mcIdType nbOfTuples=self->getNumberOfTuples();
923 int nbOfComponents=(int)self->getNumberOfComponents();
928 ARRAY ## Tuple *dd1=0;
929 convertIntStarLikePyObjToCpp(value,sw1,i1,v1,d1,dd1);
931 std::vector<mcIdType> vt1,vc1;
932 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > pt1,pc1;
933 DataArrayIdType *dt1=0,*dc1=0;
934 convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
943 self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
947 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
948 self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
951 self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1);
954 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
955 self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1);
958 throw INTERP_KERNEL::Exception(msg);
967 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
971 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
972 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
975 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
978 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
979 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
982 throw INTERP_KERNEL::Exception(msg);
991 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
995 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
996 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
999 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
1002 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1003 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
1006 throw INTERP_KERNEL::Exception(msg);
1015 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
1019 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1020 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
1023 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
1026 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1027 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
1030 throw INTERP_KERNEL::Exception(msg);
1039 self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
1043 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1044 self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
1047 self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1);
1050 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1051 self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1);
1054 throw INTERP_KERNEL::Exception(msg);
1063 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
1067 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1068 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
1071 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
1074 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1075 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
1078 throw INTERP_KERNEL::Exception(msg);
1087 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
1091 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1092 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
1095 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
1098 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1099 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
1102 throw INTERP_KERNEL::Exception(msg);
1111 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
1115 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1116 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
1119 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
1122 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1123 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
1126 throw INTERP_KERNEL::Exception(msg);
1135 self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
1139 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1140 self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
1143 self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
1146 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1147 self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
1150 throw INTERP_KERNEL::Exception(msg);
1159 self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
1163 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1164 self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
1167 self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
1170 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1171 self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
1174 throw INTERP_KERNEL::Exception(msg);
1183 self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
1187 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1188 self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size(),false);
1191 self->setPartOfValues4(d1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
1194 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1195 self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
1198 throw INTERP_KERNEL::Exception(msg);
1207 self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
1211 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1212 self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
1215 self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
1218 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1219 self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
1222 throw INTERP_KERNEL::Exception(msg);
1231 self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
1235 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1236 self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
1239 self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
1242 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1243 self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
1246 throw INTERP_KERNEL::Exception(msg);
1255 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
1259 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1260 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false);
1263 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
1266 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1267 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
1270 throw INTERP_KERNEL::Exception(msg);
1279 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
1283 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1284 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false);
1287 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
1290 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1291 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
1294 throw INTERP_KERNEL::Exception(msg);
1303 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
1307 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1308 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false);
1311 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
1314 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1315 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
1318 throw INTERP_KERNEL::Exception(msg);
1323 throw INTERP_KERNEL::Exception(msg);
1328 ARRAY *__neg__() const
1330 return self->negate();
1333 ARRAY *__add__(PyObject *obj)
1335 const char msg[]="Unexpected situation in __add__ !";
1338 std::vector<INT> aa;
1339 ARRAY ## Tuple *aaa;
1341 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1346 MCAuto<ARRAY> ret=self->deepCopy();
1347 ret->applyLin(1,val);
1352 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1353 return ARRAY::Add(self,aaaa);
1357 return ARRAY::Add(self,a);
1361 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1362 return ARRAY::Add(self,aaaa);
1365 throw INTERP_KERNEL::Exception(msg);
1369 ARRAY *__radd__(PyObject *obj)
1371 const char msg[]="Unexpected situation in __radd__ !";
1374 std::vector<INT> aa;
1375 ARRAY ## Tuple *aaa;
1377 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1382 MCAuto<ARRAY> ret=self->deepCopy();
1383 ret->applyLin(1,val);
1388 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1389 return ARRAY::Add(self,aaaa);
1393 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1394 return ARRAY::Add(self,aaaa);
1397 throw INTERP_KERNEL::Exception(msg);
1401 PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
1403 const char msg[]="Unexpected situation in __iadd__ !";
1406 std::vector<INT> aa;
1407 ARRAY ## Tuple *aaa;
1409 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1414 self->applyLin(1,val);
1415 Py_XINCREF(trueSelf);
1420 MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1422 Py_XINCREF(trueSelf);
1428 Py_XINCREF(trueSelf);
1433 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1434 self->addEqual(aaaa);
1435 Py_XINCREF(trueSelf);
1439 throw INTERP_KERNEL::Exception(msg);
1443 ARRAY *__sub__(PyObject *obj)
1445 const char msg[]="Unexpected situation in __sub__ !";
1448 std::vector<INT> aa;
1449 ARRAY ## Tuple *aaa;
1451 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1456 MCAuto<ARRAY> ret=self->deepCopy();
1457 ret->applyLin(1,-val);
1462 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1463 return ARRAY::Substract(self,aaaa);
1467 return ARRAY::Substract(self,a);
1471 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1472 return ARRAY::Substract(self,aaaa);
1475 throw INTERP_KERNEL::Exception(msg);
1479 ARRAY *__rsub__(PyObject *obj)
1481 const char msg[]="Unexpected situation in __rsub__ !";
1484 std::vector<INT> aa;
1485 ARRAY ## Tuple *aaa;
1487 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1492 MCAuto<ARRAY> ret=self->deepCopy();
1493 ret->applyLin(-1,val);
1498 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1499 return ARRAY::Substract(aaaa,self);
1503 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1504 return ARRAY::Substract(aaaa,self);
1507 throw INTERP_KERNEL::Exception(msg);
1511 PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
1513 const char msg[]="Unexpected situation in __isub__ !";
1516 std::vector<INT> aa;
1517 ARRAY ## Tuple *aaa;
1519 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1524 self->applyLin(1,-val);
1525 Py_XINCREF(trueSelf);
1530 MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1531 self->substractEqual(bb);
1532 Py_XINCREF(trueSelf);
1537 self->substractEqual(a);
1538 Py_XINCREF(trueSelf);
1543 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1544 self->substractEqual(aaaa);
1545 Py_XINCREF(trueSelf);
1549 throw INTERP_KERNEL::Exception(msg);
1553 ARRAY *__mul__(PyObject *obj)
1555 const char msg[]="Unexpected situation in __mul__ !";
1558 std::vector<INT> aa;
1559 ARRAY ## Tuple *aaa;
1561 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1566 MCAuto<ARRAY> ret=self->deepCopy();
1567 ret->applyLin(val,0);
1572 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1573 return ARRAY::Multiply(self,aaaa);
1577 return ARRAY::Multiply(self,a);
1581 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1582 return ARRAY::Multiply(self,aaaa);
1585 throw INTERP_KERNEL::Exception(msg);
1589 ARRAY *__rmul__(PyObject *obj)
1591 const char msg[]="Unexpected situation in __rmul__ !";
1594 std::vector<INT> aa;
1595 ARRAY ## Tuple *aaa;
1597 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1602 MCAuto<ARRAY> ret=self->deepCopy();
1603 ret->applyLin(val,0);
1608 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1609 return ARRAY::Multiply(self,aaaa);
1613 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1614 return ARRAY::Multiply(self,aaaa);
1617 throw INTERP_KERNEL::Exception(msg);
1621 PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
1623 const char msg[]="Unexpected situation in __imul__ !";
1626 std::vector<INT> aa;
1627 ARRAY ## Tuple *aaa;
1629 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1634 self->applyLin(val,0);
1635 Py_XINCREF(trueSelf);
1640 MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1641 self->multiplyEqual(bb);
1642 Py_XINCREF(trueSelf);
1647 self->multiplyEqual(a);
1648 Py_XINCREF(trueSelf);
1653 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1654 self->multiplyEqual(aaaa);
1655 Py_XINCREF(trueSelf);
1659 throw INTERP_KERNEL::Exception(msg);
1663 ARRAY *__div__(PyObject *obj)
1665 const char msg[]="Unexpected situation in __div__ !";
1668 std::vector<INT> aa;
1669 ARRAY ## Tuple *aaa;
1671 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1676 MCAuto<ARRAY> ret=self->deepCopy();
1677 ret->applyDivideBy(val);
1682 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1683 return ARRAY::Divide(self,aaaa);
1687 return ARRAY::Divide(self,a);
1691 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1692 return ARRAY::Divide(self,aaaa);
1695 throw INTERP_KERNEL::Exception(msg);
1699 ARRAY *__rdiv__(PyObject *obj)
1701 const char msg[]="Unexpected situation in __rdiv__ !";
1704 std::vector<INT> aa;
1705 ARRAY ## Tuple *aaa;
1707 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1712 MCAuto<ARRAY> ret=self->deepCopy();
1718 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1719 return ARRAY::Divide(aaaa,self);
1723 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1724 return ARRAY::Divide(aaaa,self);
1727 throw INTERP_KERNEL::Exception(msg);
1731 PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
1733 const char msg[]="Unexpected situation in __idiv__ !";
1736 std::vector<INT> aa;
1737 ARRAY ## Tuple *aaa;
1739 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1744 self->applyDivideBy(val);
1745 Py_XINCREF(trueSelf);
1750 MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1751 self->divideEqual(bb);
1752 Py_XINCREF(trueSelf);
1757 self->divideEqual(a);
1758 Py_XINCREF(trueSelf);
1763 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1764 self->divideEqual(aaaa);
1765 Py_XINCREF(trueSelf);
1769 throw INTERP_KERNEL::Exception(msg);
1773 ARRAY *__mod__(PyObject *obj)
1775 const char msg[]="Unexpected situation in __mod__ !";
1778 std::vector<INT> aa;
1779 ARRAY ## Tuple *aaa;
1781 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1786 MCAuto<ARRAY> ret=self->deepCopy();
1787 ret->applyModulus(val);
1792 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1793 return ARRAY::Modulus(self,aaaa);
1797 return ARRAY::Modulus(self,a);
1801 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1802 return ARRAY::Modulus(self,aaaa);
1805 throw INTERP_KERNEL::Exception(msg);
1809 ARRAY *__rmod__(PyObject *obj)
1811 const char msg[]="Unexpected situation in __rmod__ !";
1814 std::vector<INT> aa;
1815 ARRAY ## Tuple *aaa;
1817 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1822 MCAuto<ARRAY> ret=self->deepCopy();
1823 ret->applyRModulus(val);
1828 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1829 return ARRAY::Modulus(aaaa,self);
1833 return ARRAY::Modulus(a,self);
1837 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1838 return ARRAY::Modulus(aaaa,self);
1841 throw INTERP_KERNEL::Exception(msg);
1845 PyObject *___imod___(PyObject *trueSelf, PyObject *obj)
1847 const char msg[]="Unexpected situation in __imod__ !";
1850 std::vector<INT> aa;
1851 ARRAY ## Tuple *aaa;
1853 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1858 self->applyModulus(val);
1859 Py_XINCREF(trueSelf);
1864 self->modulusEqual(a);
1865 Py_XINCREF(trueSelf);
1870 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1871 self->modulusEqual(aaaa);
1872 Py_XINCREF(trueSelf);
1876 throw INTERP_KERNEL::Exception(msg);
1880 ARRAY *__pow__(PyObject *obj)
1882 const char msg[]="Unexpected situation in __pow__ !";
1885 std::vector<INT> aa;
1886 ARRAY ## Tuple *aaa;
1888 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1893 MCAuto<ARRAY> ret=self->deepCopy();
1899 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1900 return ARRAY::Pow(self,aaaa);
1904 return ARRAY::Pow(self,a);
1908 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1909 return ARRAY::Pow(self,aaaa);
1912 throw INTERP_KERNEL::Exception(msg);
1916 ARRAY *__rpow__(PyObject *obj)
1918 const char msg[]="Unexpected situation in __rpow__ !";
1921 std::vector<INT> aa;
1922 ARRAY ## Tuple *aaa;
1924 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1929 MCAuto<ARRAY> ret=self->deepCopy();
1930 ret->applyRPow(val);
1935 MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1936 return ARRAY::Pow(aaaa,self);
1940 return ARRAY::Pow(a,self);
1944 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1945 return ARRAY::Pow(aaaa,self);
1948 throw INTERP_KERNEL::Exception(msg);
1952 PyObject *___ipow___(PyObject *trueSelf, PyObject *obj)
1954 const char msg[]="Unexpected situation in __ipow__ !";
1957 std::vector<INT> aa;
1958 ARRAY ## Tuple *aaa;
1960 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1965 self->applyPow(val);
1966 Py_XINCREF(trueSelf);
1972 Py_XINCREF(trueSelf);
1977 MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1978 self->powEqual(aaaa);
1979 Py_XINCREF(trueSelf);
1983 throw INTERP_KERNEL::Exception(msg);
1987 std::string __repr__() const
1989 std::ostringstream oss;
1990 self->reprQuickOverview(oss);
1994 void pushBackValsSilent(PyObject *li)
1998 std::vector<INT> stdvecTyyppArr;
1999 const INT *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr);
2000 self->pushBackValsSilent(tmp,tmp+szArr);
2003 PyObject *partitionByDifferentValues() const
2005 std::vector<INT> ret1;
2006 std::vector<DataArrayIdType *> ret0=self->partitionByDifferentValues(ret1);
2007 std::size_t sz=ret0.size();
2008 PyObject *pyRet=PyTuple_New(2);
2009 PyObject *pyRet0=PyList_New((INT)sz);
2010 PyObject *pyRet1=PyList_New((INT)sz);
2011 for(std::size_t i=0;i<sz;i++)
2013 PyList_SetItem(pyRet0,i,SWIG_NewPointerObj(SWIG_as_voidptr(ret0[i]),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2014 PyList_SetItem(pyRet1,i,PyInt_FromLong(ret1[i]));
2016 PyTuple_SetItem(pyRet,0,pyRet0);
2017 PyTuple_SetItem(pyRet,1,pyRet1);
2021 PyObject *findIdsRangesInListOfIds(const ARRAY *listOfIds) const
2023 DataArrayIdType *ret0=0;
2025 self->findIdsRangesInListOfIds(listOfIds,ret0,ret1);
2026 PyObject *pyRet=PyTuple_New(2);
2027 PyTuple_SetItem(pyRet,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2028 PyTuple_SetItem(pyRet,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
2032 PyObject *isRange() const
2035 bool ret(self->isRange(a,b,c));
2036 PyObject *pyRet=PyTuple_New(2);
2037 PyObject *ret0Py=ret?Py_True:Py_False,*ret1Py(0);
2039 PyTuple_SetItem(pyRet,0,ret0Py);
2041 ret1Py=PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(c));
2047 PyTuple_SetItem(pyRet,1,ret1Py);
2051 static bool RemoveIdsFromIndexedArrays(PyObject *li, ARRAY *arr, DataArrayIdType *arrIndx, mcIdType offsetForRemoval=0) throw(INTERP_KERNEL::Exception)
2055 std::vector<INT> multiVal;
2056 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2057 MEDCoupling::ARRAY *daIntTyypp=0;
2059 throw INTERP_KERNEL::Exception("ARRAY::RemoveIdsFromIndexedArrays : null pointer as arrIndex !");
2060 convertIntStarOrSliceLikePyObjToCpp(li,arrIndx->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2064 return ARRAY::RemoveIdsFromIndexedArrays(&singleVal,&singleVal+1,arr,arrIndx,offsetForRemoval);
2066 return ARRAY::RemoveIdsFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arr,arrIndx,offsetForRemoval);
2068 return ARRAY::RemoveIdsFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arr,arrIndx,offsetForRemoval);
2070 throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2074 static PyObject *ExtractFromIndexedArrays(PyObject *li, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
2077 DataArrayIdType *arrIndexOut=0;
2080 std::vector<mcIdType> multiVal;
2081 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2082 MEDCoupling::DataArrayIdType *daIntTyypp=0;
2084 throw INTERP_KERNEL::Exception("ARRAY::ExtractFromIndexedArrays : null pointer as arrIndxIn !");
2085 convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2090 ARRAY::ExtractFromIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,arrOut,arrIndexOut);
2095 ARRAY::ExtractFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,arrOut,arrIndexOut);
2100 ARRAY::ExtractFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,arrOut,arrIndexOut);
2104 throw INTERP_KERNEL::Exception("ARRAY::ExtractFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2106 PyObject *ret=PyTuple_New(2);
2107 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2108 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2112 static PyObject *ExtractFromIndexedArraysSlice(mcIdType strt, mcIdType stp, mcIdType step, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
2115 DataArrayIdType *arrIndexOut=0;
2116 ARRAY::ExtractFromIndexedArraysSlice(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut);
2117 PyObject *ret=PyTuple_New(2);
2118 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2119 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2123 static PyObject *ExtractFromIndexedArraysSlice(PyObject *slic, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
2125 if(!PySlice_Check(slic))
2126 throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : the first param is not a pyslice !");
2127 Py_ssize_t strt=2,stp=2,step=2;
2129 throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : last array is null !");
2130 arrIndxIn->checkAllocated();
2131 if(arrIndxIn->getNumberOfComponents()!=1)
2132 throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : number of components of last argument must be equal to one !");
2133 GetIndicesOfSlice(slic,arrIndxIn->getNumberOfTuples(),&strt,&stp,&step,"ExtractFromIndexedArraysSlice (wrap) : Invalid slice regarding nb of elements !");
2135 DataArrayIdType *arrIndexOut=0;
2136 ARRAY::ExtractFromIndexedArraysSlice(ToIdType(strt),ToIdType(stp),ToIdType(step),arrIn,arrIndxIn,arrOut,arrIndexOut);
2137 PyObject *ret=PyTuple_New(2);
2138 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2139 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2143 static PyObject *SetPartOfIndexedArrays(PyObject *li,
2144 const ARRAY *arrIn, const DataArrayIdType *arrIndxIn,
2145 const ARRAY *srcArr, const DataArrayIdType *srcArrIndex) throw(INTERP_KERNEL::Exception)
2148 DataArrayIdType *arrIndexOut=0;
2151 std::vector<mcIdType> multiVal;
2152 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2153 MEDCoupling::DataArrayIdType *daIntTyypp=0;
2155 throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArrays : null pointer as arrIndex !");
2156 convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2161 ARRAY::SetPartOfIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
2166 ARRAY::SetPartOfIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
2171 ARRAY::SetPartOfIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
2175 throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2177 PyObject *ret=PyTuple_New(2);
2178 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2179 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2183 static void SetPartOfIndexedArraysSameIdx(PyObject *li, ARRAY *arrIn, const DataArrayIdType *arrIndxIn,
2184 const ARRAY *srcArr, const DataArrayIdType *srcArrIndex) throw(INTERP_KERNEL::Exception)
2188 std::vector<mcIdType> multiVal;
2189 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2190 MEDCoupling::DataArrayIdType *daIntTyypp=0;
2192 throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArraysSameIdx : null pointer as arrIndex !");
2193 convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2198 ARRAY::SetPartOfIndexedArraysSameIdx(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex);
2203 ARRAY::SetPartOfIndexedArraysSameIdx(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex);
2208 ARRAY::SetPartOfIndexedArraysSameIdx(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex);
2212 throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArraysSameIdx : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2219 class ARRAY ## Tuple;
2221 class ARRAY ## Iterator
2224 ARRAY ## Iterator(ARRAY *da);
2225 ~ARRAY ## Iterator();
2230 ARRAY ## Tuple *ret=self->nextt();
2232 return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_MEDCoupling__ ## ARRAY ## Tuple,SWIG_POINTER_OWN | 0);
2235 PyErr_SetString(PyExc_StopIteration,"No more data.");
2242 class ARRAY ## Tuple
2245 std::size_t getNumberOfCompo() const;
2246 ARRAY *buildDAInt(INT nbOfTuples, INT nbOfCompo) const;
2249 std::string __str__() const
2251 return self->repr();
2256 return self->intValue();
2261 return self->buildDAInt(1,self->getNumberOfCompo());
2264 PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
2266 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2267 MEDCoupling_ ## ARRAY ## ____iadd___(ret,0,obj);
2268 Py_XINCREF(trueSelf);
2272 PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
2274 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2275 MEDCoupling_ ## ARRAY ## ____isub___(ret,0,obj);
2276 Py_XINCREF(trueSelf);
2280 PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
2282 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2283 MEDCoupling_ ## ARRAY ## ____imul___(ret,0,obj);
2284 Py_XINCREF(trueSelf);
2287 PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
2289 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2290 MEDCoupling_ ## ARRAY ## ____idiv___(ret,0,obj);
2291 Py_XINCREF(trueSelf);
2295 PyObject *___imod___(PyObject *trueSelf, PyObject *obj)
2297 MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2298 MEDCoupling_ ## ARRAY ## ____imod___(ret,0,obj);
2299 Py_XINCREF(trueSelf);
2305 return PyInt_FromLong(self->getNumberOfCompo());
2308 PyObject *__getitem__(PyObject *obj)
2310 const char msg2[]="ARRAY ## Tuple::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
2313 std::vector<INT> multiVal;
2314 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2315 MEDCoupling::DataArrayIdType *daIntTyypp=0;
2316 const INT *pt=self->getConstPointer();
2317 INT nbc=(INT)self->getNumberOfCompo();
2318 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,ToIdType(nbc),sw,singleVal,multiVal,slic,daIntTyypp);
2323 if(singleVal>=(INT)nbc)
2325 std::ostringstream oss;
2326 oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
2327 PyErr_SetString(PyExc_StopIteration,oss.str().c_str());
2331 return PyInt_FromLong(pt[singleVal]);
2335 return PyInt_FromLong(pt[nbc+singleVal]);
2338 std::ostringstream oss;
2339 oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
2340 throw INTERP_KERNEL::Exception(oss.str().c_str());
2346 PyObject *t=PyTuple_New(multiVal.size());
2347 for(std::size_t j=0;j<multiVal.size();j++)
2349 INT cid=multiVal[j];
2352 std::ostringstream oss;
2353 oss << "Requesting for id #" << cid << " having only " << nbc << " components !";
2354 throw INTERP_KERNEL::Exception(oss.str().c_str());
2356 PyTuple_SetItem(t,j,PyInt_FromLong(pt[cid]));
2362 mcIdType sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
2363 PyObject *t=PyTuple_New(sz);
2364 for(INT j=0;j<sz;j++)
2365 PyTuple_SetItem(t,j,PyInt_FromLong(pt[slic.first+j*slic.second.second]));
2369 throw INTERP_KERNEL::Exception("ARRAY ## Tuple::__getitem__ : unrecognized type entered !");
2373 ARRAY ## Tuple *__setitem__(PyObject *obj, PyObject *value)
2375 const char msg[]="DataArrayIntTuple::__setitem__ : unrecognized type entered, int, slice, list<int>, tuple<int> !";
2376 const char msg2[]="DataArrayIntTuple::__setitem__ : Mismatch of slice values in 2nd parameter (components) !";
2378 mcIdType singleValV;
2379 std::vector<mcIdType> multiValV;
2380 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slicV;
2381 MEDCoupling::ARRAY ## Tuple *daIntTyyppV=0;
2382 mcIdType nbc=ToIdType(self->getNumberOfCompo());
2383 convertObjToPossibleCpp22<INT>(value,nbc,sw1,singleValV,multiValV,slicV,daIntTyyppV);
2385 std::vector<INT> multiVal;
2386 std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2387 MEDCoupling::ARRAY *daIntTyypp=0;
2388 INT *pt=self->getPointer();
2389 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
2396 std::ostringstream oss;
2397 oss << "Requesting for setting id # " << singleVal << " having only " << nbc << " components !";
2398 throw INTERP_KERNEL::Exception(oss.str().c_str());
2404 pt[singleVal]=(INT)singleValV;
2409 if(multiValV.size()!=1)
2411 std::ostringstream oss;
2412 oss << "Requesting for setting id # " << singleVal << " with a list or tuple with size != 1 ! ";
2413 throw INTERP_KERNEL::Exception(oss.str().c_str());
2415 pt[singleVal]=(INT)multiValV[0];
2420 pt[singleVal]=daIntTyyppV->getConstPointer()[0];
2424 throw INTERP_KERNEL::Exception(msg);
2433 for(std::vector<INT>::const_iterator it=multiVal.begin();it!=multiVal.end();it++)
2437 std::ostringstream oss;
2438 oss << "Requesting for setting id # " << *it << " having only " << nbc << " components !";
2439 throw INTERP_KERNEL::Exception(oss.str().c_str());
2441 pt[*it]=(INT)singleValV;
2447 if(multiVal.size()!=multiValV.size())
2449 std::ostringstream oss;
2450 oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << multiVal.size() << " !";
2451 throw INTERP_KERNEL::Exception(oss.str().c_str());
2453 for(INT i=0;i<(INT)multiVal.size();i++)
2455 INT pos=multiVal[i];
2458 std::ostringstream oss;
2459 oss << "Requesting for setting id # " << pos << " having only " << nbc << " components !";
2460 throw INTERP_KERNEL::Exception(oss.str().c_str());
2462 pt[multiVal[i]]=(INT)multiValV[i];
2468 const INT *ptV=daIntTyyppV->getConstPointer();
2469 if(nbc>(INT)daIntTyyppV->getNumberOfCompo())
2471 std::ostringstream oss;
2472 oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
2473 throw INTERP_KERNEL::Exception(oss.str().c_str());
2475 std::copy(ptV,ptV+nbc,pt);
2479 throw INTERP_KERNEL::Exception(msg);
2484 std::size_t sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
2489 for(std::size_t j=0;j<sz;j++)
2490 pt[slic.first+j*slic.second.second]=(INT)singleValV;
2495 if(sz!=multiValV.size())
2497 std::ostringstream oss;
2498 oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << sz << " !";
2499 throw INTERP_KERNEL::Exception(oss.str().c_str());
2501 for(std::size_t j=0;j<sz;j++)
2502 pt[slic.first+j*slic.second.second]=(INT)multiValV[j];
2507 const INT *ptV=daIntTyyppV->getConstPointer();
2508 if(sz>daIntTyyppV->getNumberOfCompo())
2510 std::ostringstream oss;
2511 oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
2512 throw INTERP_KERNEL::Exception(oss.str().c_str());
2514 for(std::size_t j=0;j<sz;j++)
2515 pt[slic.first+j*slic.second.second]=ptV[j];
2519 throw INTERP_KERNEL::Exception(msg);
2523 throw INTERP_KERNEL::Exception(msg);
2532 %define TRANSFORMWITHINDARR( ARRAY, INT )
2533 void transformWithIndArr(PyObject *li)
2536 int res1(SWIG_ConvertPtr(li,&da,SWIGTITraits<INT>::TI, 0 | 0 ));
2537 if (!SWIG_IsOK(res1))
2539 int res2(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__MapII, 0 | 0 ));
2542 MapII *m=reinterpret_cast<MapII *>(da);
2543 self->transformWithIndArr(*m);
2548 INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
2549 self->transformWithIndArr(tmp,tmp+size);
2554 ARRAY *da2=reinterpret_cast< ARRAY * >(da);
2555 self->transformWithIndArr(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
2560 namespace MEDCoupling
2564 typedef long long Int64;
2566 typedef long int Int64;
2569 class DataArrayInt32Iterator;
2571 class DataArrayInt32 : public DataArray
2573 ARRAYDEF( DataArrayInt32, Int32 )
2575 %extend DataArrayInt32 {
2577 PyObject *toNumPyArray() // not const. It is not a bug !
2579 return ToNumPyArray<DataArrayInt32,MEDCoupling::Int32>(self,NPY_INT32,"DataArrayInt32");
2582 #ifndef MEDCOUPLING_USE_64BIT_IDS
2583 MCAuto< MapII > invertArrayN2O2O2NOptimized()
2585 return self->invertArrayN2O2O2NOptimized();
2587 MCAuto< MapII > giveN2OOptimized()
2589 return self->giveN2OOptimized();
2591 TRANSFORMWITHINDARR( DataArrayInt32, Int32 )
2595 class DataArrayInt64Iterator;
2597 class DataArrayInt64 : public DataArray
2599 ARRAYDEF( DataArrayInt64, Int64 )
2601 %extend DataArrayInt64 {
2603 PyObject *toNumPyArray() // not const. It is not a bug !
2605 return ToNumPyArray<DataArrayInt64,MEDCoupling::Int64>(self,NPY_INT64,"DataArrayInt64");
2608 #ifdef MEDCOUPLING_USE_64BIT_IDS
2609 MCAuto< MapII > invertArrayN2O2O2NOptimized()
2611 return self->invertArrayN2O2O2NOptimized();
2613 MCAuto< MapII > giveN2OOptimized()
2615 return self->giveN2OOptimized();
2617 TRANSFORMWITHINDARR( DataArrayInt64, Int64 )