next up previous contents index
Next: Special Operations with Block Up: Block Matrix Manipulation Previous: TimesToNCM[expr]   Contents   Index

Partitioning a Matrix into a Block Matrix

We have developed the file NCBlockPartition.m to do matrix partitioning. The easiest way to explain how it works is through an example. If one has a 3$ \times$3 matrix

$\displaystyle \renewcommand {\arraystretch}{1.2}\left[ \begin{array}{ccc} 3 & 6 & 9 \ 1 & 2 & 4 \ 5 & 9 & 1\end{array}\right]
$

then one might say that it equals

$\displaystyle \renewcommand {\arraystretch}{1.2}\left[ \begin{array}{cc} A & B \ C & D\end{array}\right]
$

where

A is the 1$ \times$1 matrix containing the entry 3

B is the 1$ \times$2 matrix containing the entries 6 and 9

C is the 2$ \times$1 matrix containing the entries 1 and 5

D is the 2$ \times$2 matrix containing the entries 2, 4, 9, and 1.

One would do the above using the command

          PartitionMatrix[{{3,6,9}, {1,2,4}, {5,9,1}}, 1, 1]
(Note: the second parameter is the number of rows of the upper left hand and the third parameter is the number of columns of the upper left hand block. That is, A is a 1$ \times$1 matrix.)

and the output would have the form

          {{$1,$2},{$3,$4}}
and would have the consequence of typing ?ValueQ and ?BlockQ
          ValueOf[$1] = {{3}}
          ValueOf[$2] = {{6,9}}
          ValueOf[$3] = {{1},{5}}
          ValueOf[$4] = {{2,4},{9,1}}

          BlockQ[$1] = True
          BlockQ[$2] = True
          BlockQ[$3] = True
          BlockQ[$4] = True

One can reconstruct the original matrix by executing

          FormMatrix[{{$1,$2},{$3,$4}}]

If one does not want a `$', then one can use a different `prefix" by adding a fourth parameter to the call to PartitionMatrix. The numbers following the prefix are generated by the `Unique" command. We hope that their uglyness is not offensive.

We use the ValueOf function to associate the value of the block to the block without actually assigning it. If it were assigned immediately, then the assigned value would be dragged around instead of the variable representing the entry. If one is partitioning a 100$ \times$100 matrix into a 2$ \times$2 block matrix, then delaying the assignment makes following the calculation much simpler.

The BlockQ command tells the user if the variable represents a block matrix and is assigned within PartitionMatrix via the SetBlock command. At this time, BlockQ is never used. The intention is to provide it at this point for future expansion.

Lastly, note that

   FormMatrix[PartitionMatrix[x, m, n]]
will give back x (as long as m and n are less than the dimensions of the matrix x, of course).


next up previous contents index
Next: Special Operations with Block Up: Block Matrix Manipulation Previous: TimesToNCM[expr]   Contents   Index
NCAlgebra Project 2002-09-09