__Creating Matrices and Vectors in Maple__

Version .8 for Maple V R7.

Load pointers to functions in the linear algebra package.

`> `
**with(linalg):**

Warning, the protected names norm and trace have been redefined and unprotected

Entering a matrix as a list of lists.

`> `
**A1 := matrix([ [1,2,3], [4,5,6], [7,8,9] ]);**

Enter a vector - will be viewed as a
*column*
vector.

`> `
**v1 := vector([1, 2, 3]);**

We could now multiply A1 times v1 by evalm(A1 &* v1);

Another form of the vector call is vector(3,1) producing a column vector of dim 3 with

initial entries 1.

`> `
**v2 := vector(3,1);**

Enter a 2 by 3 matrix with entries taken in row major order from the list.

`> `
**A2 := matrix(2,3,[x,y,z,w,u,v]);**

Enter a 2 by 2 matrix with all entries initialized to 0.

`> `
**A3 := matrix(2,2,0);**

One can also define a function of row and column indices to initialize a matrix.

`> `
**f := (i,j) -> j * x^(i + j);**

`> `
**A4 := matrix(2,2,f);**

A 1 by 3 matrix; i.e. a
*row*
*vector.*

`> `
**v3 := matrix(1,3,4);**

Another form of a column vector.

`> `
**v4 := matrix(2,1,[ 5, 6]);**

Matrices can be partially specified:

`> `
**A4 := matrix(2,3,[[x,y,z]]);**

And then updated with a
**for**
loop.

`> `
**for j from 1 to 3 do
A4[2,j] := x * y^j:
od:**

`> `
**print(A4);**

Nested loops are also possible to update all entries of a matrix.

Matrices can be stacked horizontally.

`> `
**A5 := augment(A2,A4);**

Or vertically:

`> `
**A6 := stackmatrix(A2,v3);
**

One can delete a range of rows from a matrix.

`> `
**delrows(A1,1..2);**

(Use delcols for columns.)

Block diagonal or diagonal matrices can also be easily generated.

`> `
**A6 := diag(lambda_1, lambda_2);**

(These commands can be used with more than two arguments.)

`> `
**A7 := diag(A6,A6):**

One can create a 5 x 5 banded matrix by:

`> `
**band([a,b,c],5);**

A 3 by 3 Jordan block with diagonal entry 5 can be generated by:

`> `
**JordanBlock(5,3);**

Extract a submatrix using rows 1..3 of A1 and columns 2..3.

`> `
**A8 := submatrix(A1,1..3,2..3);**

Extract rows and columns as vectors.

`> `
**row(A8,2); col(A8,1);**

`> `

`> `