SRC/srscl.f(3)

πŸ’… SRC/srscl.f

okay so this is a page from the LAPACK manual β€” Library Functions Manual, if we're being fancy β€” and it's all about one lil subroutine that rescales a vector without everything exploding into overflow. it's giving "tiny but powerful" energy fr fr 🫢


✨ SYNOPSIS ✨

🌈 Functions/Subroutines

  • subroutine srscl (n, sa, sx, incx) β€” SRSCL multiplies a vector by the reciprocal of a real scalar.

πŸŽ€ Function/Subroutine Documentation πŸŽ€

subroutine srscl (integer n, real sa, real, dimension( * ) sx, integer incx)

SRSCL multiplies a vector by the reciprocal of a real scalar. that's the whole vibe, bestie πŸ’–

🌸 Purpose:

!>
!> SRSCL multiplies an n-element real vector x by the real scalar 1/a.
!> This is done without overflow or underflow as long as
!> the final result x/a does not overflow or underflow.
!>

so like β€” it divides your whole vector by a, but it's smart about it. no overflow, no underflow, as long as the final answer x/a itself fits in range. that caveat is doing a lot of work, so don't sleep on it πŸ‘€

πŸ¦‹ Parameters

  • N β€” N is INTEGER. the number of components of the vector x. lowkey just "how long is your vector" πŸ’…
  • SA β€” SA is REAL. the scalar a which is used to divide each component of x. SA must be >= 0, or the subroutine will divide by zero. 🚨 like, that's not a suggestion, that's a hard requirement β€” ignore it and you get a divide-by-zero situation, no cap.
  • SX β€” SX is REAL array, dimension (1+(N-1)*abs(INCX)). the n-element vector x. yes the dimension expression is that whole thing, write it down exactly, don't get creative ✨
  • INCX β€” INCX is INTEGER. the increment between successive values of the vector SX. and then the spec drops this:
> 0:  SX(1) = X(1) and SX(1+(i-1)*INCX) = x(i),     1< i<= n

iykyk β€” that's the stride math, and it's precise, so respect it 🧚

πŸ‘‘

Author

Univ. of Tennessee

Univ. of California Berkeley

Univ. of Colorado Denver

NAG Ltd.

the whole squad contributed, iconic behavior honestly πŸ’œ

Definition at line 83 of file srscl.f.


⭐ Author ⭐

Generated automatically by Doxygen for LAPACK from the source code. (so if the formatting's a little quirky, blame the robot, not me πŸ™ˆ)


πŸ’€ real talk reminder: SA must be >= 0 β€” the page says it twice-ish, so i'm saying it too. divide-by-zero is not the cute kind of chaos.

LAPACK β€” Version 3.12.0 πŸ¦‹ and that's the page, bestie β€” SRC/srscl.f(3), signed, sealed, slayed. mwah πŸ’‹πŸŽ€

πŸ“¦ where this page comes from