nag_gen_complx_mat_print_comp (x04dbc) (PDF version)
x04 Chapter Contents
x04 Chapter Introduction
NAG C Library Manual

NAG Library Function Document

nag_gen_complx_mat_print_comp (x04dbc)

+ Contents

    1  Purpose
    7  Accuracy
    9  Example

1  Purpose

nag_gen_complx_mat_print_comp (x04dbc) prints a Complex matrix.

2  Specification

#include <nag.h>
#include <nagx04.h>
void  nag_gen_complx_mat_print_comp (Nag_OrderType order, Nag_MatrixType matrix, Nag_DiagType diag, Integer m, Integer n, const Complex a[], Integer pda, Nag_ComplexFormType cmplxform, const char *form, const char *title, Nag_LabelType labrow, const char *rlabs[], Nag_LabelType labcol, const char *clabs[], Integer ncols, Integer indent, const char *outfile, NagError *fail)

3  Description

nag_gen_complx_mat_print_comp (x04dbc) prints a Complex matrix, or part of it, using a format specifier supplied by you. The matrix is output to the file specified by outfile or, by default, to standard output.

4  References

None.

5  Arguments

1:     orderNag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by order=Nag_RowMajor. See Section 3.2.1.3 in the Essential Introduction for a more detailed explanation of the use of this argument.
Constraint: order=Nag_RowMajor or Nag_ColMajor.
2:     matrixNag_MatrixTypeInput
On entry: indicates the part of the matrix to be printed.
matrix=Nag_GeneralMatrix
The whole of the rectangular matrix.
matrix=Nag_LowerMatrix
The lower triangle of the matrix, or the lower trapezium if the matrix has more rows than columns.
matrix=Nag_UpperMatrix
The upper triangle of the matrix, or the upper trapezium if the matrix has more columns than rows.
Constraint: matrix=Nag_GeneralMatrix, Nag_LowerMatrix or Nag_UpperMatrix.
3:     diagNag_DiagTypeInput
On entry: indicates whether the diagonal elements of the matrix are to be printed.
diag=Nag_NonRefDiag
The diagonal elements of the matrix are not referenced and not printed.
diag=Nag_UnitDiag
The diagonal elements of the matrix are not referenced, but are assumed all to be unity, and are printed as such.
diag=Nag_NonUnitDiag
The diagonal elements of the matrix are referenced and printed.
If matrix=Nag_GeneralMatrix, then diag must be set to Nag_NonUnitDiag.
Constraints:
  • if matrixNag_GeneralMatrix, diag=Nag_NonRefDiag, Nag_UnitDiag or Nag_NonUnitDiag;
  • if matrix=Nag_GeneralMatrix, diag=Nag_NonUnitDiag.
4:     mIntegerInput
5:     nIntegerInput
On entry: the number of rows and columns of the matrix, respectively, to be printed.
If either m or n is less than 1, nag_gen_complx_mat_print_comp (x04dbc) will exit immediately after printing title; no row or column labels are printed.
6:     a[dim]const ComplexInput
Note: the dimension, dim, of the array a must be at least
  • max1,pda×n when order=Nag_ColMajor;
  • max1,m×pda when order=Nag_RowMajor.
The i,jth element of the matrix A is stored in
  • a[j-1×pda+i-1] when order=Nag_ColMajor;
  • a[i-1×pda+j-1] when order=Nag_RowMajor.
On entry: the matrix to be printed. Only the elements that will be referred to, as specified by arguments matrix and diag, need be set.
7:     pdaIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array a.
Constraints:
  • if order=Nag_ColMajor, pdamax1,m;
  • if order=Nag_RowMajor, pdamax1,n.
