PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_sparse_complex_gen_matvec (f11xn)
Purpose
nag_sparse_complex_gen_matvec (f11xn) computes a matrix-vector or conjugate transposed matrix-vector product involving a complex sparse non-Hermitian matrix stored in coordinate storage format.
Syntax
[
y,
ifail] = f11xn(
trans,
a,
irow,
icol,
check,
x, 'n',
n, 'nz',
nz)
[
y,
ifail] = nag_sparse_complex_gen_matvec(
trans,
a,
irow,
icol,
check,
x, 'n',
n, 'nz',
nz)
Description
nag_sparse_complex_gen_matvec (f11xn) computes either the matrix-vector product
, or the conjugate transposed matrix-vector product
, according to the value of the argument
trans, where
is a complex
by
sparse non-Hermitian matrix, of arbitrary sparsity pattern. The matrix
is stored in coordinate storage (CS) format (see
Coordinate storage (CS) format in the F11 Chapter Introduction). The array
a stores all the nonzero elements of
, while arrays
irow and
icol store the corresponding row and column indices respectively.
It is envisaged that a common use of
nag_sparse_complex_gen_matvec (f11xn) will be to compute the matrix-vector product required in the application of
nag_sparse_complex_gen_basic_solver (f11bs) to sparse complex linear systems. This is illustrated in
Example in
nag_sparse_complex_gen_precon_ssor_solve (f11dr).
References
None.
Parameters
Compulsory Input Parameters
- 1:
– string (length ≥ 1)
-
Specifies whether or not the matrix
is conjugate transposed.
- is computed.
- is computed.
Constraint:
or .
- 2:
– complex array
-
The nonzero elements in the matrix
, 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_gen_sort (f11zn) may be used to order the elements in this way.
- 3:
– int64int32nag_int array
- 4:
– int64int32nag_int array
-
The row and column indices of the nonzero elements supplied in array
a.
Constraints:
- and , for ;
- or and , for .
- 5:
– string (length ≥ 1)
-
Specifies whether or not the CS representation of the matrix
, values of
n,
nz,
irow and
icol should be checked.
- Checks are carried on the values of n, nz, irow and icol.
- None of these checks are carried out.
Constraint:
or .
- 6:
– complex array
-
The vector .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the array
x.
, the order of the matrix .
Constraint:
.
- 2:
– 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 matrix .
Constraint:
.
Output Parameters
- 1:
– complex array
-
The vector .
- 2:
– 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 . |
-
-
On entry, | , |
or | , |
or | . |
-
-
On entry, the arrays
irow and
icol fail to satisfy the following constraints:
- and , for ;
- , or and , for .
Therefore a nonzero element has been supplied which does not lie within the matrix
, is out of order, or has duplicate row and column indices. Call
nag_sparse_complex_gen_sort (f11zn) to reorder and sum or remove duplicates.
-
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
The computed vector
satisfies the error bound:
- , if , or
- ,
if ,
where
is a modest linear function of
, and
is the
machine precision
Further Comments
Timing
The time taken for a call to
nag_sparse_complex_gen_matvec (f11xn) is proportional to
nz.
Use of check
It is expected that a common use of
nag_sparse_complex_gen_matvec (f11xn) will be to compute the matrix-vector product required in the application of
nag_sparse_complex_gen_basic_solver (f11bs) to sparse complex linear systems. In this situation
nag_sparse_complex_gen_matvec (f11xn) is likely to be called many times with the same matrix
. In the interests of both reliability and efficiency you are recommended to set
for the first of such calls, and to set
for all subsequent calls.
Example
This example reads in a complex sparse matrix and a vector . It then calls nag_sparse_complex_gen_matvec (f11xn) to compute the matrix-vector product and the conjugate transposed matrix-vector product .
Open in the MATLAB editor:
f11xn_example
function f11xn_example
fprintf('f11xn example results\n\n');
a = [ 2 + 3i 1 - 4i ...
1 + 0i -1 - 2i ...
4 + 1i 0 + 1i 1 + 3i ...
0 - 1i 2 - 6i ...
-2 + 0i 3 + 1i];
irow = [int64(1) 1 2 2 3 3 3 4 4 5 5];
icol = [int64(1) 2 3 4 1 3 5 4 5 2 5];
x = [ 0.70 + 0.21i;
0.16 - 0.43i;
0.52 + 0.97i;
0.77 + 0.00i;
0.28 - 0.64i];
trans = 'N';
check = 'C';
[y, ifail] = f11xn( ...
trans, a, irow, icol, check, x);
fprintf('\nMatrix-vector product\n');
disp(y);
trans = 'T';
check = 'N';
[y, ifail] = f11xn( ...
trans, a, irow, icol, check, x);
fprintf('\nConjugate transposed matrix-vector product\n');
disp(y);
f11xn example results
Matrix-vector product
-0.7900 + 1.4500i
-0.2500 - 0.5700i
3.8200 + 2.2600i
-3.2800 - 3.7300i
1.1600 - 0.7800i
Conjugate transposed matrix-vector product
5.0800 + 1.6800i
-0.7000 + 4.2900i
1.1300 - 0.9500i
0.7000 + 1.5200i
5.1700 + 1.8300i
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015