---
name: "Math::GSL::MatrixComplex"
section: "3pm"
platform: "linux"
package: "libmath-gsl-perl"
version: "0.45-2+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Math::GSL::MatrixComplex"
---

# Math::GSL::MatrixComplex(3pm)

Complex Matrices

## NAME

Math::GSL::MatrixComplex - Complex Matrices

## SYNOPSIS

```
    use Math::GSL::MatrixComplex qw/:all/;
    my $matrix1 = Math::GSL::MatrixComplex->new(5,5);  # OO interface
    my $matrix3 = $matrix1 + $matrix1;
    my $matrix4 = $matrix1 - $matrix1;
    if($matrix1 == $matrix4) ...
    if($matrix1 != $matrix3) ...
    my $matrix2 = gsl_matrix_complex_alloc(5,5);        # standard interface
```

## Objected Oriented Interface to GSL Math::GSL::MatrixComplex

### new()

Creates a new MatrixComplex object of the given size.

```
    my $matrix = Math::GSL::MatrixComplex->new(10,10);
```

### raw()

Get the underlying GSL matrix object created by SWIG, useful for using gsl\_matrix\_\* functions which do not have an OO counterpart.

```
    my $matrix     = Math::GSL::MatrixComplex->new(3,3);
    my $gsl_matrix = $matrix->raw;
    my $stuff      = gsl_matrix_complex_get($gsl_matrix, 1, 2);
```

### rows()

Returns the number of rows in the matrix.

```
    my $rows = $matrix->rows;
```

### cols()

Returns the number of columns in the matrix.

```
    my $cols = $matrix->cols;
```

### as\_vector()

Returns a 1xN or Nx1 matrix as a Math::GSL::VectorComplex object. Dies if called on a matrix that is not a single row or column. Useful for turning the output of `col()` or `row()` into a vector, like so:

```
    my $vector1 = $matrix->col(0)->as_vector;
    my $vector2 = $matrix->row(1)->as_vector;
```

### as\_list()

Get the contents of a Math::GSL::Matrix object as a Perl list.

```
    my $matrix = Math::GSL::MatrixComplex->new(3,3);
    ...
    my @matrix = $matrix->as_list;
```

### row()

Returns a row matrix of the row you enter.

```
    my $matrix = Math::GSL::MatrixComplex->new(3,3);
    ...
    my $matrix_row = $matrix->row(0);
```

### col()

Returns a col matrix of the column you enter.

```
    my $matrix = Math::GSL::MatrixComplex->new(3,3);
    ...
    my $matrix_col = $matrix->col(0);
```

### set\_row()

Sets a the values of a row with the elements of an array.

```
    my $matrix = Math::GSL::MatrixComplex->new(3,3);
    $matrix->set_row(0, [8, 6, 2]);
```

You can also set multiple rows at once with chained calls:\
     my `$matrix` = Math::GSL::MatrixComplex-\>new(3,3);\
     `$matrix`-\>set\_row(0, \[8, 6, 2\])\
            \-\>set\_row(1, \[2, 4, 1\]);\
     ...

### set\_col()

Sets a the values of a column with the elements of an array.

```
    my $matrix = Math::GSL::MatrixComplex->new(3,3);
    $matrix->set_col(0, [8, 6, 2]);
```

You can also set multiple columns at once with chained calls:\
     my `$matrix` = Math::GSL::MatrixComplex-\>new(3,3);\
     `$matrix`-\>set\_col(0, \[8, 6, 2\])\
            \-\>set\_col(1, \[2, 4, 1\]);\
     ...

### is\_square()

Returns true if a matrix is square, i.e. it has the same number of rows as columns, false otherwise.

### det()

Returns the determinant of a matrix (computed by LU decomposition) or dies if called on a non-square matrix.

```
    my $det = $matrix->det();
```

### zero()

Set a matrix to the zero matrix.

```
    $matrix->zero;
```

### identity()

Set a matrix to the identity matrix, i.e. one on the diagonal and zero elsewhere.

```
    my $I = $matrix->identity;
```

### inverse()

Returns the inverse of a matrix or dies when called on a non-square matrix.

```
    my $inverse = $matrix->inverse;
```

### is\_hermitian()

Returns true if the matrix is hermitian, false otherwise

```
    my $test = $matrix->is_hermitian;
```

