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_matvec (f11xs)

Purpose

nag_sparse_complex_herm_matvec (f11xs) computes a matrix-vector product involving a complex sparse Hermitian matrix stored in symmetric coordinate storage format.

Syntax

[y, ifail] = f11xs(a, irow, icol, check, x, 'n', n, 'nnz', nnz)
[y, ifail] = nag_sparse_complex_herm_matvec(a, irow, icol, check, x, 'n', n, 'nnz', nnz)

Description

nag_sparse_complex_herm_matvec (f11xs) computes the matrix-vector product
 y = Ax $y=Ax$
where A$A$ is an n$n$ by n$n$ complex Hermitian sparse matrix, of arbitrary sparsity pattern, stored in symmetric coordinate storage (SCS) format (see Section [Symmetric coordinate storage (SCS) format] in the F11 Chapter Introduction). The array a stores all the nonzero elements in the lower triangular part of A$A$, while arrays irow and icol store the corresponding row and column indices respectively.

None.

Parameters

Compulsory Input Parameters

1:     a(nnz) – complex array
nnz, the dimension of the array, must satisfy the constraint 1nnzn × (n + 1) / 2$1\le {\mathbf{nnz}}\le {\mathbf{n}}×\left({\mathbf{n}}+1\right)/2$.
The nonzero elements in the lower triangular part of the matrix A$A$, ordered by increasing row index, and by increasing column index within each row. Multiple entries for the same row and column indices are not permitted. The function nag_sparse_complex_herm_sort (f11zp) may be used to order the elements in this way.
2:     irow(nnz) – int64int32nag_int array
3:     icol(nnz) – int64int32nag_int array
nnz, the dimension of the array, must satisfy the constraint 1nnzn × (n + 1) / 2$1\le {\mathbf{nnz}}\le {\mathbf{n}}×\left({\mathbf{n}}+1\right)/2$.
The row and column indices of the nonzero elements supplied in array a.
Constraints:
irow and icol must satisfy the following constraints (which may be imposed by a call to nag_sparse_complex_herm_sort (f11zp)):
• 1irow(i)n$1\le {\mathbf{irow}}\left(\mathit{i}\right)\le {\mathbf{n}}$ and 1icol(i)irow(i)$1\le {\mathbf{icol}}\left(\mathit{i}\right)\le {\mathbf{irow}}\left(\mathit{i}\right)$, for i = 1,2,,nnz$\mathit{i}=1,2,\dots ,{\mathbf{nnz}}$;
• irow(i1) < irow(i)${\mathbf{irow}}\left(\mathit{i}-1\right)<{\mathbf{irow}}\left(\mathit{i}\right)$ or irow(i1) = irow(i)${\mathbf{irow}}\left(\mathit{i}-1\right)={\mathbf{irow}}\left(\mathit{i}\right)$ and icol(i1) < icol(i)${\mathbf{icol}}\left(\mathit{i}-1\right)<{\mathbf{icol}}\left(\mathit{i}\right)$, for i = 2,3,,nnz$\mathit{i}=2,3,\dots ,{\mathbf{nnz}}$.
4:     check – string (length ≥ 1)
Specifies whether or not the SCS representation of the matrix A$A$, values of n, nnz, irow and icol should be checked.
check = 'C'${\mathbf{check}}=\text{'C'}$
Checks are carried out on the values of n, nnz, irow and icol.
check = 'N'${\mathbf{check}}=\text{'N'}$
None of these checks are carried out.
Constraint: check = 'C'${\mathbf{check}}=\text{'C'}$ or 'N'$\text{'N'}$.
5:     x(n) – complex array
n, the dimension of the array, must satisfy the constraint n1${\mathbf{n}}\ge 1$.
The vector x$x$.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the array x.
n$n$, the order of the matrix A$A$.
Constraint: n1${\mathbf{n}}\ge 1$.
2:     nnz – int64int32nag_int scalar
Default: The dimension of the arrays a, irow, icol. (An error is raised if these dimensions are not equal.)
The number of nonzero elements in the lower triangular part of the matrix A$A$.
Constraint: 1nnzn × (n + 1) / 2$1\le {\mathbf{nnz}}\le {\mathbf{n}}×\left({\mathbf{n}}+1\right)/2$.

None.

Output Parameters

1:     y(n) – complex array
The vector y$y$.
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, check ≠ 'C'${\mathbf{check}}\ne \text{'C'}$ or 'N'$\text{'N'}$.
ifail = 2${\mathbf{ifail}}=2$
 On entry, n < 1${\mathbf{n}}<1$, or nnz < 1${\mathbf{nnz}}<1$, or nnz > n × (n + 1) / 2${\mathbf{nnz}}>{\mathbf{n}}×\left({\mathbf{n}}+1\right)/2$.
