return ret;
}
+/*!
+ * Computes for each tuple the sum of number of components values in the tuple and return it.
+ *
+ * \return DataArrayDouble * - the new instance of DataArrayDouble containing the
+ * same number of tuples as \a this array and one component.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this is not allocated.
+ */
+DataArrayDouble *DataArrayDouble::sumPerTuple() const
+{
+ checkAllocated();
+ int nbOfComp(getNumberOfComponents()),nbOfTuple(getNumberOfTuples());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret(DataArrayDouble::New());
+ ret->alloc(nbOfTuple,1);
+ const double *src(getConstPointer());
+ double *dest(ret->getPointer());
+ for(int i=0;i<nbOfTuple;i++,dest++,src+=nbOfComp)
+ *dest=std::accumulate(src,src+nbOfComp,0.);
+ return ret.retn();
+}
+
/*!
* Computes the maximal value within every tuple of \a this array.
* \return DataArrayDouble * - the new instance of DataArrayDouble containing the
declareAsNew();
}
+/*!
+ * Computes for each tuple the sum of number of components values in the tuple and return it.
+ *
+ * \return DataArrayInt * - the new instance of DataArrayInt containing the
+ * same number of tuples as \a this array and one component.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this is not allocated.
+ */
+DataArrayInt *DataArrayInt::sumPerTuple() const
+{
+ checkAllocated();
+ int nbOfComp(getNumberOfComponents()),nbOfTuple(getNumberOfTuples());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New());
+ ret->alloc(nbOfTuple,1);
+ const int *src(getConstPointer());
+ int *dest(ret->getPointer());
+ for(int i=0;i<nbOfTuple;i++,dest++,src+=nbOfComp)
+ *dest=std::accumulate(src,src+nbOfComp,0);
+ return ret.retn();
+}
+
/*!
* Reverse the array values.
* \throw If \a this->getNumberOfComponents() < 1.
MEDCOUPLING_EXPORT DataArrayDouble *trace() const;
MEDCOUPLING_EXPORT DataArrayDouble *deviator() const;
MEDCOUPLING_EXPORT DataArrayDouble *magnitude() const;
+ MEDCOUPLING_EXPORT DataArrayDouble *sumPerTuple() const;
MEDCOUPLING_EXPORT DataArrayDouble *maxPerTuple() const;
MEDCOUPLING_EXPORT DataArrayDouble *maxPerTupleWithCompoId(DataArrayInt* &compoIdOfMaxPerTuple) const;
MEDCOUPLING_EXPORT DataArrayDouble *buildEuclidianDistanceDenseMatrix() const;
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const;
MEDCOUPLING_EXPORT bool isFittingWith(const std::vector<bool>& v) const;
MEDCOUPLING_EXPORT DataArrayInt *buildPermutationArr(const DataArrayInt& other) const;
+ MEDCOUPLING_EXPORT DataArrayInt *sumPerTuple() const;
MEDCOUPLING_EXPORT void sort(bool asc=true);
MEDCOUPLING_EXPORT void reverse();
MEDCOUPLING_EXPORT void checkMonotonic(bool increasing) const;
%newobject ParaMEDMEM::DataArrayInt::getIdsNotEqual;
%newobject ParaMEDMEM::DataArrayInt::getIdsEqualList;
%newobject ParaMEDMEM::DataArrayInt::getIdsNotEqualList;
+%newobject ParaMEDMEM::DataArrayInt::sumPerTuple;
%newobject ParaMEDMEM::DataArrayInt::negate;
%newobject ParaMEDMEM::DataArrayInt::getIdsInRange;
%newobject ParaMEDMEM::DataArrayInt::Aggregate;
%newobject ParaMEDMEM::DataArrayDouble::deviator;
%newobject ParaMEDMEM::DataArrayDouble::magnitude;
%newobject ParaMEDMEM::DataArrayDouble::maxPerTuple;
+%newobject ParaMEDMEM::DataArrayDouble::sumPerTuple;
%newobject ParaMEDMEM::DataArrayDouble::computeBBoxPerTuple;
%newobject ParaMEDMEM::DataArrayDouble::buildEuclidianDistanceDenseMatrix;
%newobject ParaMEDMEM::DataArrayDouble::buildEuclidianDistanceDenseMatrixWith;
DataArrayDouble *deviator() const throw(INTERP_KERNEL::Exception);
DataArrayDouble *magnitude() const throw(INTERP_KERNEL::Exception);
DataArrayDouble *maxPerTuple() const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *sumPerTuple() const throw(INTERP_KERNEL::Exception);
DataArrayDouble *buildEuclidianDistanceDenseMatrix() const throw(INTERP_KERNEL::Exception);
DataArrayDouble *buildEuclidianDistanceDenseMatrixWith(const DataArrayDouble *other) const throw(INTERP_KERNEL::Exception);
void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception);
bool isEqualWithoutConsideringStr(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception);
bool isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception);
DataArrayInt *buildPermutationArr(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *sumPerTuple() const throw(INTERP_KERNEL::Exception);
void sort(bool asc=true) throw(INTERP_KERNEL::Exception);
void reverse() throw(INTERP_KERNEL::Exception);
void checkMonotonic(bool increasing) const throw(INTERP_KERNEL::Exception);