8:     cmplxformNag_ComplexFormTypeInput
On entry: indicates how the value of form is to be used to print matrix elements.
cmplxform=Nag_AboveForm
The format code in form is assumed to contain a single real edit-descriptor which is to be used to print the real and imaginary parts of each Complex number one above the other. Each row of the matrix is separated by a blank line, and any row labels are attached only to the real parts. This option means that about twice as many columns can be fitted into ncols characters than if any other cmplxform option is used. A typical value of form for this cmplxform option might be %11.4e.
cmplxform=Nag_BracketForm
The format code in form is assumed to contain a single edit-descriptor such as %13.4f, * or NULL, which is used to print the real and imaginary parts of each Complex number separated by a comma, and surrounded by brackets. Thus a matrix element printed with this cmplxform option might look like this: 12.345,-11.323.
cmplxform=Nag_DirectForm
The format code in form is used unaltered to print a Complex number. This cmplxform option allows you flexibility to specify exactly how the number is printed. With this option for cmplxform and a suitable value for form it is possible, for example, to print a Complex number in the form 0.123+3.214i or 0.123e−02,0.234e−01.
Constraint: cmplxform=Nag_AboveForm, Nag_BracketForm or Nag_DirectForm.
9:     formconst char *Input
On entry: a valid C format code. This should be of the form %flagww.ppformat​ ​indicator, where ww.pp indicates that up to two digits may be used to specify the field width and precision respectively. Only % and format​ ​indicator must be present. flag can be one of -, +, <space> or # and format​ ​indicator can be e, E, f, g or G. Thus, possible formats include %f, %-11.4G, %.6e. form is used in conjunction with argument cmplxform, to print elements of the matrix A.
In addition, nag_gen_complx_mat_print_comp (x04dbc) chooses its own format code when form is NULL or form='*'.
If form=NULL, nag_gen_complx_mat_print_comp (x04dbc) will choose a format code such that numbers will be printed with either a %8.4f, a %11.4f or a %13.4e format. The %8.4f code is chosen if the sizes of all the matrix elements to be printed lie between 0.001 and 1.0. The %11.4f code is chosen if the sizes of all the matrix elements to be printed lie between 0.001 and 9999.9999. Otherwise the %13.4e code is chosen.
If form='*', nag_gen_complx_mat_print_comp (x04dbc) will choose a format code such that numbers will be printed to as many significant digits as are necessary to distinguish between neighbouring machine numbers. Thus any two numbers that are stored with different internal representations should look different on output.
More complicated values of form, to print a Complex number in a desired form, may be used. See the description of argument cmplxform above for more details.
Constraint: if cmplxform=Nag_AboveForm or Nag_BracketForm, form must be of the form %flagww.ppformat​ ​indicator.
10:   titleconst char *Input
On entry: a title to be printed above the matrix, or name of the matrix.
If title=NULL, no title (and no blank line) will be printed.
If title contains more than ncols characters, the contents of title will be wrapped onto more than one line, with the break after ncols characters.
Any trailing blank characters in title are ignored.
11:   labrowNag_LabelTypeInput
On entry: indicates the type of labelling to be applied to the rows of the matrix.
labrow=Nag_NoLabels
Prints no row labels.
labrow=Nag_IntegerLabels
Prints integer row labels.
labrow=Nag_CharacterLabels
Prints character labels, which must be supplied in array rlabs.
Constraint: labrow=Nag_NoLabels, Nag_IntegerLabels or Nag_CharacterLabels.
12:   rlabs[dim]const char *Input
Note: the dimension, dim, of the array rlabs must be at least m when labrow=Nag_CharacterLabels otherwise rlabs may be NULL.
On entry: if labrow=Nag_CharacterLabels, rlabs must contain labels for the rows of the matrix.
Labels are right-justified when output, in a field which is as wide as necessary to hold the longest row label. Note that this field width is subtracted from the number of usable columns, ncols.
13:   labcolNag_LabelTypeInput
On entry: indicates the type of labelling to be applied to the columns of the matrix.
labcol=Nag_NoLabels
Prints no column labels.
labcol=Nag_IntegerLabels
Prints integer column labels.
labcol=Nag_CharacterLabels
Prints character labels, which must be supplied in array clabs.
Constraint: labcol=Nag_NoLabels, Nag_IntegerLabels or Nag_CharacterLabels.
14:   clabs[dim]const char *Input
Note: the dimension, dim, of the array clabs must be at least n when labcol=Nag_CharacterLabels otherwise clabs may be NULL.
On entry: if labcol=Nag_CharacterLabels, clabs must contain labels for the columns of the matrix.
Labels are right-justified when output. Any label that is too long for the column width, which is determined by form, is truncated.
15:   ncolsIntegerInput
On entry: the maximum output record length. If the number of columns of the matrix is too large to be accommodated in ncols characters, the matrix will be printed in parts, containing the largest possible number of matrix columns, and each part separated by a blank line.
ncols must be large enough to hold at least one column of the matrix using the format specifier in form. If a value less than or equal to 0 or greater than 132 is supplied for ncols, then the value 80 is used instead.
16:   indentIntegerInput
On entry: the number of columns by which the matrix (and any title and labels) should be indented. The effective value of ncols is reduced by indent columns. If a value less than 0 or greater than ncols is supplied for indent, the value 0 is used instead.
17:   outfileconst char *Input
On entry: the name of a file to which output will be directed. If outfile is NULL the output will be directed to standard output.
18:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Memory allocation failed.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_COL_WIDTH
value is not wide enough to hold at least one matrix column. ncols=value and indent=value.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_INVALID_FORMAT
The string value has not been recognized as a valid format.
NE_NOT_APPEND_FILE
Cannot open file value for appending.
NE_NOT_CLOSE_FILE
Cannot close file value.
NE_NOT_WRITE_FILE
Cannot open file value for writing .

7  Accuracy

Not applicable.

8  Further Comments

nag_gen_complx_mat_print_comp (x04dbc) may be used to print a vector, either as a row or as a column. The following code fragment illustrates possible calls.
#include <nag.h>
#include <nagx04.h>
#include <nag_stdlib.h>    
Complex *a = 0;
Integer n = 4;
if ( !(a = NAG_ALLOC(n, Complex)) )
  {
    Vprintf("Allocation failure\n");
    return -1;
  }
/* Read A from data file */
for (i = 0; i < n; ++i)
  Vscanf("%lf%lf", &a[i].re, &a[i].im);
/* Print vector A as a row vector */
x04dbc(Nag_RowMajor, Nag_GeneralMatrix, Nag_NonUnitDiag,
1, n, a, n, 0, 0,  Nag_NoLabels, 0, Nag_IntegerLabels, 0,
0, 0, 0, NAGERR_DEFAULT);
/* Print vector A as a column vector */
x04dbc(Nag_RowMajor, Nag_GeneralMatrix, Nag_NonUnitDiag,
n, 1, a, 1, 0, 0,  Nag_IntegerLabels, 0, Nag_NoLabels, 0,
0, 0, 0, NAGERR_DEFAULT);

9  Example

See Section 9 in nag_zhetri (f07mwc).

nag_gen_complx_mat_print_comp (x04dbc) (PDF version)
x04 Chapter Contents
x04 Chapter Introduction
NAG C Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012