NAME
Matrix::Simple - Some simple matrix operations
SYNOPSIS
use Matrix::Simple;
my $matrix = stand($in_file_name);
my $matrix = stand(\@data, $row, $col);
my $value = det($matrix);
my $value = det(\@matrix);
my $tran_matrix = tran($matrix);
my $tran_matrix = tran(\@matrix);
my $adj_matrix = adj($matrix);
my $adj_matrix = adj(\@matrix);
my $inv_matrix = inv($matrix, $round);
my $inv_matrix = inv(\@matrix, $round);
my $new_matrix = num_mult($num, $matrix);
my $new_matrix = num_mult($num, \@matrix);
my $new_matrix = sub($matrix_1, $matrix_2);
my $new_matrix = sub(\@matrix_1, \@matrix_2);
my $new_matrix = add($matrix_1, $matrix_2);
my $new_matrix = add(\@matrix_1, \@matrix_2);
my $new_matrix = mult($matrix_1, $matrix_2);
my $new_matrix = mult(\@matrix_1, \@matrix_2);
show($matrix);
show(\@matrix);
show($matrix, $out_file_name);
show(\@matrix, $out_file_name);
VERSION
1.04
DESCRIPTION
This module provides 10 subroutines for simple matrix operations. With this module, you can:
generate standard two-dimensional matrix form
calculate the determinant of the matrix
get the transposed matrix of the matrix
get the adjoint matrix of the matrix
get the inverse matrix of the matrix
multiplication between number and matrix
subtraction between matrix and matrix
addition between matrix and matrix
multiplication between matrix and matrix
display matrix to designated terminal
FUNCTION
The specific function and usage of each subroutine as follows:
- stand
-
Standardize data into two-dimensional array form (two method).
1. read data from text file (each line is separated by white space) my $matrix = stand($in_file_name); 2. normalize a one-dimensional array into a two-dimensional array my $matrix = stand(\@data, $row, $col); notice: $row and $col are the number of rows and columns, respectively
- det
-
Calculate the determinant of a matrix by Laplace expansion.
my $value = det($matrix); #two-dimensional array reference my $value = det(\@matrix); #two-dimensional array
- tran
-
Get the transposed matrix of the matrix.
my $tran_matrix = tran($matrix); #two-dimensional array reference my $tran_matrix = tran(\@matrix); #two-dimensional array
- adj
-
Get the adjugate matrix of the matrix.
my $adj_matrix = adj($matrix); #two-dimensional array reference my $adj_matrix = adj(\@matrix); #two-dimensional array
- inv
-
Get the inverse matrix of the matrix.
my $inv_matrix = inv($matrix, $round); #two-dimensional array reference my $inv_matrix = inv(\@matrix, $round); #two-dimensional array notice: $round is the number of decimal places to keep(default : 2)
- num_mult
-
Multiplication of number and matrix.
my $new_matrix = num_mult($num, $matrix); #two-dimensional array reference my $new_matrix = num_mult($num, \@matrix); #two-dimensional array
- sub
-
Subtraction of matrix and matrix.
my $new_matrix = sub($matrix_1, $matrix_2); #two-dimensional array reference my $new_matrix = sub(\@matrix_1, \@matrix_2); #two-dimensional array
- add
-
Addition of matrix and matrix.
my $new_matrix = add($matrix_1, $matrix_2); #two-dimensional array reference my $new_matrix = add(\@matrix_1, \@matrix_2); #two-dimensional array
- mult
-
Multiplication of matrix and matrix.
my $new_matrix = mult($matrix_1, $matrix_2); #two-dimensional array reference my $new_matrix = mult(\@matrix_1, \@matrix_2); #two-dimensional array
- show
-
Show matrix to specified place (two place).
1. show to STDOUT show($matrix); #two-dimensional array reference show(\@matrix); #two-dimensional array 2. show to file show($matrix, $out_file_name); #two-dimensional array reference show(\@matrix, $out_file_name); #two-dimensional array
AUTHOR
Xiangjian Gou
862137261@qq.com
DATE
11/30/2018