Math::...:Linalg(3pm)

πŸ’– Math::GSL::Linalg β€” the Math::GSL::Linalg manual, part 1 of 3 πŸ’–

okay bestie, buckle UP, we're doing linear systems today and honestly? she's iconic for it. this is Math::GSL::Linalg, from the User Contributed Perl Documentation girlies, and she is all about solving linear systems. no cap. let's get into it ✨


🌸 NAME 🌸

Math::GSL::Linalg β€” Functions for solving linear systems. that's it, that's the whole personality, and honestly? a queen who knows what she wants 🫢


✨ SYNOPSIS ✨

the vibe check, the entrance, the main character moment:

use Math::GSL::Linalg qw/:all/;

one line. pulls in everything. lowkey obsessed with how easy that is πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so like, here's a list of all the functions chilling inside this module β€” every single one, no gatekeeping, periodt:

  • gsl_linalg_matmult
  • gsl_linalg_matmult_mod
  • gsl_linalg_exponential_ss
  • gsl_linalg_householder_transform
  • gsl_linalg_complex_householder_transform

(yes babe, those five are just vibing with no little description next to them. mysterious. we respect it πŸŽ€)

and now for the ones that do spill the tea:

  • gsl_linalg_householder_hm($tau, $v, $A) β€” this one takes the Householder matrix P (defined by the scalar $tau and the vector $v) and applies it to the left-hand side of the matrix $A. on output, the result P A gets stored right back into $A. and the tea? it returns 0 if it succeeded, and 1 otherwise. slay πŸ”₯
  • gsl_linalg_householder_mh($tau, $v, $A) β€” same energy, opposite side: applies the Householder matrix P (again defined by the scalar $tau and the vector $v) to the right-hand side of the matrix $A. on output the result A P is stored in $A. she's giving mirror image, and we love her for it πŸ’œ
  • gsl_linalg_householder_hv($tau, $v, $w) β€” here she applies the Householder transformation P (defined by the scalar $tau and the vector $v) to the vector $w. on output, the result P w is stored in $w. vector on vector action, iykyk 🌈
  • gsl_linalg_householder_hm1 β€” just out here existing, no description, no drama, a true mystery icon πŸ’€
  • gsl_linalg_givens($a,$b,$c,$s) β€” performs a Givens rotation on the vector ($a,$b) and stores the answer in $c and $s.
  • gsl_linalg_givens_gv($v, $i,$j, $c, $s) β€” performs a Givens rotation on the $i and $j-th elements of $v, storing them in $c and $s. very targeted. very precise. we stan a function that knows exactly which elements it's about ✨

