 rtable_printf - Maple Help

Formatted Printing Options for Arrays, Matrices, and Vectors Description

 • The printf, fprintf, sprintf, and nprintf family of formatted printing functions (hereinafter referred to only as printf), can be used to print objects of type Array, Matrix, and Vector, collectively known as rtables.
 • Formatting specifications for printf are introduced by the "%" character, followed by zero or more flags, an optional width and precision, optional modifiers, and a one-letter formatting code. One of the possible flags is a sequence of rtable formatting options enclosed in braces "{}".
 • The rtable formatting options are specified as a sequence of characters within the enclosing braces. The available options are:
 t
 Data is to be transposed when writing. In other words, for the dense printing format, each column of the rtable is written as a row. In general, it is as though the rtable were transposed before printing, except that no actual transposed copy of the rtable is made.
 x
 If the rtable uses band, upper triangular, or lower triangular storage, write only the explicitly stored elements. So for a band Matrix, the first and last few rows written will have fewer elements than most of the rows. For an upper triangular rtable, each row will be one shorter than the one before it. For a lower triangular rtable, each row will be one longer than the one before it.
 b- and b+
 If the rtable uses band storage, write only the bands, one per row, starting with the sub-diagonals if b- was specified, or the super-diagonals if b+ was specified.
 e
 Write each element as a row, giving a set of indices followed by a value. Only explicitly stored elements are written.
 v
 Write the data as a set of vectors, the first of which give the indices (one index per vector), and the last one of which gives the values. Only indices and values for explicitly stored elements are written.
 s
 Suppress the separator between elements printed on the same line. This is useful when the basic display format has already been chosen to include separator space.
 n
 Suppress the line break between rows of elements.
 ca
 Use the character specified by a as the separator between output items. This option is ignored if s is also specified. A comma (",") separator, in conjunction with the %v" or %V formats, will produce output in Standard or Microsoft "Comma Separated Values" formats respectively. Examples

 > $\mathrm{with}\left(\mathrm{LinearAlgebra}\right):$
 > $r≔\mathrm{RandomMatrix}\left(4,4,\mathrm{density}=0.75,\mathrm{outputoptions}=\left[\mathrm{shape}={\mathrm{triangular}}_{\mathrm{lower}}\right]\right)$
 ${r}{≔}\left[\begin{array}{cccc}{0}& {0}& {0}& {0}\\ {0}& {69}& {0}& {0}\\ {-4}& {-2}& {-93}& {0}\\ {0}& {0}& {-18}& {0}\end{array}\right]$ (1)
 > $\mathrm{printf}\left("%d",r\right)$
 0 0 0 0 0 69 0 0 -4 -2 -93 0 0 0 -18 0
 > $\mathrm{printf}\left("%4d",r\right)$
 0    0    0    0    0   69    0    0   -4   -2  -93    0    0    0  -18    0
 > $\mathrm{printf}\left("%\left\{x\right\}4d",r\right)$
 0    0   69   -4   -2  -93    0    0  -18    0
 > $\mathrm{printf}\left("%\left\{t\right\}4d",r\right)$
 0    0   -4    0    0   69   -2    0    0    0  -93  -18    0    0    0    0
 > $\mathrm{printf}\left("%\left\{txc,\right\}d",r\right)$
 0,0,-4,0 0,69,-2,0 0,0,-93,-18 0,0,0,0
 > $\mathrm{printf}\left("%\left\{c,n\right\}d",r\right)$
 0,0,0,0,0,69,0,0,-4,-2,-93,0,0,0,-18,0
 > $\mathrm{printf}\left("%\left\{v\right\}d",r\right)$
 1 2 2 3 3 3 4 4 4 4 1 1 2 1 2 3 1 2 3 4 0 0 69 -4 -2 -93 0 0 -18 0
 > $\mathrm{printf}\left("%\left\{e\right\}d",r\right)$
 1 1 0 2 1 0 2 2 69 3 1 -4 3 2 -2 3 3 -93 4 1 0 4 2 0 4 3 -18 4 4 0

Non-numeric values are appropriately quoted and/or escaped when printed with the %v or %V formats.

 > ${r}_{2,2}≔a+b$
 ${{r}}_{{2}{,}{2}}{≔}{a}{+}{b}$ (2)
 > ${r}_{3,3}≔"with "quotes""$
 ${{r}}_{{3}{,}{3}}{≔}{"with "quotes""}$ (3)
 > $\mathrm{printf}\left("%\left\{c,\right\}v",r\right)$
 0,0,0,0 0,"a+b",0,0 -4,-2,"with \"quotes\"",0 0,0,-18,0
 > $\mathrm{printf}\left("%\left\{c,\right\}V",r\right)$
 0,0,0,0 0,"a+b",0,0 -4,-2,"with ""quotes""",0 0,0,-18,0

Print a vector as text on a plot.

 > $v≔⟨1,2⟩$
 ${v}{≔}\left[\begin{array}{c}{1}\\ {2}\end{array}\right]$ (4)
 > $f≔x→x:$
 > $\mathrm{plot}\left(f,1..2,\mathrm{title}=\mathrm{sprintf}\left("<%\left\{c,n\right\}a>",v\right)\right)$ 