Title

matrow -- Matrix operations on rows made simple

General syntax

Binary operations on rows

matrow Msource changedrow = leftrow operator rightrow

Unary operations on rows

matrow Msource changedrow = operator(row)

Statistics operations on matrix

matrow Msource changedrow = operator [, rows(numlist)]

Utility operations on matrix

matrow Msource changedrow = operator [, rows(numlist)]

Matrix

Msource is the matrix to be modified. Note that the original content might be overwritten.

Specifying rows

The rows in Msource that is changed and the rows with information used to create the new information are specified as follows:

# Change that row; add rows if # exceeds dimension of matrix

n Add one row to bottom of matrix

l Last rows (lower case L)

p Prior row created by adding row at top of matrix

changedrow the row to be changed in Msource. If the row does not exist (e.g., row 5 in a 3x3 matrix) additional rows filled with missing values .z are added.

leftrow in binary operations, this is the row to the left of the operator.

rightrow in binary operations, this is the row to the right of the operator.

row in unary operations, this row is modified to create the changedrow.

Options for all types of operations

list
List matrix after changes.

format(fmt)
Use fmt to format listing; default is %9.3f.

width(integer)
Width used in format; default is 9.

decimals(integer)
Decimals used in format; default is 3.

name(label)
the changed row is given this row name in the matrix.

Overview

matrow makes changes to the matrix based on row operations
such as adding two rows, summing over rows, taking the square root of a row.

Expanded syntax

Binary operations

matrow Msource changedrow = leftrow operator rightrow

Operator What it does

+ Addition of left and right

- Subtraction left from right

* Multiplication left times right

/ Division left by right

^ Exponentiation of left to right power

%of Left as percent of right

%dif Change from left to right as percent of left

Unary operations

matrow Msource changedrow = operator(row)

Operator What it does

abs Absolute value

sqrt Square root

sq Square

log Natural log

log10 Log base 10

exp exponential

inv Inverse

Statistics

matrow Msource changedrow = operator [, rows(numlist)]

For each column, statistics are computed based on information in the rows. The rows(numlist) option lets you select which rows to use in computing statistics.

Operator What it does

min minimum over selected rows.

max maximum over selected rows.

mean mean of selected rows.

sd standard deviation of selected rows.

var variance of selected rows.

range range over selected rows.

rows(numlist)
Select rows from Msource that are used when computing statistics.

Utility

matrow Msource changedrow = operator

Operator What it does

number Create a row indicting the column number.

rows(numlist)
Select rows from Msource that are used when computing statistics.

Author

Scott Long

The SPost website.
The Workflow website.