| Math-GSL documentation | view source | Contained in the Math-GSL distribution. |
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_getgsl_matrix_complex_setgsl_matrix_complex_ptrgsl_matrix_complex_const_ptrgsl_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_memcpygsl_matrix_complex_swapgsl_matrix_complex_swap_rowsgsl_matrix_complex_swap_columnsgsl_matrix_complex_swap_rowcolgsl_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_rowgsl_matrix_complex_get_colgsl_matrix_complex_set_rowgsl_matrix_complex_set_col
Math::GSL::MatrixComplex - Complex Matrices
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
Creates a new MatrixComplex object of the given size.
my $matrix = Math::GSL::MatrixComplex->new(10,10); =cut
sub new { my ($class, $rows, $cols) = @_; my $this = {}; my $matrix; if ( defined $rows && defined $cols && $rows > 0 && $cols > 0 && (int $rows == $rows) && (int $cols == $cols)){
$matrix = gsl_matrix_complex_alloc($rows,$cols);
} else {
croak( __PACKAGE__.'::new($x,$y) - $x and $y must be positive integers');
}
gsl_matrix_complex_set_zero($matrix);
$this->{_matrix} = $matrix;
($this->{_rows}, $this->{_cols}) = ($rows,$cols);
bless $this, $class;
}
=head2 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);
Returns the number of columns in the matrix.
my $cols = $matrix->cols; =cut
sub cols { (shift)->{_cols} }
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;
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;
=cut
sub as_list($) { my $self = shift; my @matrix; for my $row ( 0 .. $self->rows-1) { push @matrix, map { gsl_matrix_complex_get($self->raw, $row, $_) } (0 .. $self->cols-1 ); } return map { Math::Complex->make( gsl_real($_), gsl_imag($_)) } @matrix; }
Returns a row matrix of the row you enter.
my $matrix = Math::GSL::MatrixComplex->new(3,3);
...
my $matrix_row = $matrix->row(0);
Returns a col matrix of the column you enter.
my $matrix = Math::GSL::MatrixComplex->new(3,3);
...
my $matrix_col = $matrix->col(0);
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]); ...
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]); ...
Returns true if a matrix is square, i.e. it has the same number of rows as columns, false otherwise.
Returns the determinant of a matrix (computed by LU decomposition) or dies if called on a non-square matrix.
my $det = $matrix->det();
Set a matrix to the zero matrix.
$matrix->zero;
Set a matrix to the identity matrix, i.e. one on the diagonal and zero elsewhere.
my $I = $matrix->identity;
Returns the inverse of a matrix or dies when called on a non-square matrix.
my $inverse = $matrix->inverse;
Returns true if the matrix is hermitian, false otherwise
my $test = $matrix->is_hermitian;
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();
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_getgsl_matrix_complex_setgsl_matrix_complex_ptrgsl_matrix_complex_const_ptrgsl_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_memcpygsl_matrix_complex_swapgsl_matrix_complex_swap_rowsgsl_matrix_complex_swap_columnsgsl_matrix_complex_swap_rowcolgsl_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_rowgsl_matrix_complex_get_colgsl_matrix_complex_set_rowgsl_matrix_complex_set_colFor more informations on the functions, we refer you to the GSL offcial documentation http://www.gnu.org/software/gsl/manual/html_node/
Jonathan Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com>
Copyright (C) 2008-2009 Jonathan Leto and Thierry Moisan
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Math-GSL documentation | view source | Contained in the Math-GSL distribution. |