functionFindMultiExtremum

Extract the n smallest values (ascending=true) or greatest values (ascending=false) of a vector X

Information

FindMultiExtremum returns a vector containing the n (where n <N) extreme values of the input vector X and their indexes.

Hypothesis and equations

This function takes as input :

  • a vector X made of N real values,
  • n, the number of extreme values to extract from the vector X
  • The boolean ascending, to set if extreme values wanted are the smallest ones (=true) or the greatest ones (=false)

FindMultiExtremum returns a vector Xm contenant les n (où n < N) containing the n (where n < N) extreme values of the input vector X and the vector Indm containing their indexes in the vector X.

Bibliography

none

Instructions for use

u = {1, 3, 4, 5, 4, 3}

(X,Ind)=FindMultiExtremum(X=u,n=4,ascending=false)

Declaring variable: Real X [4];

Declaring variable: Integer Ind [4];

X = {5.0, 4.0, 4.0, 3.0}, Ind = {4, 3, 5, 2}

Known limits / Use precautions

none

Validations

Validated function - Gilles Plessis, Hassan Bouia 06/2012

--------------------------------------------------------------
Licensed by EDF under a 3-clause BSD-license
Copyright © EDF 2009 - 2023
BuildSysPro version 3.6.0
Author : Gilles PLESSIS, Hassan BOUIA, EDF (2012)
--------------------------------------------------------------

Inputs

TypeNameDefaultDescription
IntegernNumber of extreme values to extract to the vector X
RealXVector of reals
Booleanascendingfalse

Outputs

TypeNameDefaultDescription
Real[n]XmOrdered extreme values of the vector X
Integer[n]IndmCorresponding indexes in the vector X

Revisions

Benoît Charrier 01/2016 : Adaptation pour compatibilité avec OpenModelica