Formatted Printing Options for Arrays, Matrices, and Vectors - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Data Types : Rtables, Arrays, Matrices, and Vectors : IO : rtable_printf

Formatted Printing Options for Arrays, Matrices, and Vectors

 

Description

Examples

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

withLinearAlgebra:

rRandomMatrix4,4,density=0.75,outputoptions=shape=triangularlower

r:=0000069004293000180

(1)

printf%d ,r

0 0 0 0
0 69 0 0
-4 -2 -93 0
0 0 -18 0

printf%4d ,r

   0    0    0    0
   0   69    0    0
  -4   -2  -93    0
   0    0  -18    0

printf%{x}4d ,r

   0
   0   69
  -4   -2  -93
   0    0  -18    0

printf%{t}4d ,r

   0    0   -4    0
   0   69   -2    0
   0    0  -93  -18
   0    0    0    0

printf%{txc,}d ,r

0,0,-4,0
0,69,-2,0
0,0,-93,-18
0,0,0,0

printf%{c,n}d ,r

0,0,0,0,0,69,0,0,-4,-2,-93,0,0,0,-18,0

printf%{v}d ,r

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

printf%{e}d ,r

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.

r2,2a+b

r2,2:=a+b

(2)

r3,3with "quotes"

r3,3:=with "quotes"

(3)

printf%{c,}v ,r

0,0,0,0
0,"a+b",0,0
-4,-2,"with \"quotes\"",0
0,0,-18,0

printf%{c,}V ,r

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.

v1,2

v:=12

(4)

fx→x:

plotf&comma;1..2&comma;title&equals;sprintf<%{c,n}a>&comma;v

See Also

Array

Matrix

printf

rtable

Vector

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam