write_options

Sets or retrieves an option for printing a matrix.

Synopsis

#include <imsls.h>

void imsls_write_options (Imsls_write_options option, int *option_value)

Required Arguments

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

Keyword for Setting

Keyword for Retrieving

Attribute Description

IMSLS_SET_DEFAULTS

 

uses the default settings for all parameters

IMSLS_SET_CENTERING

IMSLS_GET_CENTERING

horizontal centering

IMSLS_SET_ROW_WRAP

IMSLS_GET_ROW_WRAP

row wrapping

IMSLS_SET_PAGING

IMSLS_GET_PAGING

paging

IMSLS_SET_NAN_CHAR

IMSLS_GET_NAN_CHAR

method for printing NaN

IMSLS_SET_TITLE_PAGE

IMSLS_GET_TITLE_PAGE

whether or not titles appear on each page

IMSLS_SET_FORMAT

IMSLS_GET_FORMAT

default format for real and complex numbers

int *option_value (Input, if option is to be set; Output, otherwise)
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

Function imsls_write_options allows the user to set or retrieve an option for printing a matrix. Options controlled by imsls_write_options are horizontal centering, method for printing large matrices, paging, method for printing NaN, method for printing titles, and the default format for real and complex numbers. (NaN can be retrieved by functions imsls_f_machine and imsls_d_machine (Chapter 15, Utilities).

The following values can be used for the attributes:

Keyword

Value

Meaning

CENTERING

0

1

Matrix is left justified.

Matrix is centered.

ROW_WRAP

0


m

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 n1+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 an function imsls_write_matrix begins on a new page, and paging occurs within each invocation as is needed.

Paging is on. The first invocation of an imsls_f_write_f_matrix function begins on a new page, and subsequent paging occurs as is needed. Paging occurs in the second and all subsequent calls to an imsls_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 an imsls_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.

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

Keyword

Default Value

Meaning

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 imsls_write_options when printing a 3 × 4 real matrix A with function imsls_f_write_matrix, where aij = i + j/10. The first call to imsls_write_options sets horizontal centering so that the matrix is printed centered horizontally on the page. In the next invocation of imsls_f_write_matrix, the left-justification option has been set by function imsls_write_options so the matrix is left justified when printed.

 

#include <imsls.h>

 

#define NRA 4

#define NCA 3

 

int 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;

imsls_write_options (IMSLS_SET_CENTERING, &option_value);

/* Write a matrix */

imsls_f_write_matrix ("a", NRA, NCA, (float*) a,

0);

/* Activate left justification */

option_value = 0;

imsls_write_options (IMSLS_SET_CENTERING, &option_value);

imsls_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