HPL_idamax(3)
π HPL_idamax β the "who's the biggest absolute value girlie here" function π
okay bestie, welcome to the HPL Library Functions section of the manual, page HPL_idamax(3). this one's short, sweet, and honestly so useful. let's get into it π«Ά
β¨ NAME β¨
HPL_idamax β 1st k s.t. |x_k| = max_i(|x_i|).
like. literally. it finds the first index k where the absolute value of x_k equals the max of all the |x_i|s. iconic behaviour, no notes π
πΈ SYNOPSIS πΈ
#include "hpl.h"
int HPL_idamax( const int N, const double * X, const int INCX );
π¦ DESCRIPTION π¦
HPL_idamax returns the index in an n-vector x of the first element having maximum absolute value.
bestie note the word first β if there's a tie, you're getting the earliest one, not the last one. that's just the vibe. π
π ARGUMENTS π
N(local input) βconst intOn entry,Nspecifies the length of the vectorx.Nmust be at least zero. like, zero is fine, negative is not the moment bestie πX(local input) βconst double *On entry,Xis an incremented array of dimension at least( 1 + ( n - 1 ) * abs( INCX ) )that contains the vectorx. yes theabs( INCX )is doing heavy lifting there, respect it β¨INCX(local input) βconst intOn entry,INCXspecifies the increment for the elements ofX.INCXmust not be zero. fr fr, zero is a crime here π
π EXAMPLE π
here's the whole little main character moment, verbatim:
#include "hpl.h"
int main(int argc, char *argv[])
{
double x[3];
int imax;
x[0] = 1.0; x[1] = 3.0; x[2] = 2.0;
imax = HPL_idamax( 3, x, 1 );
printf("imax=%d\n", imax);
exit(0);
return(0);
}
so x is 1.0, 3.0, 2.0, and the biggest absolute value is 3.0 sitting at index 1. so imax comes out as 1. slay. π₯
π SEE ALSO π
HPL_daxpy (3)HPL_dcopy (3)HPL_dscal (3)HPL_dswap (3)
and that's the whole page, bestie!! this one comes from HPL 2.2, dated February 24, 2016 β vintage but still eating ππβ¨ go find your maxes, you got this π§πΈ
π¦ where this page comes from
- fedora 43: hpl-doc 2.2-22.fc43 Β· LicenseRef-Callaway-BSD-with-advertising
- fedora 44: hpl-doc 2.2-23.fc44 Β· LicenseRef-Callaway-BSD-with-advertising
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms