Math-Matrix
view release on metacpan or search on metacpan
- nelm()
Returns the number of elements in the matrix.
$n = $x -> nelm();
- nrow()
Returns the number of rows.
$m = $x -> nrow();
- ncol()
Returns the number of columns.
$n = $x -> ncol();
- npag()
Returns the number of pages. A non-matrix has one page.
$n = $x -> pag();
- ndim()
Returns the number of dimensions. This is the number of dimensions along which
the length is different from one.
$n = $x -> ndim();
- bandwidth()
Returns the bandwidth of a matrix. In scalar context, returns the number of the
non-zero diagonal furthest away from the main diagonal. In list context,
separate values are returned for the lower and upper bandwidth.
$n = $x -> bandwidth();
($l, $u) = $x -> bandwidth();
The bandwidth is a non-negative integer. If the bandwidth is 0, the matrix is
diagonal or zero. If the bandwidth is 1, the matrix is tridiagonal. If the
bandwidth is 2, the matrix is pentadiagonal etc.
A matrix with the following pattern, where `x` denotes a non-zero value, would
return 2 in scalar context, and (1,2) in list context.
[ x x x 0 0 0 ]
[ x x x x 0 0 ]
[ 0 x x x x 0 ]
[ 0 0 x x x x ]
[ 0 0 0 x x x ]
[ 0 0 0 0 x x ]
See also `["is_band()"](#is_band)` and `["is_aband()"](#is_aband)`.
## Manipulate matrices
These methods are for combining matrices, splitting matrices, extracing parts of
a matrix, inserting new parts into a matrix, deleting parts of a matrix etc.
There are also methods for shuffling elements around (relocating elements)
inside a matrix.
These methods are not concerned with the values of the elements.
- catrow()
Concatenate rows, i.e., concatenate matrices vertically. Any number of arguments
is allowed. All non-empty matrices must have the same number or columns. The
result is a new matrix.
$x = Math::Matrix -> new([1, 2], [4, 5]); # 2-by-2 matrix
$y = Math::Matrix -> new([3, 6]); # 1-by-2 matrix
$z = $x -> catrow($y); # 3-by-2 matrix
- catcol()
Concatenate columns, i.e., matrices horizontally. Any number of arguments is
allowed. All non-empty matrices must have the same number or rows. The result is
a new matrix.
$x = Math::Matrix -> new([1, 2], [4, 5]); # 2-by-2 matrix
$y = Math::Matrix -> new([3], [6]); # 2-by-1 matrix
$z = $x -> catcol($y); # 2-by-3 matrix
- getrow()
Get the specified row(s). Returns a new matrix with the specified rows. The
number of rows in the output is identical to the number of elements in the
input.
$y = $x -> getrow($i); # get one
$y = $x -> getrow([$i0, $i1, $i2]); # get multiple
- getcol()
Get the specified column(s). Returns a new matrix with the specified columns.
The number of columns in the output is identical to the number of elements in
the input.
$y = $x -> getcol($j); # get one
$y = $x -> getcol([$j0, $j1, $j2]); # get multiple
- delrow()
Delete row(s). Returns a new matrix identical to the invocand but with the
specified row(s) deleted.
$y = $x -> delrow($i); # delete one
$y = $x -> delrow([$i0, $i1, $i2]); # delete multiple
- delcol()
Delete column(s). Returns a new matrix identical to the invocand but with the
specified column(s) deleted.
$y = $x -> delcol($j); # delete one
$y = $x -> delcol([$j0, $j1, $j2]); # delete multiple
- concat()
( run in 1.252 second using v1.01-cache-2.11-cpan-71847e10f99 )