9.9 Vector and Matrix Display Formats

Commands for controlling vector and matrix display use the v prefix instead of the usual d prefix. But they are display modes; in particular, they are influenced by the I and H prefix keys in the same way (see Display Modes). Matrix display is also influenced by the d O (calc-flat-language) mode; see Normal Language Modes.

The commands v < (calc-matrix-left-justify), v > (calc-matrix-right-justify), and v = (calc-matrix-center-justify) control whether matrix elements are justified to the left, right, or center of their columns.

The v [ (calc-vector-brackets) command turns the square brackets that surround vectors and matrices displayed in the stack on and off. The v { (calc-vector-braces) and v ( (calc-vector-parens) commands use curly braces or parentheses, respectively, instead of square brackets. For example, v { might be used in preparation for yanking a matrix into a buffer running Mathematica. (In fact, the Mathematica language mode uses this mode; see Mathematica Language Mode.) Note that, regardless of the display mode, either brackets or braces may be used to enter vectors, and parentheses may never be used for this purpose.

The v ] (calc-matrix-brackets) command controls the “big” style display of matrices, for matrices which have more than one row. It prompts for a string of code letters; currently implemented letters are R, which enables brackets on each row of the matrix; O, which enables outer brackets in opposite corners of the matrix; and C, which enables commas or semicolons at the ends of all rows but the last. The default format is ‘RO’. (Before Calc 2.00, the format was fixed at ‘ROC’.) Here are some example matrices:

[ [ 123,  0,   0  ]       [ [ 123,  0,   0  ],
  [  0,  123,  0  ]         [  0,  123,  0  ],
  [  0,   0,  123 ] ]       [  0,   0,  123 ] ]

         RO                        ROC

  [ 123,  0,   0            [ 123,  0,   0 ;
     0,  123,  0               0,  123,  0 ;
     0,   0,  123 ]            0,   0,  123 ]

          O                        OC

  [ 123,  0,   0  ]           123,  0,   0
  [  0,  123,  0  ]            0,  123,  0
  [  0,   0,  123 ]            0,   0,  123

          R                       blank

Note that of the formats shown here, ‘RO’, ‘ROC’, and ‘OC’ are all recognized as matrices during reading, while the others are useful for display only.

The v , (calc-vector-commas) command turns commas on and off in vector and matrix display.

In vectors of length one, and in all vectors when commas have been turned off, Calc adds extra parentheses around formulas that might otherwise be ambiguous. For example, ‘[a b]’ could be a vector of the one formula ‘a b’, or it could be a vector of two variables with commas turned off. Calc will display the former case as ‘[(a b)]’. You can disable these extra parentheses (to make the output less cluttered at the expense of allowing some ambiguity) by adding the letter P to the control string you give to v ] (as described above).

The v . (calc-full-vectors) command turns abbreviated display of long vectors on and off. In this mode, vectors of six or more elements, or matrices of six or more rows or columns, will be displayed in an abbreviated form that displays only the first three elements and the last element: ‘[a, b, c, ..., z]’. When very large vectors are involved this will substantially improve Calc’s display speed.

The t . (calc-full-trail-vectors) command controls a similar mode for recording vectors in the Trail. If you turn on this mode, vectors of six or more elements and matrices of six or more rows or columns will be abbreviated when they are put in the Trail. The t y (calc-trail-yank) command will be unable to recover those vectors. If you are working with very large vectors, this mode will improve the speed of all operations that involve the trail.

The v / (calc-break-vectors) command turns multi-line vector display on and off. Normally, matrices are displayed with one row per line but all other types of vectors are displayed in a single line. This mode causes all vectors, whether matrices or not, to be displayed with a single element per line. Sub-vectors within the vectors will still use the normal linear form.