void setContigPartOfSelectedValuesSlice(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step);
T getMaxValue(int& tupleId) const;
T getMaxValueInArray() const;
+ T getMaxAbsValue(std::size_t& tupleId) const;
+ T getMaxAbsValueInArray() const;
T getMinValue(int& tupleId) const;
T getMinValueInArray() const;
MEDCOUPLING_EXPORT void getTuple(int tupleId, T *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
* \return double - the maximal value among all values of \a this array.
* \throw If \a this->getNumberOfComponents() != 1
* \throw If \a this->getNumberOfTuples() < 1
+ * \sa getMaxAbsValue, getMinValue
*/
template<class T>
T DataArrayTemplate<T>::getMaxValue(int& tupleId) const
* one component.
* \return double - the maximal value among all values of \a this array.
* \throw If \a this is not allocated.
+ * \sa getMaxAbsValueInArray, getMinValueInArray
*/
template<class T>
T DataArrayTemplate<T>::getMaxValueInArray() const
return *loc;
}
+ /*!
+ * Returns the maximal absolute value in \a this and the first occurrence location associated to it.
+ * \return the element in this (positive or negative) having the max abs value in \a this.
+ * \throw If \a this is not allocated.
+ * \throw If \a this is non one component array.
+ * \throw If \a this is empty.
+ */
+ template<class T>
+ T DataArrayTemplate<T>::getMaxAbsValue(std::size_t& tupleId) const
+ {
+ checkAllocated();
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxAbsValue : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before or call 'getMaxValueInArray' method !");
+ std::size_t nbTuples(this->getNumberOfTuples());
+ if(nbTuples==0)
+ throw INTERP_KERNEL::Exception("DataArrayTemplate<T>::getMaxAbsValue : empty array !");
+ T ret((T)-1);
+ tupleId=0;
+ const T *pt(begin());
+ for(std::size_t i=0;i<nbTuples;i++,pt++)
+ {
+ T cand(std::abs(*pt));
+ if(cand>ret)
+ {
+ ret=cand;
+ tupleId=i;
+ }
+ }
+ return this->getIJ(tupleId,0);
+ }
+
+ /*!
+ * Returns the maximal absolute value in \a this.
+ * \throw If \a this is not allocated.
+ * \throw If \a this is non one component array.
+ * \throw If \a this is empty.
+ */
+ template<class T>
+ T DataArrayTemplate<T>::getMaxAbsValueInArray() const
+ {
+ std::size_t dummy;
+ return getMaxAbsValue(dummy);
+ }
+
/*!
* Returns the minimal value and its location within \a this one-dimensional array.
* \param [out] tupleId - index of the tuple holding the minimal value.
self.assertTrue((d-center).magnitude().isUniform(radius,1e-10))
self.assertAlmostEqual(ang,-4.712389294301196,12)
pass
+
+ def testDAMaxAbsValue(self):
+ d=DataArrayDouble([-2,3,1.2,-2.9])
+ a,b=d.getMaxAbsValue()
+ self.assertAlmostEqual(a,3.,13)
+ self.assertEqual(b,1)
+ a,b=(-d).getMaxAbsValue()
+ self.assertAlmostEqual(a,-3.,13)
+ self.assertEqual(b,1)
+ self.assertAlmostEqual((-d).getMaxAbsValueInArray(),-3.,13)
+ pass
pass
void checkNoNullValues() const throw(INTERP_KERNEL::Exception);
DataArrayDouble *computeBBoxPerTuple(double epsilon=0.0) const throw(INTERP_KERNEL::Exception);
void recenterForMaxPrecision(double eps) throw(INTERP_KERNEL::Exception);
- double getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
double getMaxValueInArray() const throw(INTERP_KERNEL::Exception);
- double getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
+ double getMaxAbsValueInArray() const throw(INTERP_KERNEL::Exception);
double getMinValueInArray() const throw(INTERP_KERNEL::Exception);
int count(double value, double eps) const throw(INTERP_KERNEL::Exception);
double getAverageValue() const throw(INTERP_KERNEL::Exception);
return ret;
}
+ PyObject *getMaxAbsValue() const throw(INTERP_KERNEL::Exception)
+ {
+ std::size_t tmp;
+ double r1=self->getMaxAbsValue(tmp);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
+ PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
+ return ret;
+ }
+
PyObject *getMaxValue2() const throw(INTERP_KERNEL::Exception)
{
DataArrayInt *tmp;
bool presenceOfValue(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception);
int count(int value) const throw(INTERP_KERNEL::Exception);
int accumulate(int compId) const throw(INTERP_KERNEL::Exception);
- int getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
int getMaxValueInArray() const throw(INTERP_KERNEL::Exception);
- int getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
+ int getMaxAbsValueInArray() const throw(INTERP_KERNEL::Exception);
int getMinValueInArray() const throw(INTERP_KERNEL::Exception);
void abs() throw(INTERP_KERNEL::Exception);
DataArrayInt *computeAbs() const throw(INTERP_KERNEL::Exception);
PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
return ret;
}
+
+ PyObject *getMaxAbsValue(std::size_t& tupleId) const throw(INTERP_KERNEL::Exception)
+ {
+ std::size_t tmp;
+ int r1=self->getMaxAbsValue(tmp);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
+ PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
+ return ret;
+ }
PyObject *getMinValue() const throw(INTERP_KERNEL::Exception)
{