+/*!
+ * Accumulates values of each component of \a this array.
+ * \param [out] res - an array of length \a this->getNumberOfComponents(), allocated
+ * by the caller, that is filled by this method with sum value for each
+ * component.
+ * \throw If \a this is not allocated.
+ */
+void DataArrayInt::accumulate(int *res) const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ const int *ptr=getConstPointer();
+ int nbTuple=getNumberOfTuples();
+ int nbComps=getNumberOfComponents();
+ std::fill(res,res+nbComps,0);
+ for(int i=0;i<nbTuple;i++)
+ std::transform(ptr+i*nbComps,ptr+(i+1)*nbComps,res,res,std::plus<int>());
+}
+
+int DataArrayInt::accumulate(int compId) const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ const int *ptr=getConstPointer();
+ int nbTuple=getNumberOfTuples();
+ int nbComps=getNumberOfComponents();
+ if(compId<0 || compId>=nbComps)
+ throw INTERP_KERNEL::Exception("DataArrayInt::accumulate : Invalid compId specified : No such nb of components !");
+ int ret=0;
+ for(int i=0;i<nbTuple;i++)
+ ret+=ptr[i*nbComps+compId];
+ return ret;
+}
+
+/*!
+ * This method accumulate using addition tuples in \a this using input index array [ \a bgOfIndex, \a endOfIndex ).
+ * The returned array will have same number of components than \a this and number of tuples equal to
+ * \c std::distance(bgOfIndex,endOfIndex) \b minus \b one.
+ *
+ * The input index array is expected to be ascendingly sorted in which the all referenced ids should be in [0, \c this->getNumberOfTuples).
+ *
+ * \param [in] bgOfIndex - begin (included) of the input index array.
+ * \param [in] endOfIndex - end (excluded) of the input index array.
+ * \return DataArrayInt * - the new instance having the same number of components than \a this.
+ *
+ * \throw If bgOfIndex or end is NULL.
+ * \throw If input index array is not ascendingly sorted.
+ * \throw If there is an id in [ \a bgOfIndex, \a endOfIndex ) not in [0, \c this->getNumberOfTuples).
+ * \throw If std::distance(bgOfIndex,endOfIndex)==0.
+ */
+DataArrayInt *DataArrayInt::accumulatePerChunck(const int *bgOfIndex, const int *endOfIndex) const throw(INTERP_KERNEL::Exception)
+{
+ if(!bgOfIndex || !endOfIndex)
+ throw INTERP_KERNEL::Exception("DataArrayInt::accumulatePerChunck : input pointer NULL !");
+ checkAllocated();
+ int nbCompo=getNumberOfComponents();
+ int nbOfTuples=getNumberOfTuples();
+ int sz=(int)std::distance(bgOfIndex,endOfIndex);
+ if(sz<1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::accumulatePerChunck : invalid size of input index array !");
+ sz--;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New(); ret->alloc(sz,nbCompo);
+ const int *w=bgOfIndex;
+ if(*w<0 || *w>=nbOfTuples)
+ throw INTERP_KERNEL::Exception("DataArrayInt::accumulatePerChunck : The first element of the input index not in [0,nbOfTuples) !");
+ const int *srcPt=begin()+(*w)*nbCompo;
+ int *tmp=ret->getPointer();
+ for(int i=0;i<sz;i++,tmp+=nbCompo,w++)
+ {
+ std::fill(tmp,tmp+nbCompo,0.);
+ if(w[1]>=w[0])
+ {
+ for(int j=w[0];j<w[1];j++,srcPt+=nbCompo)
+ {
+ if(j>=0 && j<nbOfTuples)
+ std::transform(srcPt,srcPt+nbCompo,tmp,tmp,std::plus<int>());
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::accumulatePerChunck : At rank #" << i << " the input index array points to id " << j << " should be in [0," << nbOfTuples << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ }
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::accumulatePerChunck : At rank #" << i << " the input index array is not in ascendingly sorted.";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ ret->copyStringInfoFrom(*this);
+ return ret.retn();
+}
+
+/*!
+ * Returns a new DataArrayInt by concatenating two given arrays, so that (1) the number
+ * of tuples in the result array is <em> a1->getNumberOfTuples() + a2->getNumberOfTuples() -
+ * offsetA2</em> and (2)
+ * the number of component in the result array is same as that of each of given arrays.
+ * First \a offsetA2 tuples of \a a2 are skipped and thus are missing from the result array.
+ * Info on components is copied from the first of the given arrays. Number of components
+ * in the given arrays must be the same.
+ * \param [in] a1 - an array to include in the result array.
+ * \param [in] a2 - another array to include in the result array.
+ * \param [in] offsetA2 - number of tuples of \a a2 to skip.
+ * \return DataArrayInt * - the new instance of DataArrayInt.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If either \a a1 or \a a2 is NULL.
+ * \throw If \a a1->getNumberOfComponents() != \a a2->getNumberOfComponents().
+ */