### eigenvalues()

### lndet()

Returns the natural log of the absolute value of the determinant of a matrix (computed by LU decomposition) or dies if called on a non-square matrix.

```
    my $lndet = $matrix->lndet();
```

## DESCRIPTION

- "gsl\_matrix\_complex\_alloc "

  - "gsl\_matrix\_complex\_calloc "

  - "gsl\_matrix\_complex\_alloc\_from\_block "

  - "gsl\_matrix\_complex\_alloc\_from\_matrix "

  - "gsl\_vector\_complex\_alloc\_row\_from\_matrix "

  - "gsl\_vector\_complex\_alloc\_col\_from\_matrix "

  - "gsl\_matrix\_complex\_free "

  - "gsl\_matrix\_complex\_submatrix "

  - "gsl\_matrix\_complex\_row "

  - "gsl\_matrix\_complex\_column "

  - "gsl\_matrix\_complex\_diagonal "

  - "gsl\_matrix\_complex\_subdiagonal "

  - "gsl\_matrix\_complex\_superdiagonal "

  - "gsl\_matrix\_complex\_subrow "

  - "gsl\_matrix\_complex\_subcolumn "

  - "gsl\_matrix\_complex\_view\_array "

  - "gsl\_matrix\_complex\_view\_array\_with\_tda "

  - "gsl\_matrix\_complex\_view\_vector "

  - "gsl\_matrix\_complex\_view\_vector\_with\_tda "

  - "gsl\_matrix\_complex\_const\_submatrix "

  - "gsl\_matrix\_complex\_const\_row "

  - "gsl\_matrix\_complex\_const\_column "

  - "gsl\_matrix\_complex\_const\_diagonal "

  - "gsl\_matrix\_complex\_const\_subdiagonal "

  - "gsl\_matrix\_complex\_const\_superdiagonal "

  - "gsl\_matrix\_complex\_const\_subrow "

  - "gsl\_matrix\_complex\_const\_subcolumn "

  - "gsl\_matrix\_complex\_const\_view\_array "

  - "gsl\_matrix\_complex\_const\_view\_array\_with\_tda "

  - "gsl\_matrix\_complex\_const\_view\_vector "

  - "gsl\_matrix\_complex\_const\_view\_vector\_with\_tda "

  - "gsl\_matrix\_complex\_get"

  - "gsl\_matrix\_complex\_set"

  - "gsl\_matrix\_complex\_ptr"

  - "gsl\_matrix\_complex\_const\_ptr"

  - "gsl\_matrix\_complex\_set\_zero "

  - "gsl\_matrix\_complex\_set\_identity "

  - "gsl\_matrix\_complex\_set\_all "

  - "gsl\_matrix\_complex\_fread "

  - "gsl\_matrix\_complex\_fwrite "

  - "gsl\_matrix\_complex\_fscanf "

  - "gsl\_matrix\_complex\_fprintf "

  - "gsl\_matrix\_complex\_memcpy"

  - "gsl\_matrix\_complex\_swap"

  - "gsl\_matrix\_complex\_swap\_rows"

  - "gsl\_matrix\_complex\_swap\_columns"

  - "gsl\_matrix\_complex\_swap\_rowcol"

  - "gsl\_matrix\_complex\_transpose "

  - "gsl\_matrix\_complex\_transpose\_memcpy "

  - "gsl\_matrix\_complex\_isnull "

  - "gsl\_matrix\_complex\_ispos "

  - "gsl\_matrix\_complex\_isneg "

  - "gsl\_matrix\_complex\_add "

  - "gsl\_matrix\_complex\_sub "

  - "gsl\_matrix\_complex\_mul\_elements "

  - "gsl\_matrix\_complex\_div\_elements "

  - "gsl\_matrix\_complex\_scale "

  - "gsl\_matrix\_complex\_add\_constant "

  - "gsl\_matrix\_complex\_add\_diagonal "

  - "gsl\_matrix\_complex\_get\_row"

  - "gsl\_matrix\_complex\_get\_col"

  - "gsl\_matrix\_complex\_set\_row"

  - "gsl\_matrix\_complex\_set\_col"

  For more information on the functions, we refer you to the GSL official documentation \<http://www.gnu.org/software/gsl/manual/html\_node/\>

## AUTHORS

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

## COPYRIGHT AND LICENSE

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.
