19 Mar 2006 08:29:09 UTC
- Distribution: Math-Matrix
- Module version: 0.5
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (0)
- Testers (773 / 1 / 0)
- KwaliteeBus factor: 1
- License: unknown
- Download (6.05KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:1 non-PAUSE user
Math::Matrix - Multiply and invert Matrices
The following methods are available:
Constructor arguments are a list of references to arrays of the same length. The arrays are copied. The method returns undef in case of error.
$a = new Math::Matrix ([rand,rand,rand], [rand,rand,rand], [rand,rand,rand]);
If you call
newas method, a zero filled matrix with identical deminsions is returned.
You can clone a matrix by calling:
$b = $a->clone;
You can determine the dimensions of a matrix by calling:
($m, $n) = $a->size;
Concatenates two matrices of same row count. The result is a new matrix or undef in case of error.
$b = new Math::Matrix ([rand],[rand],[rand]); $c = $a->concat($b);
Returns the transposed matrix. This is the matrix where colums and rows of the argument matrix are swaped.
Multiplies two matrices where the length of the rows in the first matrix is the same as the length of the columns in the second matrix. Returns the product or undef in case of error.
Solves a equation system given by the matrix. The number of colums must be greater than the number of rows. If variables are dependent from each other, the second and all further of the dependent coefficients are 0. This means the method can handle such systems. The method returns a matrix containing the solutions in its columns or undef in case of error.
Invert a Matrix using
Multiplies a matrix and a scalar resulting in a matrix of the same dimensions with each element scaled with the scalar.
$a->multiply_scalar(2); scale matrix by factor 2
Add two matrices of the same dimensions.
Decide if two matrices are equal. The criterion is, that each pair of elements differs less than $Math::Matrix::eps.
Compute the determinant of a matrix.
Compute the dot product of two vectors.
Compute the absolute value of a vector.
Normalize a vector.
Compute the cross-product of vectors.
Prints the matrix on STDOUT. If the method has additional parameters, these are printed before the matrix is printed.
Compute the pseudo-inverse of the matrix: ((A'A)^-1)A'
use Math::Matrix; srand(time); $a = new Math::Matrix ([rand,rand,rand], [rand,rand,rand], [rand,rand,rand]); $x = new Math::Matrix ([rand,rand,rand]); $a->print("A\n"); $E = $a->concat($x->transpose); $E->print("Equation system\n"); $s = $E->solve; $s->print("Solutions s\n"); $a->multiply($s)->print("A*s\n");
Ulrich Pfeifer <firstname.lastname@example.org>
Brian J. Watson <email@example.com>
Matthew Brett <firstname.lastname@example.org>
|s||Focus search bar|
|?||Bring up this help dialog|
|g p||Go to pull requests|
|g i||go to github issues (only if github is preferred repository)|
|g a||Go to author|
|g c||Go to changes|
|g i||Go to issues|
|g d||Go to dist|
|g r||Go to repository/SCM|
|g s||Go to source|
|g b||Go to file browse|