Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Working with Matrices

Subscript Reduction Operators

You can use reduction operators, which return a matrix of reduced dimension, in place of values for subscripts to get reductions across all rows and columns. Table 4.3 lists the eight operators for subscript reduction in IML.

Table 4.3: Subscript Reduction Operators
Operator Action
+ addition
# multiplication
<> maximum
>< minimum
<:> index of maximum
>:< index of minimum
: mean (different from the MATRIX procedure)
## sum of squares

For example, to get column sums of the matrix X (sum across the rows, which reduces the row dimension to 1), specify X[+,]. The first subscript (+) specifies that summation reduction take place across the rows. Omitting the second subscript, corresponding to columns, leaves the column dimension unchanged. The elements in each column are added, and the new matrix consists of one row containing the column sums.

You can use these operators to reduce either rows or columns or both. When both rows and columns are reduced, row reduction is done first.

For example, the expression A[+,<>] results in the maximum (<>) of the column sums (+).

You can repeat reduction operators. To get the sum of the row maxima, use the expression A[,<>] [+,].

A subscript such as A[{2 3},+] first selects the second and third rows of A and then finds the row sums of that matrix. The following examples demonstrate how to use the operators for subscript reduction.

{Let } A =
[ 0 & 1 & 2 \ 5 & 4 & 3 \ 7 & 6 & 8 \ ]
The following statements are true:
A[{2 3},+] { yields }
[ 12 \ 21 \ ]
{ (row sums for rows 2 and 3)}
A[+,\lt\gt] { yields }
[ 13 \ ]
{ (maximum of column sums)}
A[\lt\gt,+] { yields }
[ 21 \ ]
{ (sum of column maxima)}
A[,\gt\lt] [+,] { yields }
[ 9 \ ]
{ (sum of row minima)}
A[,\lt:\gt] { yields }
[ 3 \ 1 \ 3 \ ]
{ (indices of row maxima)}
A[\gt:\lt,] { yields }
[ 1 & 1 & 1 \ ]
{ (indices of column minima)}
A[:] { yields }
[ 4 \ ]
{ (mean of all elements)}

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.