hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_sparse_complex_herm_sort (f11zp)

Purpose

nag_sparse_complex_herm_sort (f11zp) sorts the nonzero elements of a sparse complex Hermitian matrix, represented in symmetric coordinate storage format.

Syntax

[nnz, a, irow, icol, istr, ifail] = f11zp(n, nnz, a, irow, icol, dup, zer)
[nnz, a, irow, icol, istr, ifail] = nag_sparse_complex_herm_sort(n, nnz, a, irow, icol, dup, zer)

Description

nag_sparse_complex_herm_sort (f11zp) takes a symmetric coordinate storage (SCS) representation (see Section [Symmetric coordinate storage (SCS) format] in the F11 Chapter Introduction) of a sparse nn by nn complex Hermitian matrix AA, and reorders the nonzero elements by increasing row index and increasing column index within each row. Entries with duplicate row and column indices may be removed, or the values may be summed. Any entries with zero values may optionally be removed.
The function also returns a pointer array istr to the starting address of each row in AA.

References

None.

Parameters

Compulsory Input Parameters

1:     n – int64int32nag_int scalar
nn, the order of the matrix AA.
Constraint: n1n1.
2:     nnz – int64int32nag_int scalar
The number of nonzero elements in the lower triangular part of the matrix AA.
Constraint: nnz0nnz0.
3:     a( : :) – complex array
Note: the dimension of the array a must be at least max (1,nnz)max(1,nnz).
The nonzero elements of the lower triangular part of the complex matrix AA. These may be in any order and there may be multiple nonzero elements with the same row and column indices.
4:     irow( : :) – int64int32nag_int array
Note: the dimension of the array irow must be at least max (1,nnz)max(1,nnz).
The row indices corresponding to the nonzero elements supplied in the array a.
Constraint: 1irow(i)n1irowin, for i = 1,2,,nnzi=1,2,,nnz.
5:     icol( : :) – int64int32nag_int array
Note: the dimension of the array icol must be at least max (1,nnz)max(1,nnz).
The column indices corresponding to the nonzero elements supplied in the array a.
Constraint: 1icol(i)irow(i)1icoliirowi, for i = 1,2,,nnzi=1,2,,nnz.
6:     dup – string (length ≥ 1)
Indicates how any nonzero elements with duplicate row and column indices are to be treated.
dup = 'R'dup='R'
The entries are removed.
dup = 'S'dup='S'
The relevant values in a are summed.
dup = 'F'dup='F'
The function fails with ifail = 3ifail=3 on detecting a duplicate.
Constraint: dup = 'R'dup='R', 'S''S' or 'F''F'.
7:     zer – string (length ≥ 1)
Indicates how any elements with zero values in array a are to be treated.
zer = 'R'zer='R'
The entries are removed.
zer = 'K'zer='K'
The entries are kept.
zer = 'F'zer='F'
The function fails with ifail = 4ifail=4 on detecting a zero.
Constraint: zer = 'R'zer='R', 'K''K' or 'F''F'.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

iwork

Output Parameters

1:     nnz – int64int32nag_int scalar
The number of lower triangular nonzero elements with unique row and column indices.
2:     a( : :) – complex array
Note: the dimension of the array a must be at least max (1,nnz)max(1,nnz).
The lower triangular nonzero elements ordered by increasing row index, and by increasing column index within each row. Each nonzero element has a unique row and column index.
3:     irow( : :) – int64int32nag_int array
Note: the dimension of the array irow must be at least max (1,nnz)max(1,nnz).
The first nnz elements contain the row indices corresponding to the nonzero elements returned in the array a.
4:     icol( : :) – int64int32nag_int array
Note: the dimension of the array icol must be at least max (1,nnz)max(1,nnz).
The first nnz elements contain the column indices corresponding to the nonzero elements returned in the array a.
5:     istr(n + 1n+1) – int64int32nag_int array
istr(i)istri, for i = 1,2,,ni=1,2,,n, is the starting address in the arrays a, irow and icol of row ii of the matrix AA. istr(n + 1)istrn+1 is the address of the last nonzero element in AA plus one.
6:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,n < 1n<1,
ornnz < 0nnz<0,
ordup'R'dup'R', 'S''S' or 'F''F',
orzer'R'zer'R', 'K''K' or 'F''F'.
  ifail = 2ifail=2
On entry, a nonzero element has been supplied which does not lie in the lower triangular part of AA, i.e., one or more of the following constraints have been violated:
  • 1irow(i)n1irowin,
  • 1icol(i)irow(i)1icoliirowi,
for i = 1,2,,nnzi=1,2,,nnz
  ifail = 3ifail=3
On entry, dup = 'F'dup='F' and nonzero elements have been supplied which have duplicate row and column indices.
  ifail = 4ifail=4
On entry, zer = 'F'zer='F' and at least one matrix element has been supplied with a zero coefficient value.

Accuracy

Not applicable.

Further Comments

The time taken for a call to nag_sparse_complex_herm_sort (f11zp) is proportional to nnz.
Note that the resulting matrix may have either rows or columns with no entries. If row ii has no entries then istr(i) = istr(i + 1)istri=istri+1.

Example

function nag_sparse_complex_herm_sort_example
n = int64(4);
nz = int64(9);
a = [ 1 + 2i;
      0 + 0i;
      0 + 3i;
      3 - 5i;
      4 + 2i;
      0 + 3i;
      2 + 4i;
      1 - 1i;
      1 + 3i];
irow = [int64(3);2;3;4;1;2;3;3;3];
icol = [int64(2);1;2;4;1;2;3;2;2];
dup = 'S';
zero = 'R';
[nzOut, aOut, irowOut, icolOut, istr, ifail] = ...
    nag_sparse_complex_herm_sort(n, nz, a, irow, icol, dup, zero)
 

nzOut =

                    5


aOut =

   4.0000 + 2.0000i
   0.0000 + 3.0000i
   3.0000 + 7.0000i
   2.0000 + 4.0000i
   3.0000 - 5.0000i


irowOut =

                    1
                    2
                    3
                    3
                    4


icolOut =

                    1
                    2
                    2
                    3
                    4


istr =

                    1
                    2
                    3
                    5
                    6


ifail =

                    0


function f11zp_example
n = int64(4);
nz = int64(9);
a = [ 1 + 2i;
      0 + 0i;
      0 + 3i;
      3 - 5i;
      4 + 2i;
      0 + 3i;
      2 + 4i;
      1 - 1i;
      1 + 3i];
irow = [int64(3);2;3;4;1;2;3;3;3];
icol = [int64(2);1;2;4;1;2;3;2;2];
dup = 'S';
zero = 'R';
[nzOut, aOut, irowOut, icolOut, istr, ifail] = ...
    f11zp(n, nz, a, irow, icol, dup, zero)
 

nzOut =

                    5


aOut =

   4.0000 + 2.0000i
   0.0000 + 3.0000i
   3.0000 + 7.0000i
   2.0000 + 4.0000i
   3.0000 - 5.0000i


irowOut =

                    1
                    2
                    3
                    3
                    4


icolOut =

                    1
                    2
                    2
                    3
                    4


istr =

                    1
                    2
                    3
                    5
                    6


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013