+ if(!other)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::findClosestTupleId : other instance is NULL !");
+ checkAllocated(); other->checkAllocated();
+ int nbOfCompo=getNumberOfComponents();
+ if(nbOfCompo!=other->getNumberOfComponents())
+ {
+ std::ostringstream oss; oss << "DataArrayDouble::findClosestTupleId : number of components in this is " << nbOfCompo;
+ oss << ", whereas number of components in other is " << other->getNumberOfComponents() << "! Should be equal !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ int nbOfTuples=other->getNumberOfTuples();
+ int thisNbOfTuples=getNumberOfTuples();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New(); ret->alloc(nbOfTuples,1);
+ double bounds[6];
+ getMinMaxPerComponent(bounds);
+ switch(nbOfCompo)
+ {
+ case 3:
+ {
+ double xDelta(fabs(bounds[1]-bounds[0])),yDelta(fabs(bounds[3]-bounds[2])),zDelta(fabs(bounds[5]-bounds[4]));
+ double delta=std::max(xDelta,yDelta); delta=std::max(delta,zDelta);
+ double characSize=pow((delta*delta*delta)/((double)thisNbOfTuples),1./3.);
+ BBTreePts<3,int> myTree(begin(),0,0,getNumberOfTuples(),characSize*1e-12);
+ FindClosestTupleIdAlg<3>(myTree,3.*characSize*characSize,other->begin(),nbOfTuples,begin(),thisNbOfTuples,ret->getPointer());
+ break;
+ }
+ case 2:
+ {
+ double xDelta(fabs(bounds[1]-bounds[0])),yDelta(fabs(bounds[3]-bounds[2]));
+ double delta=std::max(xDelta,yDelta);
+ double characSize=sqrt(delta/(double)thisNbOfTuples);
+ BBTreePts<2,int> myTree(begin(),0,0,getNumberOfTuples(),characSize*1e-12);
+ FindClosestTupleIdAlg<2>(myTree,2.*characSize*characSize,other->begin(),nbOfTuples,begin(),thisNbOfTuples,ret->getPointer());
+ break;
+ }
+ case 1:
+ {
+ double characSize=fabs(bounds[1]-bounds[0])/thisNbOfTuples;
+ BBTreePts<1,int> myTree(begin(),0,0,getNumberOfTuples(),characSize*1e-12);
+ FindClosestTupleIdAlg<1>(myTree,1.*characSize*characSize,other->begin(),nbOfTuples,begin(),thisNbOfTuples,ret->getPointer());
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("Unexpected spacedim of coords for findClosestTupleId. Must be 1, 2 or 3.");
+ }
+ return ret.retn();
+}
+
+/*!
+ * Returns a copy of \a this array by excluding coincident tuples. Each tuple is
+ * considered as coordinates of a point in getNumberOfComponents()-dimensional
+ * space. The distance between tuples is computed using norm2. If several tuples are
+ * not far each from other than \a prec, only one of them remains in the result
+ * array. The order of tuples in the result array is same as in \a this one except
+ * that coincident tuples are excluded.
+ * \param [in] prec - minimal absolute distance between two tuples at which they are
+ * considered not coincident.
+ * \param [in] limitTupleId - limit tuple id. If all tuples within a group of coincident
+ * tuples have id strictly lower than \a limitTupleId then they are not excluded.
+ * \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 the number of components is not in [1,2,3].
+ *
+ * \ref cpp_mcdataarraydouble_getdifferentvalues "Here is a Python example".
+ */
+DataArrayDouble *DataArrayDouble::getDifferentValues(double prec, int limitTupleId) const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ DataArrayInt *c0=0,*cI0=0;
+ findCommonTuples(prec,limitTupleId,c0,cI0);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c(c0),cI(cI0);
+ int newNbOfTuples=-1;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n=DataArrayInt::BuildOld2NewArrayFromSurjectiveFormat2(getNumberOfTuples(),c0->begin(),cI0->begin(),cI0->end(),newNbOfTuples);
+ return renumberAndReduce(o2n->getConstPointer(),newNbOfTuples);
+}
+
+/*!
+ * Copy all components in a specified order from another DataArrayDouble.
+ * Both numerical and textual data is copied. The number of tuples in \a this and
+ * the other array can be different.
+ * \param [in] a - the array to copy data from.
+ * \param [in] compoIds - sequence of zero based indices of components, data of which is
+ * to be copied.
+ * \throw If \a a is NULL.
+ * \throw If \a compoIds.size() != \a a->getNumberOfComponents().
+ * \throw If \a compoIds[i] < 0 or \a compoIds[i] > \a this->getNumberOfComponents().
+ *
+ * \ref cpp_mcdataarraydouble_setselectedcomponents "Here is a Python example".
+ */
+void DataArrayDouble::setSelectedComponents(const DataArrayDouble *a, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception)
+{
+ if(!a)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::setSelectedComponents : input DataArrayDouble is NULL !");
+ checkAllocated();
+ copyPartOfStringInfoFrom2(compoIds,*a);
+ std::size_t partOfCompoSz=compoIds.size();
+ int nbOfCompo=getNumberOfComponents();
+ int nbOfTuples=std::min(getNumberOfTuples(),a->getNumberOfTuples());
+ const double *ac=a->getConstPointer();
+ double *nc=getPointer();
+ for(int i=0;i<nbOfTuples;i++)
+ for(std::size_t j=0;j<partOfCompoSz;j++,ac++)
+ nc[nbOfCompo*i+compoIds[j]]=*ac;
+}
+
+/*!
+ * Copy all values from another DataArrayDouble into specified tuples and components
+ * of \a this array. Textual data is not copied.
+ * The tree parameters defining set of indices of tuples and components are similar to
+ * the tree parameters of the Python function \c range(\c start,\c stop,\c step).
+ * \param [in] a - the array to copy values from.
+ * \param [in] bgTuples - index of the first tuple of \a this array to assign values to.
+ * \param [in] endTuples - index of the tuple before which the tuples to assign to
+ * are located.
+ * \param [in] stepTuples - index increment to get index of the next tuple to assign to.
+ * \param [in] bgComp - index of the first component of \a this array to assign values to.
+ * \param [in] endComp - index of the component before which the components to assign
+ * to are located.
+ * \param [in] stepComp - index increment to get index of the next component to assign to.
+ * \param [in] strictCompoCompare - if \a true (by default), then \a a->getNumberOfComponents()
+ * must be equal to the number of columns to assign to, else an
+ * exception is thrown; if \a false, then it is only required that \a
+ * a->getNbOfElems() equals to number of values to assign to (this condition
+ * must be respected even if \a strictCompoCompare is \a true). The number of
+ * values to assign to is given by following Python expression:
+ * \a nbTargetValues =
+ * \c len(\c range(\a bgTuples,\a endTuples,\a stepTuples)) *
+ * \c len(\c range(\a bgComp,\a endComp,\a stepComp)).
+ * \throw If \a a is NULL.
+ * \throw If \a a is not allocated.
+ * \throw If \a this is not allocated.
+ * \throw If parameters specifying tuples and components to assign to do not give a
+ * non-empty range of increasing indices.
+ * \throw If \a a->getNbOfElems() != \a nbTargetValues.
+ * \throw If \a strictCompoCompare == \a true && \a a->getNumberOfComponents() !=
+ * \c len(\c range(\a bgComp,\a endComp,\a stepComp)).
+ *
+ * \ref cpp_mcdataarraydouble_setpartofvalues1 "Here is a Python example".
+ */
+void DataArrayDouble::setPartOfValues1(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
+{
+ if(!a)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::setPartOfValues1 : input DataArrayDouble is NULL !");
+ const char msg[]="DataArrayDouble::setPartOfValues1";
+ checkAllocated();
+ a->checkAllocated();
+ int newNbOfTuples=DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg);
+ int newNbOfComp=DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg);
+ int nbComp=getNumberOfComponents();