SLASRT2(l)

πŸ“¦ version 1.5, in ubuntu jammy

πŸ’– SLASRT2 πŸ’– β€” the LAPACK routine bestie

okay so this is SLASRT2, a LAPACK routine, and she's literally just here to put your numbers in order. Version 1.5 energy. Let's get into it, no cap.


✨ NAME ✨

SLASRT2 β€” sorts the numbers in D in increasing order (if ID = 'I') or in decreasing order (if ID = 'D'). That's it. That's the whole job. She's an icon, she's a legend, and she's the moment. πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

SUBROUTINE SLASRT2( ID, N, D, KEY, INFO )

    CHARACTER       ID

    INTEGER         INFO, N

    INTEGER         KEY( * )

    REAL            D( * )

the way that she takes five arguments and one of them is literally just a single character telling her which way to go. main character energy fr fr. πŸ’…


🌸 PURPOSE 🌸

Sort the numbers in D in increasing order (if ID = 'I') or in decreasing order (if ID = 'D').

She uses Quick Sort, but β€” and this is the cute part β€” she reverts to Insertion sort on arrays of size <= 20. tiny arrays deserve gentle treatment, periodt. 🧚

The dimension of STACK limits N to about 2**32. so like, enormous, but not infinite, bestie. know your limits. πŸ’€


πŸŽ€ ARGUMENTS πŸŽ€

  • ID (input) CHARACTER*1 β€” the vibe selector:
    • = 'I': sort D in increasing order;
    • = 'D': sort D in decreasing order.
  • N (input) INTEGER β€” the length of the array D. how many little guys are we sorting. πŸ”’
  • D (input/output) REAL array, dimension (N) β€” on entry, the array to be sorted. On exit, D has been sorted into increasing order (D(1) <= ... <= D(N)) or into decreasing order (D(1) >= ... >= D(N)), depending on ID. she comes in messy and leaves immaculate. glow-up of the century. ✨
  • KEY (input/output) INTEGER array, dimension (N) β€” on entry, KEY contains a key to each of the entries in D(). Typically, KEY(I) = I for all I. On exit, KEY is permuted in exactly the same manner as D() was permuted from input to output. Therefore, if KEY(I) = I for all I upon input, then D_out(I) = D_in(KEY(I)). 🫢
not me explaining this like a group chat receipt: KEY tags along with D through the exact same shuffling, so you can always trace every sorted number back to where it started. no number gets lost, everyone gets home safe. πŸ™ˆ
  • INFO (output) INTEGER β€” the status report:
    • = 0: successful exit πŸŽ‰ slay.
    • < 0: if INFO = -i, the i-th argument had an illegal value. bestie noooo one of your arguments is not it. 😭

⚠️ heads up: INFO < 0 means an argument was illegal β€” check which one with -i before you blame the algorithm, okay? she's not the problem. πŸ’…

and that's the whole page! this was the SLASRT2(l) manual page from LAPACK version 1.5, dated 12 May 1997. yes she's vintage, yes she still eats, we love a classic. bye bestie, go sort something. πŸ’–πŸŒˆβ­

πŸ“¦ where this page comes from