HPL_dswap(3)
π HPL_dswap β bestie edition π
okay so you're in the HPL Library Functions section of the manual, page HPL_dswap(3), and honestly? this one is a whole vibe. it's the glow-up where two vectors just... trade places. no cap. π¦
β¨ NAME β¨
HPL_dswap β y <-> x. that's it. that's the tweet. π
πΈ SYNOPSIS πΈ
#include "hpl.h"
void HPL_dswap( const int N, double * X, const int INCX, double * Y,
const int INCY );
look at that signature. chef's kiss. π
π« DESCRIPTION π«
so HPL_dswap swaps the vectors x and y. like, fully swaps them. x becomes what y was, y becomes what x was, and they both walk away changed. it's giving identity crisis but make it math. π₯
π ARGUMENTS π
Nβ (local input)const intβ on entry,Nspecifies the length of the vectors x and y.Nmust be at least zero. yes bestie, zero is allowed. negative is not. don't try it. πXβ (local input/output)double *β on entry,Xis an incremented array of dimension at least( 1 + ( n - 1 ) * abs( INCX ) )that contains the vector x. on exit, the entries of the incremented arrayXare updated with the entries of the incremented arrayY. so it's not just reading, it's receiving. main character energy. β¨INCXβ (local input)const intβ on entry,INCXspecifies the increment for the elements ofX.INCXmust not be zero. fr fr, zero is not the move here. π«Yβ (local input/output)double *β on entry,Yis an incremented array of dimension at least( 1 + ( n - 1 ) * abs( INCY ) )that contains the vector y. on exit, the entries of the incremented arrayYare updated with the entries of the incremented arrayX. mutual exchange. mutual slay. π«ΆINCYβ (local input)const intβ on entry,INCYspecifies the increment for the elements ofY.INCYmust not be zero. same rule, same energy. π
π EXAMPLE π
here's a lil demo, copy-paste ready, no thoughts head empty just swaps:
#include "hpl.h"
int main(int argc, char *argv[])
{
double x[3], y[3];
x[0] = 1.0; x[1] = 2.0; x[2] = 3.0;
y[0] = 4.0; y[1] = 5.0; y[2] = 6.0;
HPL_dswap( 3, x, 1, y, 1 );
printf("x=[%f,%f,%f]\n", x[0], x[1], x[2]);
printf("y=[%f,%f,%f]\n", y[0], y[1], y[2]);
exit(0); return(0);
}
x comes in as 1.0, 2.0, 3.0, y comes in as 4.0, 5.0, 6.0, and after one call to HPL_dswap( 3, x, 1, y, 1 ) they've fully swapped. iconic behaviour, honestly. π
π SEE ALSO π
the girlies in the same friend group:
HPL_daxpy (3)HPL_dcopy (3)HPL_dscal (3)
π heads up:INCXandINCYmust not be zero. andNmust be at least zero. these aren't suggestions bestie, that's just the rules.
okay that's the whole page!! this was HPL 2.2, dated February 24, 2016 β yes she's an older queen but she still ate, and she's still serving swaps to this very day. go forth and swap responsibly. mwah. πππ¦β¨
π¦ 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