Chapter 11: Printing Functions

.p>.CMCH11.DOC!WRITE_OPTIONS;write_options

Sets or retrieves an option for printing a matrix.

Synopsis

#include <imsl.h>

void imsl_write_options (Imsl_write_options option, int* option_value)

Required Arguments

Imsl_write_options option   (Input)
Option giving the type of the printing attribute to set or retrieve.

 

option for Setting

option for Retrieving

Attribute Description

IMSL_SET_DEFAULTS

 

Use the default settings for all parameters

IMSL_SET_CENTERING

IMSL_GET_CENTERING

Horizontal centering

IMSL_SET_ROW_WRAP

IMSL_GET_ROW_WRAP

Row wrapping

IMSL_SET_PAGING

IMSL_GET_PAGING

Paging

IMSL_SET_NAN_CHAR

IMSL_GET_NAN_CHAR

Method for printing NaN (not a number)

IMSL_SET_TITLE_PAGE

IMSL_GET_TITLE_PAGE

Whether or not titles appear on each page

IMSL_SET_FORMAT

IMSL_GET_FORMAT

Default format for real and complex numbers

int *option_value   (Input, if option is to be set; Output, otherwise)
The value of the option attribute selected by option. The values to be used when setting attributes are described in a table in the description section.

Description

The function imsl_write_options allows the user to set or retrieve an option for printing a matrix. Options controlled by imsl_write_options are horizontal centering, method for printing large matrices, paging, method for printing NaN (not a number), method for printing titles, and the default format for real and complex numbers. (NaN can be retrieved by functions imsl_f_machine and imsl_d_machine, Chapter 12, “Utilities;.”)

The values that may be used for the attributes are as follows:

Option

Value

Meaning

CENTERING

0

1

Matrix is left justified.

Matrix is centered.

ROW_WRAP

0

m

A complete row is printed before the next row is printed. Wrapping is used if necessary.

Here m is a positive integer. Let n1 be the maximum number of columns that fit across the page, as determined by the widths in the conversion specifications starting with column 1. First, columns 1 through n1 are printed for rows 1 through m. Let n2 be the maximum number of columns that fit across the page, starting with column
n
1 + 1. Second, columns n1+1 through n1 + n2 are printed for rows 1 through m. This continues until the last columns are printed for rows 1 through m. Printing continues in this fashion for the next m rows, etc.

PAGING

-2

-1



0





k

No paging occurs.

Paging is on. Every invocation of a imsl_f_write_matrix function begins on a new page, and paging occurs within each invocation as is needed.

Paging is on. The first invocation of a imsl_f_write_matrix function begins on a new page, and subsequent paging occurs as is needed. Paging occurs in the second and all subsequent calls to a imsl_f_write_matrix function only as needed.

Turn paging on and set the number of lines printed on the current page to k lines. If k is greater than or equal to the page length, then the first invocation of a imsl_f_write_matrix function begins on a new page. In any case, subsequent paging occurs as is needed.

NAN_CHAR

0

1

. . . . . . . . . . is printed for NaN.

A blank field is printed for NaN.

TITLE_PAGE

0

1

Title appears only on first page.

Title appears on the first page and all continuation pages.

FORMAT

0

1

2

Format is "%10.4x".

Format is "%12.6w".

Format is "%22.5e".

The w conversion character used by the FORMAT option is a special conversion character that can be used to automatically select a pretty C conversion specification ending in either e, f, or d. The conversion specification ending with w is specified as "%n.dw". Here, n is the field width, and d is the number of significant digits generally printed.

The function imsl_write_options can be invoked repeatedly before using a write_matrix function to print a matrix. The matrix printing functions retrieve the values set by imsl_write_options to determine the printing options. It is not necessary to call imsl_write_options if a default value of a printing option is desired. The defaults are as follows:

Option

Default Value

 

CENTERING

0

Left justified

ROW_WRAP

1000

Lines before wrapping

PAGING

-2

No paging

NAN_CHAR

0

. . . . . . . . . . . . . .

TITLE_PAGE

0

Title appears only on the first page

FORMAT

0

%10.4w

Example

The following example illustrates the effect of imsl_write_options when printing a 3 ´ 4  real matrix A with IMSL function imsl_f_write_matrix, where aij = i + j10. The first call to imsl_write_options sets horizontal centering so that the matrix is printed centered horizontally on the page. In the next invocation of imsl_f_write_matrix, the left-justification option has been set via function imsl_write_options, so the matrix is left justified when printed.

 

#include <imsl.h>

#define NRA     4
#define NCA     3

main()
{
    int         i, j, option_value;
    float       a[NRA][NCA];

    for (i = 0;  i < NRA;  i++) {
        for (j = 0;  j < NCA;  j++) {
            a[i][j] = (i+1) + (j+1)/10.0;
        }
    }
                                /* Activate centering option */
    option_value = 1;
    imsl_write_options (IMSL_SET_CENTERING, &option_value);
                                /* Write a matrix */
    imsl_f_write_matrix ("a", NRA, NCA, (float*) a, 0);
                                /* Activate left justification */
    option_value = 0;
    imsl_write_options (IMSL_SET_CENTERING, &option_value);
    imsl_f_write_matrix ("a", NRA, NCA, (float*) a, 0);
}

Output

                                       a
                                 1           2           3
                     1         1.1         1.2         1.3
                     2         2.1         2.2         2.3
                     3         3.1         3.2         3.3
                     4         4.1         4.2         4.3
 
                  a
            1           2           3
1         1.1         1.2         1.3
2         2.1         2.2         2.3
3         3.1         3.2         3.3
4         4.1         4.2         4.3

 


Visual Numerics, Inc.
Visual Numerics - Developers of IMSL and PV-WAVE
http://www.vni.com/
PHONE: 713.784.3131
FAX:713.781.9260