Math::...omplex(3pm)
πΈ Math::...omplex(3pm) β a.k.a. Math::GSL::MatrixComplex π
okay so bestie, welcome to the User Contributed Perl Documentation corner of the universe. this is where we talk about Complex Matrices for GSL and honestly? it's giving β¨structured mathβ¨. sit down, grab a strawberry π, let's go.
β¨ NAME β¨
Math::GSL::MatrixComplex β Complex Matrices. yes girl, matrices. but complex. π¦
β¨ SYNOPSIS β¨
two ways to live your life: the OO interface, or the standard interface. pick your fighter π
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
like hello?? you can literally just + and - matrices and do == / != comparisons on them. obsessed. π
β¨ Objected Oriented Interface to GSL Math::GSL::MatrixComplex β¨
this is the main character section. every method, no skips. periodt.
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);
it's the backstage pass π β when the OO wrapper doesn't cover something, you dip into the raw SWIG object.
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;
β οΈ careful bestie: if your matrix is not a single row or a single column, this dies. it said what it said. π
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]);
...
chained calls?? we love a method that hands you back the vibe so you can keep going. π
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();
β οΈ non-square matrix? it dies. LU decomposition said no thank you. π
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;
β οΈ again with the dying β non-square input gets the boot. only squares get inverted around here π
is_hermitian()
Returns true if the matrix is hermitian, false otherwise
my $test = $matrix->is_hermitian;
eigenvalues()
okay so this one literally just... exists. no description was given. it's an icon, it's a mystery, it's 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();
β οΈ yes, non-square = dies. the LU decomposition clique is exclusive fr fr.
β¨ DESCRIPTION β¨
so this section is a whole roster of the raw GSL functions that are in the building. lineup goes crazy:
gsl_matrix_complex_allocgsl_matrix_complex_callocgsl_matrix_complex_alloc_from_blockgsl_matrix_complex_alloc_from_matrixgsl_vector_complex_alloc_row_from_matrixgsl_vector_complex_alloc_col_from_matrixgsl_matrix_complex_freegsl_matrix_complex_submatrixgsl_matrix_complex_rowgsl_matrix_complex_columngsl_matrix_complex_diagonalgsl_matrix_complex_subdiagonalgsl_matrix_complex_superdiagonalgsl_matrix_complex_subrowgsl_matrix_complex_subcolumngsl_matrix_complex_view_arraygsl_matrix_complex_view_array_with_tdagsl_matrix_complex_view_vectorgsl_matrix_complex_view_vector_with_tdagsl_matrix_complex_const_submatrixgsl_matrix_complex_const_rowgsl_matrix_complex_const_columngsl_matrix_complex_const_diagonalgsl_matrix_complex_const_subdiagonalgsl_matrix_complex_const_superdiagonalgsl_matrix_complex_const_subrowgsl_matrix_complex_const_subcolumngsl_matrix_complex_const_view_arraygsl_matrix_complex_const_view_array_with_tdagsl_matrix_complex_const_view_vectorgsl_matrix_complex_const_view_vector_with_tdagsl_matrix_complex_getgsl_matrix_complex_setgsl_matrix_complex_ptrgsl_matrix_complex_const_ptrgsl_matrix_complex_set_zerogsl_matrix_complex_set_identitygsl_matrix_complex_set_allgsl_matrix_complex_freadgsl_matrix_complex_fwritegsl_matrix_complex_fscanfgsl_matrix_complex_fprintfgsl_matrix_complex_memcpygsl_matrix_complex_swapgsl_matrix_complex_swap_rowsgsl_matrix_complex_swap_columnsgsl_matrix_complex_swap_rowcolgsl_matrix_complex_transposegsl_matrix_complex_transpose_memcpygsl_matrix_complex_isnullgsl_matrix_complex_isposgsl_matrix_complex_isneggsl_matrix_complex_addgsl_matrix_complex_subgsl_matrix_complex_mul_elementsgsl_matrix_complex_div_elementsgsl_matrix_complex_scalegsl_matrix_complex_add_constantgsl_matrix_complex_add_diagonalgsl_matrix_complex_get_rowgsl_matrix_complex_get_colgsl_matrix_complex_set_rowgsl_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/>
π«Ά that's the deep lore link right there. if you want the real tea on any of those functions, that's where you go. iykyk.
β¨ 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.
and that's the whole page bestie π this one's running on perl v5.42.3, stamped 2026-08-20, and it's <rainbow>Math::...omplex(3pm)</rainbow> from the User Contributed Perl Documentation collection. slay, floss, and always check is_square() before you det(). πβ¨π¦
π¦ where this page comes from
- ubuntu stonking: libmath-gsl-perl 0.49-1build1 Β· 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