X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingMemArray.cxx;h=e84b23b07256e4ace10b0e8c876704be06defdb4;hb=0ba3453939dda0697b09ed7e728a01d4f33e3ce2;hp=60d04080607fb88487e8e8e2c8c18e9219c24d3e;hpb=aafcf704892f03308a84407e898d9e8b19496a1c;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 60d040806..e84b23b07 100755 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2022 CEA/DEN, EDF R&D +// Copyright (C) 2007-2023 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -2337,16 +2337,7 @@ DataArrayDouble *DataArrayDouble::magnitude() const return ret; } -/*! - * Computes the maximal value within every tuple of \a this array. - * \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. - * \sa DataArrayDouble::maxPerTupleWithCompoId - */ -DataArrayDouble *DataArrayDouble::maxPerTuple() const +DataArrayDouble *DataArrayDouble::operatePerTuple(std::function func) const { checkAllocated(); std::size_t nbOfComp(getNumberOfComponents()); @@ -2356,10 +2347,38 @@ DataArrayDouble *DataArrayDouble::maxPerTuple() const const double *src=getConstPointer(); double *dest=ret->getPointer(); for(mcIdType i=0;ioperatePerTuple([](const double *bg, const double *endd) { return *std::max_element(bg,endd); }); +} + +/*! + * Computes the minimal value within every tuple of \a this array. + * \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. + * \sa DataArrayDouble::maxPerTuple + */ +DataArrayDouble *DataArrayDouble::minPerTuple() const +{ + return this->operatePerTuple([](const double *bg, const double *endd) { return *std::min_element(bg,endd); }); +} + /*! * Computes the maximal value within every tuple of \a this array and it returns the first component * id for each tuple that corresponds to the maximal value within the tuple.