more of this manual is incoming babe, we're only at part 1 of 3 β€” don't go anywhere πŸ’–
  • gsl_linalg_complex_householder_hm($tau, $v, $A) β€” bestie it's the exact same move as gsl_linalg_householder_hm, just with the complex glow-up: complex matrix $A, complex value $tau, complex vector $v. same energy, more imaginary parts πŸ’…
  • gsl_linalg_complex_householder_mh($tau, $v, $A) β€” and this one is gsl_linalg_householder_mh again but complex-coded: complex matrix $A, complex value $tau, complex vector $v.
  • gsl_linalg_complex_householder_hv($tau, $v, $w) β€” same as gsl_linalg_householder_hv, but the complex version: complex value $tau, complex vectors $v and $w. slay 🌸
  • gsl_linalg_hessenberg_decomp($A, $tau) β€” okay so this one computes the Hessenberg decomposition of matrix $A by applying the similarity transformation H = U^T A U. On output, H is stored in the upper portion of $A. The info you need to build the matrix U lives in the lower triangular portion of $A. U is a product of N - 2 Householder matrices, no cap. The Householder vectors are stored in the lower portion of $A (below the subdiagonal) and the Householder coefficients are stored in the vector $tau. tau must be of length N. Returns 0 if it succeeded, 1 otherwise. it's giving very precise ✨
  • gsl_linalg_hessenberg_unpack($H, $tau, $U) β€” this one constructs the orthogonal matrix $U out of the info stored in the Hessenberg matrix $H plus the vector $tau. and yeah $H and $tau are literally the outputs from gsl_linalg_hessenberg_decomp, so you can't just roll up with randoms here 🫢
  • gsl_linalg_hessenberg_unpack_accum($H, $tau, $V) β€” similar vibe to gsl_linalg_hessenberg_unpack, except it accumulates the matrix U into $V, so that V' = VU. The matrix $V must be initialized before you call this, okay? and setting $V to the identity matrix gives you the same result as gsl_linalg_hessenberg_unpack. also: if $H is order N, then $V must have N columns but it can have any number of rows. flexible queen 🌈
  • gsl_linalg_hessenberg_set_zero($H) β€” sets the lower triangular portion of $H (below the subdiagonal) to zero. it's the cleanup era: useful for clearing out the Householder vectors after you call gsl_linalg_hessenberg_decomp. self-care honestly 🧚
  • gsl_linalg_hessenberg_submatrix
  • gsl_linalg_hessenberg
  • gsl_linalg_hesstri_decomp($A, $B, $U, $V, $work) β€” computes the Hessenberg-Triangular decomposition of the matrix pair ($A, $B). On output, H is stored in $A, and R is stored in $B. If $U and $V are provided (and yes they may be null, no pressure), the similarity transformations are stored in them. You'll also need additional workspace of length N in the vector $work. πŸ’–
  • gsl_linalg_SV_decomp($A, $V, $S, $work) β€” this factorizes the M-by-N matrix $A into the singular value decomposition A = U S V^T for M >= N. On output the matrix $A is replaced by U. The diagonal elements of the singular value matrix S are stored in the vector $S. The singular values are non-negative and form a non-increasing sequence from S_1 to S_N. The matrix $V contains the elements of V in untransposed form β€” so to form the product U S V^T you gotta take the transpose of V, don't skip that step bestie. A workspace of length N is required in vector $work. This routine uses the Golub-Reinsch SVD algorithm. iconic algorithm behavior πŸ‘‘
  • gsl_linalg_SV_decomp_mod($A, $X, $V, $S, $work) β€” computes the SVD using the modified Golub-Reinsch algorithm, which is faster for M>>N. It requires the vector $work of length N and the N-by-N matrix $X as additional working space. $A and $V are matrices while $S is a vector. speed demon energy πŸ”₯
  • gsl_linalg_SV_decomp_jacobi($A, $V, $S) β€” computes the SVD of the M-by-N matrix $A using one-sided Jacobi orthogonalization for M >= N. The Jacobi method can compute singular values to higher relative accuracy than Golub-Reinsch algorithms. $V is a matrix while $S is a vector. accuracy ate, no crumbs ✨
  • gsl_linalg_SV_solve($U, $V, $S, $b, $x) β€” solves the system A x = b using the singular value decomposition ($U, $S, $V) of A given by gsl_linalg_SV_decomp. Only non-zero singular values get used in computing the solution β€” the parts of the solution corresponding to singular values of zero are just ignored, periodt. Other singular values can be edited out by setting them to zero before you call this function. And in the over-determined case where A has more rows than columns, the system is solved in the least squares sense, returning the solution x which minimizes ||A x - b||_2. math but make it serve πŸ’…
  • gsl_linalg_LU_decomp($a, $p) β€” factorize the matrix $a into the LU decomposition PA = LU. On output the diagonal and upper triangular part of the input matrix A contain the matrix U. The lower triangular part of the input matrix (excluding the diagonal) contains L. The diagonal elements of L are unity, and are not stored β€” they're just implied, lowkey mysterious of them. The function returns two values: the first is 0 if the operation succeeded, 1 otherwise, and the second is the sign of the permutation. two-for-one πŸ’–
  • gsl_linalg_LU_solve($LU, $p, $b, $x) β€” solves the square system A x = b using the LU decomposition of the matrix A into (LU, p) given by gsl_linalg_LU_decomp. $LU is a matrix, $p a permutation, and $b and $x are vectors. Returns 1 if the operation succeeded, 0 otherwise. (yes, flipped from the last one, don't come for me, that's just how it is 😭)
  • gsl_linalg_LU_svx($LU, $p, $x) β€” solves the square system A x = b in-place using the LU decomposition of A into (LU,p). On input $x should contain the right-hand side b, which gets replaced by the solution on output. $LU is a matrix, $p a permutation, $x is a vector. Returns 1 if the operation succeeded, 0 otherwise. 🌸
  • gsl_linalg_LU_refine($A, $LU, $p, $b, $x, $residual) β€” applies an iterative improvement to $x, the solution of $A $x = $b, using the LU decomposition of $A into ($LU,$p). The initial residual $r = $A $x - $b (where $x and $b are vectors) is also computed and stored in the vector $residual. glow-up on your answer, literally 🫢
  • gsl_linalg_LU_invert($LU, $p, $inverse) β€” computes the inverse of a matrix A from its LU decomposition stored in the matrix $LU and the permutation $p, storing the result in the matrix $inverse. flip era πŸ”„
  • gsl_linalg_LU_det($LU, $signum) β€” returns the determinant of a matrix A from its LU decomposition stored in the $LU matrix. It needs the integer $signum, which is the sign of the permutation returned by gsl_linalg_LU_decomp. don't forget to feed it the signum, it will simply not know πŸ’€
  • gsl_linalg_LU_lndet($LU) β€” returns the logarithm of the absolute value of the determinant of a matrix A, from its LU decomposition stored in the $LU matrix. log era, very demure, very mindful ✨
  • gsl_linalg_LU_sgndet($LU, $signum) β€” computes the sign or phase factor of the determinant of a matrix A, det(A)/|det(A)|, from its LU decomposition, $LU. ⭐
  • gsl_linalg_complex_LU_decomp($A, $p) β€” does the same operation as gsl_linalg_LU_decomp but on the complex matrix $A. complex girlies rise πŸ’œ
  • gsl_linalg_complex_LU_solve($LU, $p, $b, $x) β€” solves the square system A x = b using the LU decomposition of A into ($LU, $p) given by gsl_linalg_complex_LU_decomp. πŸ¦‹
  • gsl_linalg_complex_LU_svx($LU, $p, $x) β€” does the same operation as gsl_linalg_LU_svx but on the complex matrix $LU and the complex vector $x. πŸŽ€
  • gsl_linalg_complex_LU_refine($A, $LU, $p, $b, $x, $residual) β€” does the same operation as gsl_linalg_LU_refine but on the complex matrices $A and $LU and with the complex vectors $b, $x and $residual. ❀️
  • gsl_linalg_complex_LU_invert($LU, $p, $inverse) β€” does the same operation as gsl_linalg_LU_invert but on the complex matrices $LU and $inverse. (the original says "matrces" and honestly? typo queen, we respect her 🫢) πŸ’…
  • gsl_linalg_complex_LU_det($LU, $signum) β€” does the same operation as gsl_linalg_LU_det but on the complex matrix $LU.
  • gsl_linalg_complex_LU_lndet($LU) β€” does the same operation as gsl_linalg_LU_det but on the complex matrix $LU. πŸ”₯
  • gsl_linalg_complex_LU_sgndet($LU, $signum) β€” does the same operation as gsl_linalg_LU_sgndet but on the complex matrix $LU.
  • gsl_linalg_QR_decomp($a, $tau) β€” factorize the M-by-N matrix A into the QR decomposition A = Q R. On output the diagonal and upper triangular part of the input matrix $a contain the matrix R. The vector $tau and the columns of the lower triangular part of the matrix $a contain the Householder coefficients and Householder vectors which encode the orthogonal matrix Q. The vector tau must be of length k= min(M,N). write that down πŸ“
  • gsl_linalg_QR_solve($QR, $tau, $b, $x) β€” solves the square system A x = b using the QR decomposition of A into (QR, tau) given by gsl_linalg_QR_decomp. $QR is a matrix, and $tau, $b and $x are vectors.
  • gsl_linalg_QR_svx($QR, $tau, $x) β€” solves the square system A x = b in-place using the QR decomposition of A into the matrix $QR and the vector $tau given by gsl_linalg_QR_decomp. On input, the vector $x should contain the right-hand side b, which gets replaced by the solution on output. 🌸
  • gsl_linalg_QR_lssolve($QR, $tau, $b, $x, $residual) β€” finds the least squares solution to the overdetermined system $A $x = $b where the matrix $A has more rows than columns. The least squares solution minimizes the Euclidean norm of the residual, ||Ax - b||. The routine uses the $QR decomposition of $A into ($QR, $tau) given by gsl_linalg_QR_decomp. The solution is returned in $x. The residual is computed as a by-product and stored in residual. Returns 0 if it succeeded, 1 otherwise. ✨
  • gsl_linalg_QR_QRsolve($Q, $R, $b, $x) β€” solves the system $R $x = $Q**T $b for $x. You can use this when the $QR decomposition of a matrix is available in unpacked form as ($Q, $R). Returns 0 if it succeeded, 1 otherwise. πŸ”₯
  • gsl_linalg_QR_Rsolve($QR, $b, $x) β€” solves the triangular system R $x = $b for $x. It may be useful if the product b' = Q^T b has already been computed using gsl_linalg_QR_QTvec. iykyk 🫢
  • gsl_linalg_QR_Rsvx($QR, $x) β€” solves the triangular system R $x = b for $x in-place. On input $x should contain the right-hand side b and is replaced by the solution on output. This function may be useful if the product b' = Q^T b has already been computed using gsl_linalg_QR_QTvec. Returns 0 if it succeeded, 1 otherwise. πŸ’–
  • gsl_linalg_QR_update($Q, $R, $b, $x) β€” performs a rank-1 update $w $v**T of the QR decomposition ($Q, $R). The update is given by Q'R' = Q R + w v^T where the output matrices Q' and R' are also orthogonal and right triangular. Note that w is destroyed by the update β€” she does not survive, bestie, so don't come looking for her after πŸ’€. Returns 0 if it succeeded, 1 otherwise.
  • gsl_linalg_QR_QTvec($QR, $tau, $v) β€” applies the matrix Q^T encoded in the decomposition ($QR,$tau) to the vector $v, storing the result Q^T v in $v. The matrix multiplication is carried out directly using the encoding of the Householder vectors without needing to form the full matrix Q^T. Returns 0 if it succeeded, 1 otherwise. so efficient, she's not doing extra work for anybody πŸ‘‘
  • gsl_linalg_QR_Qvec($QR, $tau, $v) β€” applies the matrix Q encoded in the decomposition ($QR,$tau) to the vector $v, storing the result Q v in $v. The matrix multiplication is carried out directly using the encoding of the Householder vectors without needing to form
  • ...and that's your full matrix Q right there. This function returns 0 if it succeeded, 1 otherwise. ✨
  • gsl_linalg_QR_QTmat($QR, $tau, $A) β€” applies the matrix Q^T that's encoded in the decomposition ($QR,$tau) onto the matrix $A, and drops the result Q^T A right back into $A. The tea: it does the whole multiplication directly using the encoding of the Householder vectors, so it never has to actually form the full matrix Q^T. No cap. Returns 0 if it succeeded, 1 otherwise. πŸ’–
  • gsl_linalg_QR_unpack($QR, $tau, $Q, $R) β€” unpacks that encoded QR decomposition ($QR,$tau) into the matrices $Q and $R, where $Q is M-by-M and $R is M-by-N. Returns 0 if it succeeded, 1 otherwise.
  • gsl_linalg_R_solve($R, $b, $x) β€” solves the triangular system $R $x = $b for the N-by-N matrix $R. Returns 0 if it succeeded, 1 otherwise. πŸ¦‹
  • gsl_linalg_R_svx($R, $x) β€” solves the triangular system $R $x = b in-place. On input, $x should have the right-hand side b in it, and on output that gets replaced by the solution. She swaps. πŸ’… Returns 0 if it succeeded, 1 otherwise.
  • gsl_linalg_QRPT_decomp($A, $tau, $p, $norm) β€” factorizes the M-by-N matrix $A into the QRP^T decomposition A = Q R P^T. On output, the diagonal and upper triangular part of the input matrix hold the matrix R. The permutation matrix P is stored in the permutation $p. This one returns two values: the first is 0 if the operation succeeded, 1 otherwise. The second is the sign of the permutation, which has the value (-1)^n, where n is the number of interchanges in the permutation. The vector $tau plus the columns of the lower triangular part of the matrix $A hold the Householder coefficients and vectors that encode the orthogonal matrix Q. The vector tau must be of length k=\min(M,N). The matrix Q is related to these components by Q = Q_k ... Q_2 Q_1 where Q_i = I - \tau_i v_i v_i^T and v_i is the Householder vector v_i = (0,...,1,A(i+1,i),A(i+2,i),...,A(m,i)). This is the same storage scheme as used by lapack. The vector norm is a workspace of length N used for column pivoting. The algorithm used to perform the decomposition is Householder QR with column pivoting (Golub & Van Loan, Matrix Computations, Algorithm 5.4.1). 🌸
  • gsl_linalg_QRPT_decomp2($A, $q, $r, $tau, $p, $norm) β€” factorizes the matrix $A into the decomposition A = Q R P^T without modifying $A itself, storing the output in the separate matrices $q and $r. For the rest, it operates exactly like gsl_linalg_QRPT_decomp. She's the gentle version that doesn't destroy your original. πŸ₯Ί

