PDF version (NAG web site
, 64-bit version, 64-bit version)
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
[
nz,
a,
irow,
icol,
istr,
ifail] = f11zp(
n,
nz,
a,
irow,
icol,
dup,
zer)
[
nz,
a,
irow,
icol,
istr,
ifail] = nag_sparse_complex_herm_sort(
n,
nz,
a,
irow,
icol,
dup,
zer)
Description
nag_sparse_complex_herm_sort (f11zp) takes a symmetric coordinate storage (SCS) representation (see
Symmetric coordinate storage (SCS) format in the F11 Chapter Introduction) of a sparse
by
complex Hermitian matrix
, 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
.
References
None.
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int scalar
-
, the order of the matrix .
Constraint:
.
- 2:
– int64int32nag_int scalar
-
The number of nonzero elements in the lower triangular part of the matrix .
Constraint:
.
- 3:
– complex array
-
The dimension of the array
a
must be at least
The nonzero elements of the lower triangular part of the complex matrix . These may be in any order and there may be multiple nonzero elements with the same row and column indices.
- 4:
– int64int32nag_int array
-
The dimension of the array
irow
must be at least
The row indices corresponding to the nonzero elements supplied in the array
a.
Constraint:
, for .
- 5:
– int64int32nag_int array
-
The dimension of the array
icol
must be at least
The column indices corresponding to the nonzero elements supplied in the array
a.
Constraint:
, for .
- 6:
– string (length ≥ 1)
-
Indicates how any nonzero elements with duplicate row and column indices are to be treated.
- The entries are removed.
- The relevant values in a are summed.
- The function fails with on detecting a duplicate.
Constraint:
, or .
- 7:
– string (length ≥ 1)
-
Indicates how any elements with zero values in array
a are to be treated.
- The entries are removed.
- The entries are kept.
- The function fails with on detecting a zero.
Constraint:
, or .
Optional Input Parameters
None.
Output Parameters
- 1:
– int64int32nag_int scalar
-
The number of lower triangular nonzero elements with unique row and column indices.
- 2:
– complex array
-
The dimension of the array
a will be
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:
– int64int32nag_int array
-
The dimension of the array
irow will be
The first
nz elements contain the row indices corresponding to the nonzero elements returned in the array
a.
- 4:
– int64int32nag_int array
-
The dimension of the array
icol will be
The first
nz elements contain the column indices corresponding to the nonzero elements returned in the array
a.
- 5:
– int64int32nag_int array
-
, for
, is the starting address in the arrays
a,
irow and
icol of row
of the matrix
.
is the address of the last nonzero element in
plus one.
- 6:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
On entry, | , |
or | , |
or | , or , |
or | , or . |
-
-
On entry, a nonzero element has been supplied which does not lie in the lower triangular part of
, i.e., one or more of the following constraints have been violated:
for
-
-
On entry, and nonzero elements have been supplied which have duplicate row and column indices.
-
-
On entry, and at least one matrix element has been supplied with a zero coefficient value.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
Not applicable.
Further Comments
The time taken for a call to
nag_sparse_complex_herm_sort (f11zp) is proportional to
nz.
Note that the resulting matrix may have either rows or columns with no entries. If row has no entries then .
Example
This example reads the SCS representation of a complex sparse Hermitian matrix , calls nag_sparse_complex_herm_sort (f11zp) to reorder the nonzero elements, and outputs the original and the reordered representations.
Open in the MATLAB editor:
f11zp_example
function f11zp_example
fprintf('f11zp example results\n\n');
n = int64(4);
nz = int64(9);
irow = zeros(nz,1,'int64');
icol = zeros(nz,1,'int64');
a = zeros(nz,1);
a(1:nz) = [ 1 + 2i; 0 + 0i; 0 + 3i;
3 - 5i; 4 + 2i; 0 + 3i;
2 + 4i; 1 - 1i; 1 + 3i];
irow(1:nz) = [ 3; 2; 3;
4; 1; 2;
3; 3; 3];
icol(1:nz) = [ 2; 1; 2;
4; 1; 2;
3; 2; 2];
fprintf('Number of elements in original sparse matrix: %5d\n',nz);
disp('Original matrix ordering:');
fprintf(' k a(k) i_k j_k\n');
for j = 1:nz
fprintf('%4d (%4.1f,%4.1f)%5d%5d\n', j, real(a(j)), imag(a(j)), ...
irow(j),icol(j));
end
dup = 'S';
zero = 'R';
[nz, a, irow, icol, istr, ifail] = ...
f11zp( ...
n, nz, a, irow, icol, dup, zero);
fprintf('\nNumber of elements in reordered sparse matrix: %5d\n',nz);
disp('New ordering:');
fprintf(' k a(k) i_k j_k\n');
for j = 1:nz
fprintf('%4d (%4.1f,%4.1f)%5d%5d\n', j, real(a(j)), imag(a(j)), ...
irow(j),icol(j));
end
f11zp example results
Number of elements in original sparse matrix: 9
Original matrix ordering:
k a(k) i_k j_k
1 ( 1.0, 2.0) 3 2
2 ( 0.0, 0.0) 2 1
3 ( 0.0, 3.0) 3 2
4 ( 3.0,-5.0) 4 4
5 ( 4.0, 2.0) 1 1
6 ( 0.0, 3.0) 2 2
7 ( 2.0, 4.0) 3 3
8 ( 1.0,-1.0) 3 2
9 ( 1.0, 3.0) 3 2
Number of elements in reordered sparse matrix: 5
New ordering:
k a(k) i_k j_k
1 ( 4.0, 2.0) 1 1
2 ( 0.0, 3.0) 2 2
3 ( 3.0, 7.0) 3 2
4 ( 2.0, 4.0) 3 3
5 ( 3.0,-5.0) 4 4
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015