declareAsNew();
}
-/*!
- * Converts every value of \a this array to its absolute value.
- * \b WARNING this method is non const. If a new DataArrayDouble instance should be built containing the result of abs DataArrayDouble::computeAbs
- * should be called instead.
- *
- * \throw If \a this is not allocated.
- * \sa DataArrayDouble::computeAbs
- */
-void DataArrayDouble::abs()
-{
- checkAllocated();
- double *ptr(getPointer());
- std::size_t nbOfElems(getNbOfElems());
- std::transform(ptr,ptr+nbOfElems,ptr,std::ptr_fun<double,double>(fabs));
- declareAsNew();
-}
-
-/*!
- * This method builds a new instance of \a this object containing the result of std::abs applied of all elements in \a this.
- * This method is a const method (that do not change any values in \a this) contrary to DataArrayDouble::abs method.
- *
- * \return DataArrayDouble * - the new instance of DataArrayDouble containing the
- * same number of tuples and component as \a this array.
- * The caller is to delete this result array using decrRef() as it is no more
- * needed.
- * \throw If \a this is not allocated.
- * \sa DataArrayDouble::abs
- */
-DataArrayDouble *DataArrayDouble::computeAbs() const
-{
- checkAllocated();
- DataArrayDouble *newArr(DataArrayDouble::New());
- int nbOfTuples(getNumberOfTuples());
- int nbOfComp(getNumberOfComponents());
- newArr->alloc(nbOfTuples,nbOfComp);
- std::transform(begin(),end(),newArr->getPointer(),std::ptr_fun<double,double>(fabs));
- newArr->copyStringInfoFrom(*this);
- return newArr;
-}
-
/*!
* Modify all elements of \a this array, so that
* an element _x_ becomes \f$ numerator / x \f$.
}
}
-/*!
- * Converts every value of \a this array to its absolute value.
- * \b WARNING this method is non const. If a new DataArrayInt instance should be built containing the result of abs DataArrayInt::computeAbs
- * should be called instead.
- *
- * \throw If \a this is not allocated.
- * \sa DataArrayInt::computeAbs
- */
-void DataArrayInt::abs()
-{
- checkAllocated();
- int *ptr(getPointer());
- std::size_t nbOfElems(getNbOfElems());
- std::transform(ptr,ptr+nbOfElems,ptr,std::ptr_fun<int,int>(std::abs));
- declareAsNew();
-}
-
-/*!
- * This method builds a new instance of \a this object containing the result of std::abs applied of all elements in \a this.
- * This method is a const method (that do not change any values in \a this) contrary to DataArrayInt::abs method.
- *
- * \return DataArrayInt * - the new instance of DataArrayInt containing the
- * same number of tuples and component as \a this array.
- * The caller is to delete this result array using decrRef() as it is no more
- * needed.
- * \throw If \a this is not allocated.
- * \sa DataArrayInt::abs
- */
-DataArrayInt *DataArrayInt::computeAbs() const
-{
- checkAllocated();
- DataArrayInt *newArr(DataArrayInt::New());
- int nbOfTuples(getNumberOfTuples());
- int nbOfComp(getNumberOfComponents());
- newArr->alloc(nbOfTuples,nbOfComp);
- std::transform(begin(),end(),newArr->getPointer(),std::ptr_fun<int,int>(std::abs));
- newArr->copyStringInfoFrom(*this);
- return newArr;
-}
-
/*!
* Modify all elements of \a this array, so that
* an element _x_ becomes \f$ numerator / x \f$.
MEDCOUPLING_EXPORT void meldWith(const typename Traits<T>::ArrayType *other);
MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *duplicateEachTupleNTimes(int nbTimes) const;
MEDCOUPLING_EXPORT void aggregate(const typename Traits<T>::ArrayType *other);
+ MEDCOUPLING_EXPORT void abs();
+ MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *computeAbs() const;
protected:
static typename Traits<T>::ArrayType *PerformCopyOrIncrRef(bool dCpy, const typename Traits<T>::ArrayType& self);
template<class OP>
MEDCOUPLING_EXPORT DataArrayDouble *buildEuclidianDistanceDenseMatrix() const;
MEDCOUPLING_EXPORT DataArrayDouble *buildEuclidianDistanceDenseMatrixWith(const DataArrayDouble *other) const;
MEDCOUPLING_EXPORT void sortPerTuple(bool asc);
- MEDCOUPLING_EXPORT void abs();
- MEDCOUPLING_EXPORT DataArrayDouble *computeAbs() const;
MEDCOUPLING_EXPORT void applyInv(double numerator);
MEDCOUPLING_EXPORT void applyPow(double val);
MEDCOUPLING_EXPORT void applyRPow(double val);
MEDCOUPLING_EXPORT int accumulate(int compId) const;
MEDCOUPLING_EXPORT DataArrayInt *accumulatePerChunck(const int *bgOfIndex, const int *endOfIndex) const;
MEDCOUPLING_EXPORT void getMinMaxValues(int& minValue, int& maxValue) const;
- MEDCOUPLING_EXPORT void abs();
- MEDCOUPLING_EXPORT DataArrayInt *computeAbs() const;
MEDCOUPLING_EXPORT void applyInv(int numerator);
MEDCOUPLING_EXPORT void applyDivideBy(int val);
MEDCOUPLING_EXPORT void applyModulus(int val);
throw INTERP_KERNEL::Exception("DataArrayDouble::aggregate : mismatch number of components !");
this->_mem.insertAtTheEnd(other->begin(),other->end());
}
+
+ /*!
+ * Converts every value of \a this array to its absolute value.
+ * \b WARNING this method is non const. If a new DataArrayDouble instance should be built containing the result of abs DataArrayDouble::computeAbs
+ * should be called instead.
+ *
+ * \throw If \a this is not allocated.
+ * \sa DataArrayDouble::computeAbs
+ */
+ template<class T>
+ void DataArrayTemplateClassic<T>::abs()
+ {
+ this->checkAllocated();
+ T *ptr(this->getPointer());
+ std::size_t nbOfElems(this->getNbOfElems());
+ std::transform(ptr,ptr+nbOfElems,ptr,std::ptr_fun<T,T>(std::abs));
+ this->declareAsNew();
+ }
+
+ /*!
+ * This method builds a new instance of \a this object containing the result of std::abs applied of all elements in \a this.
+ * This method is a const method (that do not change any values in \a this) contrary to DataArrayDouble::abs method.
+ *
+ * \return DataArrayDouble * - the new instance of DataArrayDouble containing the
+ * same number of tuples and component as \a this array.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this is not allocated.
+ * \sa DataArrayDouble::abs
+ */
+ template<class T>
+ typename Traits<T>::ArrayType *DataArrayTemplateClassic<T>::computeAbs() const
+ {
+ this->checkAllocated();
+ MCAuto<typename Traits<T>::ArrayType> newArr(Traits<T>::ArrayType::New());
+ int nbOfTuples(this->getNumberOfTuples());
+ int nbOfComp(this->getNumberOfComponents());
+ newArr->alloc(nbOfTuples,nbOfComp);
+ std::transform(this->begin(),this->end(),newArr->getPointer(),std::ptr_fun<T,T>(std::abs));
+ newArr->copyStringInfoFrom(*this);
+ return newArr.retn();
+ }
/*!
* Checks if all values in \a this array are equal to \a val at precision \a eps.