okay bestie, heads up: the doc literally just drop-names the next batch of functions with zero description. Not me reading a list of names with no lore. I'm giving you every single one, exactly as written, because we do not skip content around here. πŸ’€
  • gsl_linalg_QRPT_solve
  • gsl_linalg_QRPT_svx
  • gsl_linalg_QRPT_QRsolve
  • gsl_linalg_QRPT_Rsolve
  • gsl_linalg_QRPT_Rsvx
  • gsl_linalg_QRPT_update
  • gsl_linalg_LQ_decomp
  • gsl_linalg_LQ_solve_T
  • gsl_linalg_LQ_svx_T
  • gsl_linalg_LQ_lssolve_T
  • gsl_linalg_LQ_Lsolve_T
  • gsl_linalg_LQ_Lsvx_T
  • gsl_linalg_L_solve_T
  • gsl_linalg_LQ_vecQ
  • gsl_linalg_LQ_vecQT
  • gsl_linalg_LQ_unpack
  • gsl_linalg_LQ_update
  • gsl_linalg_LQ_LQsolve
  • gsl_linalg_PTLQ_decomp
  • gsl_linalg_PTLQ_decomp2
  • gsl_linalg_PTLQ_solve_T
  • gsl_linalg_PTLQ_svx_T
  • gsl_linalg_PTLQ_LQsolve_T
  • gsl_linalg_PTLQ_Lsolve_T
  • gsl_linalg_PTLQ_Lsvx_T
  • gsl_linalg_PTLQ_update

  • gsl_linalg_cholesky_decomp($A) β€” factorizes the symmetric, positive-definite square matrix $A into the Cholesky decomposition A = L L^T and stores it into the matrix $A. And the return value? The doc says it returns 0 if the operation succeeded, 0 otherwise. Yes. Both. Zero. That's what it says, and I am reporting, not judging. πŸ™ˆ
  • gsl_linalg_cholesky_solve($cholesky, $b, $x) β€” solves the system A x = b using the Cholesky decomposition of A into the matrix $cholesky given by gsl_linalg_cholesky_decomp. $b and $x are vectors. The function returns 0 if the operation succeeded, 0 otherwise. ✨
  • gsl_linalg_cholesky_svx($cholesky, $x) β€” solves the system A x = b in-place using the Cholesky decomposition of A into the matrix $cholesky given by gsl_linalg_cholesky_decomp. On input, the vector $x should contain the right-hand side b, which is replaced by the solution on output. The function returns 0 if the operation succeeded, 0 otherwise. πŸ’œ
  • gsl_linalg_cholesky_decomp_unit β€” (name-dropped, no description, but she's here and she counts πŸŽ€)
  • gsl_linalg_complex_cholesky_decomp($A) β€” factorizes the symmetric, positive-definite square matrix $A that contains complex numbers into the Cholesky decomposition A = L L^T and stores it into the matrix $A. Returns 0 if the operation succeeded, 0 otherwise. Complex girlies rise 🌈
  • gsl_linalg_complex_cholesky_solve($cholesky, $b, $x) β€” solves the system A x = b using the Cholesky decomposition of A into the matrix $cholesky given by gsl_linalg_complex_cholesky_decomp. $b and $x are vectors. Returns 0 if the operation succeeded, 0 otherwise.
  • gsl_linalg_complex_cholesky_svx($cholesky, $x) β€” solves the system A x = b in-place using the Cholesky decomposition of A into the matrix $cholesky given by gsl_linalg_complex_cholesky_decomp. On input, the vector $x should contain the right-hand side b, which is replaced by the solution on output. Returns 0 if the operation succeeded, 0 otherwise. πŸ’…

  • gsl_linalg_symmtd_decomp($A, $tau) β€” factorizes the symmetric square matrix $A into the symmetric tridiagonal decomposition Q T Q^T. On output, the diagonal and subdiagonal part of the input matrix $A contain the tridiagonal matrix T. The remaining lower triangular part of the input matrix contains the Householder vectors which, together with the Householder coefficients $tau, encode the orthogonal matrix Q. This storage scheme is the same as used by lapack. The upper triangular part of $A is not referenced. $tau is a vector. πŸ¦‹
  • gsl_linalg_symmtd_unpack($A, $tau, $Q, $diag, $subdiag) β€” unpacks the encoded symmetric tridiagonal decomposition ($A, $tau) obtained from gsl_linalg_symmtd_decomp into the orthogonal matrix $Q, the vector of diagonal elements $diag, and the vector of subdiagonal elements $subdiag. Opening the box, iconic behavior 🎁
  • gsl_linalg_symmtd_unpack_T($A, $diag, $subdiag) β€” unpacks the diagonal and subdiagonal of the encoded symmetric tridiagonal decomposition ($A, $tau) obtained from gsl_linalg_symmtd_decomp into the vectors $diag and $subdiag. (Just the T part. Minimalist. ✨)
  • gsl_linalg_hermtd_decomp($A, $tau) β€” factorizes the hermitian matrix $A into the symmetric tridiagonal decomposition U T U^T. On output, the real parts of the diagonal and subdiagonal part of the input matrix $A contain the tridiagonal matrix T. The remaining lower triangular part of the input matrix contains the Householder vectors which, together with the Householder coefficients $tau, encode the orthogonal matrix Q. This storage scheme is the same as used by lapack. The upper triangular part of $A and the imaginary parts of the diagonal are not referenced. $A is a complex matrix and $tau a complex vector. πŸ’œ
  • gsl_linalg_hermtd_unpack($A, $tau, $U, $diag, $subdiag) β€” unpacks the encoded tridiagonal decomposition ($A, $tau) obtained from gsl_linalg_hermtd_decomp into the unitary complex matrix $U, the real vector of diagonal elements $diag, and the real vector of subdiagonal elements $subdiag.
  • gsl_linalg_hermtd_unpack_T($A, $diag, $subdiag) β€” unpacks the diagonal and subdiagonal of the encoded tridiagonal decomposition (A, tau) obtained from the gsl_linalg_hermtd_decomp into the real vectors $diag and $subdiag.

  • gsl_linalg_HH_solve($a, $b, $x) β€” solves the system $A $x = $b directly using Householder transformations, where $A is a matrix and $b and $x are vectors. On output the solution is stored in $x and $b is not modified. 🫢
⚠️ But listen β€” $A is destroyed by the Householder transformations. She ate, and she took the matrix with her. 😭
  • gsl_linalg_HH_svx($A, $x) β€” solves the system $A $x = b in-place using Householder transformations, where $A is a matrix and $b is a vector. On input, $x should contain the right-hand side b, which is replaced by the solution on output.
⚠️ And same energy: the matrix $A is destroyed by the Householder transformations. RIP to $A, she was a real one. πŸ’€
  • gsl_linalg_solve_symm_tridiag
  • gsl_linalg_solve_tridiag
  • gsl_linalg_solve_symm_cyc_tridiag
  • gsl_linalg_solve_cyc_tridiag
  • gsl_linalg_bidiag_decomp
  • gsl_linalg_bidiag_unpack
  • gsl_linalg_bidiag_unpack2
  • gsl_linalg_bidiag_unpack_B
  • gsl_linalg_balance_matrix
  • gsl_linalg_balance_accum
  • gsl_linalg_balance_columns

(Again: just names, zero description in the doc. I'm being faithful, bestie, not lazy. πŸ’…)


So how do you actually use any of this? You have to add the functions you want to use inside the qw /put_function_here / with spaces between each function. And you can also write use Math::GSL::Complex qw/:all/ to use all available functions of the module. Easy ✨

For more information on the functions, we refer you to the GSL official documentation:

<http://www.gnu.org/software/gsl/manual/html_node/>


πŸ§ͺ EXAMPLES πŸ§ͺ

This example shows how to compute the determinant of a matrix with the LU decomposition:

use Math::GSL::Matrix qw/:all/;
use Math::GSL::Permutation qw/:all/;
use Math::GSL::Linalg qw/:all/;

my $Matrix = gsl_matrix_alloc(4,4);
map { gsl_matrix_set($Matrix, 0, $_, $_+1) } (0..3);

gsl_matrix_set($Matrix,1, 0, 2);
gsl_matrix_set($Matrix, 1, 1, 3);
gsl_matrix_set($Matrix, 1, 2, 4);
gsl_matrix_set($Matrix, 1, 3, 1);

gsl_matrix_set($Matrix, 2, 0, 3);
gsl_matrix_set($Matrix, 2, 1, 4);
gsl_matrix_set($Matrix, 2, 2, 1);
gsl_matrix_set($Matrix, 2, 3, 2);

gsl_matrix_set($Matrix, 3, 0, 4);
gsl_matrix_set($Matrix, 3, 1, 1);
gsl_matrix_set($Matrix, 3, 2, 2);
gsl_matrix_set($Matrix, 3, 3, 3);

my $permutation = gsl_permutation_alloc(4);
gsl_permutation_init($permutation);
my ($result, $signum) = gsl_linalg_LU_decomp($Matrix, $permutation);
my $det = gsl_linalg_LU_det($Matrix, $signum);
print "The value of the determinant of the matrix is $det \n";

Determinant acquired, main character energy achieved πŸ‘‘πŸ”’


πŸ‘‘ AUTHORS πŸ‘‘

Jonathan "Duke" Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com>


Copyright (C) 2008-2024 Jonathan "Duke" Leto and Thierry Moisan

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole page, bestie πŸ’– this was perl v5.42.3, dated 2026-08-20, and she served every single line. go solve something iconic with her 🌟🫢

πŸ“¦ where this page comes from