Matrix definitions

<< Click to Display Table of Contents >>

Navigation:  Reference > Commands >

Matrix definitions

A matrix definition command takes one of the forms:

DS svar = matrix definition,

DM mvar = matrix definition,

The form of the matrix definition is this:

var.BY.var.BY.var...

where the vars may be svars or mvars. If the variable being defined is an svar then only svars are allowed in the definition.

A matrix definition is the same as a string definition in which every combination of the possible values of the variables is defined.

The number of bits generated by this definition is the lengths of all the vars multiplied together.

If any of the vars used is empty, then all the generated bits will be false. Provided that all the variables used have a true bit, one or more of the generated bits will be true. The bit(s) which are set true depend on the contents of the variables.

The order of the combinations is best shown by example. If we have three variables, $A (length 2), $B (length 3) and $C (length 2) then:

$a.by.$b,

is the same as "b within a":

$a/1.$b/1, $a/1.$b/2, $a/1.$b/3,

$a/2.$b/1, $a/2.$b/2, $a/2.$b/3,

and,

$a.by.$b.by.$c,

is the same as "c within b within a":

$a/1.$b/1.$c/1, $a/1.$b/1.$c/2,

$a/1.$b/2.$c/1, $a/1.$b/2.$c/2,

$a/1.$b/3.$c/1, $a/1.$b/3.$c/2,

$a/2.$b/1.$c/1, $a/2.$b/1.$c/2,

$a/2.$b/2.$c/1, $a/2.$b/2.$c/2,

$a/2.$b/3.$c/1, $a/2.$b/3.$c/2,

One common use of this transformation is to determine a cell address, that is to determine the number of a cell in a table into which a particular record would fall. For example:

ds $row=$a.by.$b,

ds $col=$c,

t #1=$row*$col,

ds $address=$a.by.$b.by.$c,

dw $cell=$address(#1),