# Matrix

3*3 matrix manipulation

## Synopsis

Example t/matrix.t

`````` #_ Matrix _____________________________________________________________
# Test 3*3 matrices
#______________________________________________________________________

use Math::Zap::Matrix identity=>i;
use Math::Zap::Vector;
use Test::Simple tests=>8;

my (\$a, \$b, \$c, \$v);

\$a = matrix
(8, 0, 0,
0, 8, 0,
0, 0, 8
);

\$b = matrix
(4, 2, 0,
2, 4, 2,
0, 2, 4
);

\$c = matrix
(4, 2, 1,
2, 4, 2,
1, 2, 4
);

\$v = vector(1,2,3);

ok(\$a/\$a           == i());
ok(\$b/\$b           == i());
ok(\$c/\$c           == i());
ok(2/\$a*\$a/2       == i());
ok((\$a+\$b)/(\$a+\$b) == i());
ok((\$a-\$c)/(\$a-\$c) == i());
ok(-\$a/-\$a         == i());
ok(1/\$a*(\$a*\$v)    == \$v);
``````

## Description

3*3 matrix manipulation

## Constructors

Create a matrix

### matrix

Create a matrix = synonym for "new"

### new3v

Create a matrix from three vectors

### new3vnc

Create a matrix from three vectors without checking

## Methods

### check

Check its a matrix

### is

Test its a matrix

Singular matrix?

### accuracy

Get/Set accuracy for comparisons

### round

Round: round to nearest integer if within accuracy of that integer

### clone

Create a matrix from another matrix

Print matrix

Negate matrix

### subtract

Subtract matrices

### matrixVectorMultiply

Vector = Matrix * Vector

### matrixScalarMultiply

Matrix = Matrix * scalar

### matrixMatrixMultiply

Matrix = Matrix * Matrix

### matrixScalarDivide

Matrix=Matrix / non zero scalar

### det

Determinant of matrix.

### d2

Determinant of 2*2 matrix

### inverse

Inverse of matrix

Identity matrix

### equals

Equals to within accuracy

Negate operator.

### multiply operator

Multiply operator.

Divide operator.

Equals operator.

### det operator

Determinant of a matrix

Print a vector.

## Exports

Export "matrix", "identity", "new3v", "new3vnc"

## Credits

### Author

philiprbrenan@yahoo.com

philiprbrenan@yahoo.com, 2004