---
name: "PDL::GSL::LINALG"
section: "3pm"
platform: "linux"
package: "pdl"
version: "1:2.081-2"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/PDL::GSL::LINALG"
---

# PDL::GSL::LINALG(3pm)

PDL interface to linear algebra routines in GSL

## NAME

PDL::GSL::LINALG - PDL interface to linear algebra routines in GSL

## SYNOPSIS

```
  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
```

## DESCRIPTION

This is an interface to the linear algebra package present in the GNU Scientific Library. Functions are named as in GSL, but with the initial `"gsl_linalg_"` removed. They are provided in both real and complex double precision.

Currently only LU decomposition interfaces here. Pull requests welcome! #line 59 "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.

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.

### LU\_solve

```
  Signature: ([phys]LU(n,m); indx [phys]ipiv(p); [phys]B(n); [o,phys]x(n))
```

Solve `"A x = B"` using the LU and permutation from "LU\_decomp", real or complex.

LU\_solve 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.

### LU\_det

```
  Signature: ([phys]LU(n,m); int [phys]signum(); [o]det())
```

Find the determinant from the LU decomp.

LU\_det 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.

### solve\_tridiag

```
  Signature: ([phys]diag(n); [phys]superdiag(n); [phys]subdiag(n); [phys]B(n); [o,phys]x(n))
```

Solve `"A x = B"` where A is a tridiagonal system. Real only, because GSL does not have a complex function.

solve\_tridiag 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.

## SEE ALSO

PDL

The GSL documentation for linear algebra is online at \<https://www.gnu.org/software/gsl/doc/html/linalg.html\>
