Forum archive 2000-2006

Michael Gage -

Michael Gage -

by Arnold Pizer -
Number of replies: 0 topic started 4/23/2002; 9:31:38 AM
last post 4/23/2002; 9:31:38 AM
userMichael Gage -  blueArrow
4/23/2002; 9:31:38 AM (reads: 2017, responses: 0)


    Matrix macros for the PG language



Almost all of the macros in the file are very rough at best. The most useful is display_matrix. Many of the other macros work with vectors and matrices stored as anonymous arrays.

Frequently it may be more useful to use the Matrix objects defined and and the constructs listed there.


        Usage       \{ display_matrix( [ [1, '\(\sin x\)'], [ans_rule(5), 6] ]) \}
\{ display_matrix($A, align=>'crvl') \}
\[ \{ display_matrix_mm($A) \} \]
\[ \{ display_matrix_mm([ [1, 3], [4, 6] ]) \} \]
    display_matrix produces a matrix for display purposes.  It checks whether
it is producing LaTeX output, or if it is displaying on a web page in one
of the various modes. The input can either be of type Matrix, or a
reference to an array.
        Entries can be numbers, Fraction objects, bits of math mode, or answer
boxes. An entire row can be replaced by the string 'hline' to produce
a horizontal line in the matrix.
        display_matrix_mm functions similarly, except that it should be inside
math mode. display_matrix_mm cannot contain answer boxes in its entries.
Entries to display_matrix_mm should assume that they are already in
math mode.
        Both functions take an optional alignment string, similar to ones in
LaTeX tabulars and arrays. Here c for centered columns, l for left
flushed columns, and r for right flushed columns.
        The alignment string can also specify vertical rules to be placed in the
matrix. Here s or | denote a solid line, d is a dashed line, and v
requests the default vertical line. This can be set on a system-wide
or course-wide basis via the variable $defaultDisplayMatrixStyle, and
it can default to solid, dashed, or no vertical line (n for none).
        The matrix has left and right delimiters also specified by
$defaultDisplayMatrixStyle. They can be parentheses, square brackets,
braces, vertical bars, or none. The default can be overridden in
an individual problem with optional arguments such as left=>"|", or
    You can specify an optional argument of 'top_labels'=> ['a', 'b', 'c'].
These are placed above the columns of the matrix (as is typical for
linear programming tableau, for example). The entries will be typeset
in math mode.
    Top labels require a bit of care.   For image modes, they look better
with display_matrix_mm where it is all one big image, but they work with
display_matrix. With tth, you pretty much have to use display_matrix
since tth can't handle the TeX tricks used to get the column headers
up there if it gets the whole matrix at once.


        Usage   \{ mbox(thing1, thing2, thing3) \}
\{ mbox([thing1, thing2, thing3], valign=>'top') \}
    mbox takes a list of constructs, such as strings, or outputs of
display_matrix, and puts them together on a line. Without mbox, the
output of display_matrix would always start a new line.
        The inputs can be just listed, or given as a reference to an array.
With the latter, optional arguments can be given.
        Optional arguments are allowbreaks=>'yes' to allow line breaks in TeX
output; and valign which sets vertical alignment on web page output.


        Usage:  ra_flatten_matrix($A)

where $A is a matrix object
The output is a reference to an array. The matrix is placed in the array
by iterating
over columns on the inside
loop, then over the rows. (e.g right to left and then down, as one reads
File path = /ww/webwork/pg/macros/

<| Post or View Comments |>