I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
get GPL
COST (GBP)
this unit 0.10
sub units 0.75
+
0

Largest

Finds the largest value of order k in the given array.
Controller: CodeCogs

Dependents

Info

Interface

C++

Largest

 
template<class T>Tlargestintn
T*data
intk )[inline]
This function makes a call to the Stats/Moments/Smallest function to return the k-th largest value in a data set, therefore using the Hoare selection algorithm. If on input the order k is 1 the maximum entry is sought, while if k is equal to the size of the array, the minimum is calculated.

Example:

#include <codecogs/statistics/moments/largest.h>
#include <iostream>
int main()
{
  double a[6] = {0.2, 1.24, 0.5, 2.54, 2.3, 0.3},
  large = Stats::Moments::largest<double>(6, a, 3);
  std::cout << "The 3rd largest value of the array is: " << large;
  std::cout << std::endl;
  return 0;
}

Output:

The 3rd largest value of the array is: 1.24

References:

SUBSET, a library of C++ combinatorial routines, http://www.csit.fsu.edu/~burkardt/cpp_src/subset/subset.html

Parameters

nthe size of the array
dataan array of numerical data for which you want to determine the k-th smallest value
kthe order of the largest value to return

Returns

the k-th largest value in the given data set

Authors

Anca Filibiu (August 2005)
Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.