LINALG(3pm)
π LINALG(3pm) β PDL::GSL::LINALG π
okay bestie, gather round, because this is the PDL interface to the linear algebra routines in GSL, and it is lowkey iconic. it's a User Contributed Perl Documentation page, so you know it's real π«Ά
β¨ NAME β¨
PDL::GSL::LINALG β PDL interface to linear algebra routines in GSL
like. it's giving "Perl meets the GNU Scientific Library and they're holding hands." πΈ
β¨ SYNOPSIS β¨
okay so here's the vibe, no cap:
use PDL::LiteF;
use PDL::MatrixOps; # for 'x'
use PDL::GSL::LINALG;
my $A = pdl [
[0.18, 0.60, 0.57, 0.96],
[0.41, 0.24, 0.99, 0.58],
[0.14, 0.30, 0.97, 0.66],
[0.51, 0.13, 0.19, 0.85],
];
my $B = sequence(2,4); # column vectors
LU_decomp(my $lu=$A->copy, my $p=null, my $signum=null);
# transpose so first dim means is vector, higher dims broadcast
LU_solve($lu, $p, $B->transpose, my $x=null);
$x = $x->inplace->transpose; # now can be matrix-multiplied
see that? matrix in, decomposition out, solve, transpose, slay. π
β¨ DESCRIPTION β¨
so basically this is an interface to the linear algebra package that lives inside the GNU Scientific Library. the functions are named exactly like they are in GSL, except the initial "gsl_linalg_" gets chopped off the front. cute little haircut. βοΈ
and bestie, they come in both real and complex double precision. we love range. π
right now it's only LU decomposition interfaces in here. pull requests welcome! π (yes that's a real line from the docs and honestly? respect the hustle.)
#line 60 "LINALG.pm"
β¨ FUNCTIONS β¨
π LU_decomp π
Signature: ([io,phys]A(n,m); indx [o,phys]ipiv(p); int [o,phys]signum())
LU decomposition of the given (real or complex) matrix. that's the whole thing, bestie. it takes your matrix and breaks it down.
LU_decomp ignores the bad-value flag of the input ndarrays. it will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. so like, it doesn't check your baggage going in, but it'll definitely tag it coming out. π
π LU_solve π
Signature: ([phys]LU(n,m); indx [phys]ipiv(p); [phys]B(n); [o,phys]x(n))
solves "A x = B" using the LU and permutation that "LU_decomp" gave you β real or complex, your choice, we don't gatekeep. π¦
same energy as before: LU_solve ignores the bad-value flag of the input ndarrays, and it will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
π LU_det π
Signature: ([phys]LU(n,m); int [phys]signum(); [o]det())
find the determinant from the LU decomp. yes, the determinant. the big scary number? we got it. β¨
and yep, you guessed it: LU_det ignores the bad-value flag of the input ndarrays, and it will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. consistency is a love language. π«Ά
π solve_tridiag π
Signature: ([phys]diag(n); [phys]superdiag(n); [phys]subdiag(n); [phys]B(n); [o,phys]x(n))
solves "A x = B" where A is a tridiagonal system. real only, because GSL does not have a complex function β not us being lazy, that's just the facts, fr fr. π
and (final time, promise): solve_tridiag ignores the bad-value flag of the input ndarrays, and it will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
β¨ SEE ALSO β¨
PDLβ the whole reason we're here π
and if you want the actual GSL documentation for linear algebra, it's online at:
https://www.gnu.org/software/gsl/doc/html/linalg.html
go read it, it's giving reference material, it's giving citations, it's giving academic. π
and that's the page!! this whole thing is perl v5.38.2, dated 2024-04-10, from the LINALG(3pm) manual β thanks for coming to my TED talk, mwah πβ¨
π¦ where this page comes from
- ubuntu noble: pdl 1:2.085-1ubuntu1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms