HPL_idamax(3)

πŸ“¦ version 2.2, in fedora 43, fedora 44

πŸ’– 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 int On entry, N specifies the length of the vector x. N must be at least zero. like, zero is fine, negative is not the moment bestie 😭
  • X (local input) β€” const double * On entry, X is an incremented array of dimension at least ( 1 + ( n - 1 ) * abs( INCX ) ) that contains the vector x. yes the abs( INCX ) is doing heavy lifting there, respect it ✨
  • INCX (local input) β€” const int On entry, INCX specifies the increment for the elements of X. INCX must 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