- checkAllocated();
- int nbTuples=getNumberOfTuples();
- int nbOfCompo=getNumberOfComponents();
- double *tmp=new double[nbTuples*nbOfCompo];
- const double *iptr=getConstPointer();
- for(int i=0;i<nbTuples;i++)
- {
- int v=new2Old[i];
- if(v>=0 && v<nbTuples)
- std::copy(iptr+nbOfCompo*v,iptr+nbOfCompo*(v+1),tmp+nbOfCompo*i);
- else
- {
- std::ostringstream oss; oss << "DataArrayDouble::renumberInPlaceR : At place #" << i << " value is " << v << " ! Should be in [0," << nbTuples << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- std::copy(tmp,tmp+nbTuples*nbOfCompo,getPointer());
- delete [] tmp;
- declareAsNew();
-}
-
-/*!
- * Returns a copy of \a this array with values permuted as required by \a old2New array.
- * The values are permuted so that \c new[ \a old2New[ i ]] = \c old[ i ].
- * Number of tuples in the result array remains the same as in \this one.
- * If a permutation reduction is needed, renumberAndReduce() should be used.
- * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
- * \param [in] old2New - C array of length equal to \a this->getNumberOfTuples()
- * giving a new position for i-th old value.
- * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
- * is to delete using decrRef() as it is no more needed.
- * \throw If \a this is not allocated.
- */
-DataArrayDouble *DataArrayDouble::renumber(const int *old2New) const throw(INTERP_KERNEL::Exception)
-{
- checkAllocated();
- int nbTuples=getNumberOfTuples();
- int nbOfCompo=getNumberOfComponents();
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
- ret->alloc(nbTuples,nbOfCompo);
- ret->copyStringInfoFrom(*this);
- const double *iptr=getConstPointer();
- double *optr=ret->getPointer();
- for(int i=0;i<nbTuples;i++)
- std::copy(iptr+nbOfCompo*i,iptr+nbOfCompo*(i+1),optr+nbOfCompo*old2New[i]);
- ret->copyStringInfoFrom(*this);
- return ret.retn();
-}
-
-/*!
- * Returns a copy of \a this array with values permuted as required by \a new2Old array.
- * The values are permuted so that \c new[ i ] = \c old[ \a new2Old[ i ]]. Number of
- * tuples in the result array remains the same as in \this one.
- * If a permutation reduction is needed, substr() or selectByTupleId() should be used.
- * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
- * \param [in] new2Old - C array of length equal to \a this->getNumberOfTuples()
- * giving a previous position of i-th new value.
- * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
- * is to delete using decrRef() as it is no more needed.
- */
-DataArrayDouble *DataArrayDouble::renumberR(const int *new2Old) const throw(INTERP_KERNEL::Exception)
-{
- checkAllocated();
- int nbTuples=getNumberOfTuples();
- int nbOfCompo=getNumberOfComponents();
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
- ret->alloc(nbTuples,nbOfCompo);
- ret->copyStringInfoFrom(*this);
- const double *iptr=getConstPointer();
- double *optr=ret->getPointer();
- for(int i=0;i<nbTuples;i++)
- std::copy(iptr+nbOfCompo*new2Old[i],iptr+nbOfCompo*(new2Old[i]+1),optr+i*nbOfCompo);
- ret->copyStringInfoFrom(*this);
- return ret.retn();
-}
-
-/*!
- * Returns a shorten and permuted copy of \a this array. The new DataArrayDouble is
- * of size \a newNbOfTuple and it's values are permuted as required by \a old2New array.
- * The values are permuted so that \c new[ \a old2New[ i ]] = \c old[ i ] for all
- * \a old2New[ i ] >= 0. In other words every i-th tuple in \a this array, for which
- * \a old2New[ i ] is negative, is missing from the result array.
- * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
- * \param [in] old2New - C array of length equal to \a this->getNumberOfTuples()
- * giving a new position for i-th old tuple and giving negative position for
- * for i-th old tuple that should be omitted.
- * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
- * is to delete using decrRef() as it is no more needed.
- */
-DataArrayDouble *DataArrayDouble::renumberAndReduce(const int *old2New, int newNbOfTuple) const throw(INTERP_KERNEL::Exception)
-{
- checkAllocated();
- int nbTuples=getNumberOfTuples();
- int nbOfCompo=getNumberOfComponents();
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
- ret->alloc(newNbOfTuple,nbOfCompo);
- const double *iptr=getConstPointer();
- double *optr=ret->getPointer();
- for(int i=0;i<nbTuples;i++)
- {
- int w=old2New[i];
- if(w>=0)
- std::copy(iptr+i*nbOfCompo,iptr+(i+1)*nbOfCompo,optr+w*nbOfCompo);
- }
- ret->copyStringInfoFrom(*this);
- return ret.retn();
-}
-
-/*!
- * Returns a shorten and permuted copy of \a this array. The new DataArrayDouble is
- * of size \a new2OldEnd - \a new2OldBg and it's values are permuted as required by
- * \a new2OldBg array.
- * The values are permuted so that \c new[ i ] = \c old[ \a new2OldBg[ i ]].
- * This method is equivalent to renumberAndReduce() except that convention in input is
- * \c new2old and \b not \c old2new.
- * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
- * \param [in] new2OldBg - pointer to the beginning of a permutation array that gives a
- * tuple index in \a this array to fill the i-th tuple in the new array.
- * \param [in] new2OldEnd - specifies the end of the permutation array that starts at
- * \a new2OldBg, so that pointer to a tuple index (\a pi) varies as this:
- * \a new2OldBg <= \a pi < \a new2OldEnd.
- * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
- * is to delete using decrRef() as it is no more needed.
- */
-DataArrayDouble *DataArrayDouble::selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const
-{
- checkAllocated();
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
- int nbComp=getNumberOfComponents();
- ret->alloc((int)std::distance(new2OldBg,new2OldEnd),nbComp);
- ret->copyStringInfoFrom(*this);
- double *pt=ret->getPointer();
- const double *srcPt=getConstPointer();
- int i=0;
- for(const int *w=new2OldBg;w!=new2OldEnd;w++,i++)
- std::copy(srcPt+(*w)*nbComp,srcPt+((*w)+1)*nbComp,pt+i*nbComp);
- ret->copyStringInfoFrom(*this);
- return ret.retn();
-}
-
-/*!
- * Returns a shorten and permuted copy of \a this array. The new DataArrayDouble is
- * of size \a new2OldEnd - \a new2OldBg and it's values are permuted as required by
- * \a new2OldBg array.
- * The values are permuted so that \c new[ i ] = \c old[ \a new2OldBg[ i ]].
- * This method is equivalent to renumberAndReduce() except that convention in input is
- * \c new2old and \b not \c old2new.
- * This method is equivalent to selectByTupleId() except that it prevents coping data
- * from behind the end of \a this array.
- * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
- * \param [in] new2OldBg - pointer to the beginning of a permutation array that gives a
- * tuple index in \a this array to fill the i-th tuple in the new array.
- * \param [in] new2OldEnd - specifies the end of the permutation array that starts at
- * \a new2OldBg, so that pointer to a tuple index (\a pi) varies as this:
- * \a new2OldBg <= \a pi < \a new2OldEnd.
- * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
- * is to delete using decrRef() as it is no more needed.
- * \throw If \a new2OldEnd - \a new2OldBg > \a this->getNumberOfTuples().
- */
-DataArrayDouble *DataArrayDouble::selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception)
-{
- checkAllocated();
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
- int nbComp=getNumberOfComponents();
- int oldNbOfTuples=getNumberOfTuples();
- ret->alloc((int)std::distance(new2OldBg,new2OldEnd),nbComp);
- ret->copyStringInfoFrom(*this);
- double *pt=ret->getPointer();
- const double *srcPt=getConstPointer();
- int i=0;
- for(const int *w=new2OldBg;w!=new2OldEnd;w++,i++)
- if(*w>=0 && *w<oldNbOfTuples)
- std::copy(srcPt+(*w)*nbComp,srcPt+((*w)+1)*nbComp,pt+i*nbComp);
- else
- throw INTERP_KERNEL::Exception("DataArrayDouble::selectByTupleIdSafe : some ids has been detected to be out of [0,this->getNumberOfTuples) !");
- ret->copyStringInfoFrom(*this);
- return ret.retn();
-}
-
-/*!
- * Returns a shorten copy of \a this array. The new DataArrayDouble contains every
- * (\a bg + \c i * \a step)-th tuple of \a this array located before the \a end2-th
- * tuple. Indices of the selected tuples are the same as ones returned by the Python
- * command \c range( \a bg, \a end2, \a step ).
- * This method is equivalent to selectByTupleIdSafe() except that the input array is
- * not constructed explicitly.
- * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
- * \param [in] bg - index of the first tuple to copy from \a this array.
- * \param [in] end2 - index of the tuple before which the tuples to copy are located.
- * \param [in] step - index increment to get index of the next tuple to copy.
- * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
- * is to delete using decrRef() as it is no more needed.
- * \sa DataArrayDouble::substr.
- */
-DataArrayDouble *DataArrayDouble::selectByTupleId2(int bg, int end2, int step) const throw(INTERP_KERNEL::Exception)
-{
- checkAllocated();
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
- int nbComp=getNumberOfComponents();
- int newNbOfTuples=GetNumberOfItemGivenBESRelative(bg,end2,step,"DataArrayDouble::selectByTupleId2 : ");
- ret->alloc(newNbOfTuples,nbComp);
- double *pt=ret->getPointer();
- const double *srcPt=getConstPointer()+bg*nbComp;
- for(int i=0;i<newNbOfTuples;i++,srcPt+=step*nbComp)
- std::copy(srcPt,srcPt+nbComp,pt+i*nbComp);
- ret->copyStringInfoFrom(*this);
- return ret.retn();
-}
-
-/*!
- * Returns a shorten copy of \a this array. The new DataArrayDouble contains ranges
- * of tuples specified by \a ranges parameter.
- * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
- * \param [in] ranges - std::vector of std::pair's each of which defines a range
- * of tuples in [\c begin,\c end) format.
- * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
- * is to delete using decrRef() as it is no more needed.
- * \throw If \a end < \a begin.
- * \throw If \a end > \a this->getNumberOfTuples().
- * \throw If \a this is not allocated.
- */
-DataArray *DataArrayDouble::selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const throw(INTERP_KERNEL::Exception)
-{
- checkAllocated();
- int nbOfComp=getNumberOfComponents();
- int nbOfTuplesThis=getNumberOfTuples();
- if(ranges.empty())
- {
- DataArrayDouble *ret=DataArrayDouble::New();
- ret->alloc(0,nbOfComp);
- ret->copyStringInfoFrom(*this);
- return ret;
- }
- int ref=ranges.front().first;
- int nbOfTuples=0;
- bool isIncreasing=true;
- for(std::vector<std::pair<int,int> >::const_iterator it=ranges.begin();it!=ranges.end();it++)
- {
- if((*it).first<=(*it).second)
- {
- if((*it).first>=0 && (*it).second<=nbOfTuplesThis)
- {
- nbOfTuples+=(*it).second-(*it).first;
- if(isIncreasing)
- isIncreasing=ref<=(*it).first;
- ref=(*it).second;
- }
- else
- {
- std::ostringstream oss; oss << "DataArrayDouble::selectByTupleRanges : on range #" << std::distance(ranges.begin(),it);
- oss << " (" << (*it).first << "," << (*it).second << ") is greater than number of tuples of this :" << nbOfTuples << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- else
- {
- std::ostringstream oss; oss << "DataArrayDouble::selectByTupleRanges : on range #" << std::distance(ranges.begin(),it);
- oss << " (" << (*it).first << "," << (*it).second << ") end is before begin !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- if(isIncreasing && nbOfTuplesThis==nbOfTuples)
- return deepCpy();
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
- ret->alloc(nbOfTuples,nbOfComp);
- ret->copyStringInfoFrom(*this);
- const double *src=getConstPointer();
- double *work=ret->getPointer();
- for(std::vector<std::pair<int,int> >::const_iterator it=ranges.begin();it!=ranges.end();it++)
- work=std::copy(src+(*it).first*nbOfComp,src+(*it).second*nbOfComp,work);
- return ret.retn();
-}
-
-/*!
- * Returns a shorten copy of \a this array. The new DataArrayDouble contains all
- * tuples starting from the \a tupleIdBg-th tuple and including all tuples located before
- * the \a tupleIdEnd-th one. This methods has a similar behavior as std::string::substr().
- * This method is a specialization of selectByTupleId2().
- * \param [in] tupleIdBg - index of the first tuple to copy from \a this array.
- * \param [in] tupleIdEnd - index of the tuple before which the tuples to copy are located.
- * If \a tupleIdEnd == -1, all the tuples till the end of \a this array are copied.
- * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
- * is to delete using decrRef() as it is no more needed.
- * \throw If \a tupleIdBg < 0.
- * \throw If \a tupleIdBg > \a this->getNumberOfTuples().
- \throw If \a tupleIdEnd != -1 && \a tupleIdEnd < \a this->getNumberOfTuples().
- * \sa DataArrayDouble::selectByTupleId2
- */
-DataArrayDouble *DataArrayDouble::substr(int tupleIdBg, int tupleIdEnd) const throw(INTERP_KERNEL::Exception)
-{
- checkAllocated();
- int nbt=getNumberOfTuples();
- if(tupleIdBg<0)
- throw INTERP_KERNEL::Exception("DataArrayDouble::substr : The tupleIdBg parameter must be greater than 0 !");
- if(tupleIdBg>nbt)
- throw INTERP_KERNEL::Exception("DataArrayDouble::substr : The tupleIdBg parameter is greater than number of tuples !");
- int trueEnd=tupleIdEnd;
- if(tupleIdEnd!=-1)
- {
- if(tupleIdEnd>nbt)
- throw INTERP_KERNEL::Exception("DataArrayDouble::substr : The tupleIdBg parameter is greater or equal than number of tuples !");
- }
- else
- trueEnd=nbt;
- int nbComp=getNumberOfComponents();
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
- ret->alloc(trueEnd-tupleIdBg,nbComp);
- ret->copyStringInfoFrom(*this);
- std::copy(getConstPointer()+tupleIdBg*nbComp,getConstPointer()+trueEnd*nbComp,ret->getPointer());
- return ret.retn();
-}
-
-/*!
- * Returns a shorten or extended copy of \a this array. If \a newNbOfComp is less
- * than \a this->getNumberOfComponents() then the result array is shorten as each tuple
- * is truncated to have \a newNbOfComp components, keeping first components. If \a
- * newNbOfComp is more than \a this->getNumberOfComponents() then the result array is
- * expanded as each tuple is populated with \a dftValue to have \a newNbOfComp
- * components.
- * \param [in] newNbOfComp - number of components for the new array to have.
- * \param [in] dftValue - value assigned to new values added to the new array.
- * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
- * is to delete using decrRef() as it is no more needed.
- * \throw If \a this is not allocated.
- */
-DataArrayDouble *DataArrayDouble::changeNbOfComponents(int newNbOfComp, double dftValue) const throw(INTERP_KERNEL::Exception)
-{
- checkAllocated();
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
- ret->alloc(getNumberOfTuples(),newNbOfComp);
- const double *oldc=getConstPointer();
- double *nc=ret->getPointer();
- int nbOfTuples=getNumberOfTuples();
- int oldNbOfComp=getNumberOfComponents();
- int dim=std::min(oldNbOfComp,newNbOfComp);
- for(int i=0;i<nbOfTuples;i++)
- {
- int j=0;
- for(;j<dim;j++)
- nc[newNbOfComp*i+j]=oldc[i*oldNbOfComp+j];
- for(;j<newNbOfComp;j++)
- nc[newNbOfComp*i+j]=dftValue;
- }
- ret->setName(getName().c_str());
- for(int i=0;i<dim;i++)
- ret->setInfoOnComponent(i,getInfoOnComponent(i).c_str());
- ret->setName(getName().c_str());
- return ret.retn();
-}
-
-/*!
- * Changes the number of components within \a this array so that its raw data **does
- * not** change, instead splitting this data into tuples changes.
- * \warning This method erases all (name and unit) component info set before!
- * \param [in] newNbOfComp - number of components for \a this array to have.
- * \throw If \a this is not allocated
- * \throw If getNbOfElems() % \a newNbOfCompo != 0.
- * \throw If \a newNbOfCompo is lower than 1.
- * \throw If the rearrange method would lead to a number of tuples higher than 2147483647 (maximal capacity of int32 !).
- * \warning This method erases all (name and unit) component info set before!
- */
-void DataArrayDouble::rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception)
-{
- checkAllocated();
- if(newNbOfCompo<1)
- throw INTERP_KERNEL::Exception("DataArrayDouble::rearrange : input newNbOfCompo must be > 0 !");
- std::size_t nbOfElems=getNbOfElems();
- if(nbOfElems%newNbOfCompo!=0)
- throw INTERP_KERNEL::Exception("DataArrayDouble::rearrange : nbOfElems%newNbOfCompo!=0 !");
- if(nbOfElems/newNbOfCompo>(std::size_t)std::numeric_limits<int>::max())
- throw INTERP_KERNEL::Exception("DataArrayDouble::rearrange : the rearrangement leads to too high number of tuples (> 2147483647) !");
- _info_on_compo.clear();
- _info_on_compo.resize(newNbOfCompo);
- declareAsNew();
-}
-
-/*!
- * Changes the number of components within \a this array to be equal to its number
- * of tuples, and inversely its number of tuples to become equal to its number of
- * components. So that its raw data **does not** change, instead splitting this
- * data into tuples changes.
- * \warning This method erases all (name and unit) component info set before!
- * \warning Do not confuse this method with fromNoInterlace() and toNoInterlace()!
- * \throw If \a this is not allocated.
- * \sa rearrange()
- */
-void DataArrayDouble::transpose() throw(INTERP_KERNEL::Exception)
-{
- checkAllocated();
- int nbOfTuples=getNumberOfTuples();
- rearrange(nbOfTuples);
-}
-
-/*!
- * Returns a copy of \a this array composed of selected components.
- * The new DataArrayDouble has the same number of tuples but includes components
- * specified by \a compoIds parameter. So that getNbOfElems() of the result array
- * can be either less, same or more than \a this->getNbOfElems().
- * \param [in] compoIds - sequence of zero based indices of components to include
- * into the new array.
- * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
- * is to delete using decrRef() as it is no more needed.
- * \throw If \a this is not allocated.
- * \throw If a component index (\a i) is not valid:
- * \a i < 0 || \a i >= \a this->getNumberOfComponents().
- *
- * \ref py_mcdataarraydouble_KeepSelectedComponents "Here is a Python example".
- */
-DataArray *DataArrayDouble::keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception)
-{
- checkAllocated();
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret(DataArrayDouble::New());
- std::size_t newNbOfCompo=compoIds.size();
- int oldNbOfCompo=getNumberOfComponents();
- for(std::vector<int>::const_iterator it=compoIds.begin();it!=compoIds.end();it++)
- if((*it)<0 || (*it)>=oldNbOfCompo)
- {
- std::ostringstream oss; oss << "DataArrayDouble::keepSelectedComponents : invalid requested component : " << *it << " whereas it should be in [0," << oldNbOfCompo << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- int nbOfTuples=getNumberOfTuples();
- ret->alloc(nbOfTuples,(int)newNbOfCompo);
- ret->copyPartOfStringInfoFrom(*this,compoIds);
- const double *oldc=getConstPointer();
- double *nc=ret->getPointer();
- for(int i=0;i<nbOfTuples;i++)
- for(std::size_t j=0;j<newNbOfCompo;j++,nc++)
- *nc=oldc[i*oldNbOfCompo+compoIds[j]];
- return ret.retn();
-}
-
-/*!
- * Appends components of another array to components of \a this one, tuple by tuple.
- * So that the number of tuples of \a this array remains the same and the number of
- * components increases.
- * \param [in] other - the DataArrayDouble to append to \a this one.
- * \throw If \a this is not allocated.
- * \throw If \a this and \a other arrays have different number of tuples.
- *
- * \ref cpp_mcdataarraydouble_meldwith "Here is a C++ example".
- *
- * \ref py_mcdataarraydouble_meldwith "Here is a Python example".
- */
-void DataArrayDouble::meldWith(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception)
-{
- checkAllocated();
- other->checkAllocated();
- int nbOfTuples=getNumberOfTuples();
- if(nbOfTuples!=other->getNumberOfTuples())
- throw INTERP_KERNEL::Exception("DataArrayDouble::meldWith : mismatch of number of tuples !");
- int nbOfComp1=getNumberOfComponents();
- int nbOfComp2=other->getNumberOfComponents();
- double *newArr=(double *)malloc((nbOfTuples*(nbOfComp1+nbOfComp2))*sizeof(double));
- double *w=newArr;
- const double *inp1=getConstPointer();
- const double *inp2=other->getConstPointer();
- for(int i=0;i<nbOfTuples;i++,inp1+=nbOfComp1,inp2+=nbOfComp2)
- {
- w=std::copy(inp1,inp1+nbOfComp1,w);
- w=std::copy(inp2,inp2+nbOfComp2,w);
- }
- useArray(newArr,true,C_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2);
- std::vector<int> compIds(nbOfComp2);
- for(int i=0;i<nbOfComp2;i++)
- compIds[i]=nbOfComp1+i;
- copyPartOfStringInfoFrom2(compIds,*other);
-}
-
-/*!
- * This method checks that all tuples in \a other are in \a this.
- * If true, the output param \a tupleIds contains the tuples ids of \a this that correspond to tupes in \a this.
- * For each i in [ 0 , other->getNumberOfTuples() ) tuple #i in \a other is equal ( regarding input precision \a prec ) to tuple tupleIds[i] in \a this.
- *
- * \param [in] other - the array having the same number of components than \a this.
- * \param [out] tupleIds - the tuple ids containing the same number of tuples than \a other has.
- * \sa DataArrayDouble::findCommonTuples
- */
-bool DataArrayDouble::areIncludedInMe(const DataArrayDouble *other, double prec, DataArrayInt *&tupleIds) const throw(INTERP_KERNEL::Exception)
-{
- if(!other)
- throw INTERP_KERNEL::Exception("DataArrayDouble::areIncludedInMe : input array is NULL !");
- checkAllocated(); other->checkAllocated();
- if(getNumberOfComponents()!=other->getNumberOfComponents())
- throw INTERP_KERNEL::Exception("DataArrayDouble::areIncludedInMe : the number of components does not match !");
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> a=DataArrayDouble::Aggregate(this,other);
- DataArrayInt *c=0,*ci=0;
- a->findCommonTuples(prec,getNumberOfTuples(),c,ci);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cSafe(c),ciSafe(ci);
- int newNbOfTuples=-1;
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::BuildOld2NewArrayFromSurjectiveFormat2(a->getNumberOfTuples(),c->begin(),ci->begin(),ci->end(),newNbOfTuples);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret1=ids->selectByTupleId2(getNumberOfTuples(),a->getNumberOfTuples(),1);
- tupleIds=ret1.retn();
- return newNbOfTuples==getNumberOfTuples();