NAME

        Matrix macros for the PG language

DESCRIPTION

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 RealMatrix.pm and Matrix.pm and the constructs listed there.

display_matrix

                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, Value::Matrix (mathobject) 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 variabledefaultDisplayMatrixStyle, and
it can default to solid, dashed, or no vertical line (n for none).
          The matrix has left and right delimiters also specified by

check_matrix_from_ans_box_cmp

An answer checker factory built on create2d_matrix. This still needs work. It is not feature complete, particularly with regard to error messages for incorrect input. --MEG

        $matrix = Matrix("[[1,4],[2,3]"); ANS( check_matrix_from_ans_box($matrix) );

convert_to_array_ref {

        $output_matrix = convert_to_array_ref($input_matrix)

Converts a MathObject matrix (ref($input_matrix eq 'Value::Matrix') or a MatrixReal1 matrix (ref($input_matrix eq 'Matrix')to a reference to an array (e.g [[4,6],[3,2]]). This adaptor allows all of the Linear Programming subroutines to be used with MathObject arrays.

\$mathobject_matrix->value outputs an array (usually an array of array references) so placing it inside square bracket produces and array reference (of array references) which is what lp_display_mm() is seeking.