ifail = 3${\mathbf{ifail}}=3$
On entry, the arrays irow and icol fail to satisfy the following constraints:
• 1irow(i)n$1\le {\mathbf{irow}}\left(i\right)\le {\mathbf{n}}$ and 1icol(i)irow(i)$1\le {\mathbf{icol}}\left(i\right)\le {\mathbf{irow}}\left(i\right)$, for i = 1,2,,nnz$i=1,2,\dots ,{\mathbf{nnz}}$;
• irow(i1) < irow(i)${\mathbf{irow}}\left(i-1\right)<{\mathbf{irow}}\left(i\right)$ or irow(i1) = irow(i)${\mathbf{irow}}\left(i-1\right)={\mathbf{irow}}\left(i\right)$ and icol(i1) < icol(i)${\mathbf{icol}}\left(i-1\right)<{\mathbf{icol}}\left(i\right)$, for i = 2,3,,nnz$i=2,3,\dots ,{\mathbf{nnz}}$.
Therefore a nonzero element has been supplied which does not lie in the lower triangular part of A$A$, is out of order, or has duplicate row and column indices. Call nag_sparse_complex_herm_sort (f11zp) to reorder and sum or remove duplicates.

Accuracy

The computed vector y$y$ satisfies the error bound
 ‖y − Ax‖∞ ≤ c(n)ε‖A‖∞‖x‖∞, $‖y-Ax‖∞≤c(n)ε‖A‖∞‖x‖∞,$
where c(n)$c\left(n\right)$ is a modest linear function of n$n$, and ε$\epsilon$ is the machine precision.

Timing

The time taken for a call to nag_sparse_complex_herm_matvec (f11xs) is proportional to nnz.

Example

```function nag_sparse_complex_herm_matvec_example
a = [6;
-1 + 1i;
6 + 0i;
0 + 1i;
5 + 0i;
5 + 0i;
2 - 2i;
4 + 0i;
1 + 1i;
2 + 0i;
6 + 0i;
-4 + 3i;
0 + 1i;
-1 + 0i;
6 + 0i;
-1 - 1i;
0 - 1i;
9 + 0i;
1 + 3i;
1 + 2i;
-1 + 0i;
1 + 4i;
9 + 0i];
irow = [int64(1);2;2;3;3;4;5;5;6;6;6;7;7;7;7;8;8;8;9;9;9;9;9];
icol = [int64(1);1;2;2;3;4;1;5;3;4;6;2;5;6;7;4;6;8;1;5;6;8;9];
check = 'C';
x = [ 1 + 9i;
2 - 8i;
3 + 7i;
4 - 6i;
5 + 5i;
6 - 4i;
7 + 3i;
8 - 2i;
9 + 1i];
[y, ifail] = nag_sparse_complex_herm_matvec(a, irow, icol, check, x)
```
```

y =

8.0000 +54.0000i
-10.0000 -92.0000i
25.0000 +27.0000i
26.0000 -28.0000i
54.0000 +12.0000i
26.0000 -22.0000i
47.0000 +65.0000i
71.0000 -57.0000i
60.0000 +70.0000i

ifail =

0

```
```function f11xs_example
a = [6;
-1 + 1i;
6 + 0i;
0 + 1i;
5 + 0i;
5 + 0i;
2 - 2i;
4 + 0i;
1 + 1i;
2 + 0i;
6 + 0i;
-4 + 3i;
0 + 1i;
-1 + 0i;
6 + 0i;
-1 - 1i;
0 - 1i;
9 + 0i;
1 + 3i;
1 + 2i;
-1 + 0i;
1 + 4i;
9 + 0i];
irow = [int64(1);2;2;3;3;4;5;5;6;6;6;7;7;7;7;8;8;8;9;9;9;9;9];
icol = [int64(1);1;2;2;3;4;1;5;3;4;6;2;5;6;7;4;6;8;1;5;6;8;9];
check = 'C';
x = [ 1 + 9i;
2 - 8i;
3 + 7i;
4 - 6i;
5 + 5i;
6 - 4i;
7 + 3i;
8 - 2i;
9 + 1i];
[y, ifail] = f11xs(a, irow, icol, check, x)
```
```

y =

8.0000 +54.0000i
-10.0000 -92.0000i
25.0000 +27.0000i
26.0000 -28.0000i
54.0000 +12.0000i
26.0000 -22.0000i
47.0000 +65.0000i
71.0000 -57.0000i
60.0000 +70.0000i

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