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_dot_complex_prec (x03ab)

## Purpose

nag_dot_complex_prec (x03ab) calculates the value of a complex scalar product using basic precision or additional precision and adds it to a complex initial value.

## Syntax

[dx, ifail] = x03ab(a, b, n, istepa, istepb, cx, sw, 'isizea', isizea, 'isizeb', isizeb)
[dx, ifail] = nag_dot_complex_prec(a, b, n, istepa, istepb, cx, sw, 'isizea', isizea, 'isizeb', isizeb)

## Description

nag_dot_complex_prec (x03ab) calculates the scalar product of two complex vectors and adds it to an initial value $c$ to give a correctly rounded result $d$:
 $d=c+∑i=1naibi.$
If $n<1$, $d=c$.
The vector elements ${a}_{i}$ and ${b}_{i}$ are stored in selected elements of the one-dimensional array arguments a and b, which in the function from which nag_dot_complex_prec (x03ab) is called may be identified with parts of possibly multidimensional arrays according to the standard Fortran rules. For example, the vectors may be parts of a row or column of a matrix. See Arguments for details, and Example for an example.
The products are accumulated in basic precision or additional precision depending on the argument sw.
This function has been designed primarily for use as an auxiliary function by other functions in the NAG Toolbox, especially those in the chapters on Linear Algebra.

None.

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{a}\left({\mathbf{isizea}}\right)$ – complex array
The elements of the first vector.
The $i$th vector element is stored in the array element ${\mathbf{a}}\left(\left(i-1\right)×{\mathbf{istepa}}+1\right)$. In your function from which nag_dot_complex_prec (x03ab) is called, a can be part of a multidimensional array and the actual argument must be the array element containing the first vector element.
2:     $\mathrm{b}\left({\mathbf{isizeb}}\right)$ – complex array
The elements of the second vector.
The $i$th vector element is stored in the array element ${\mathbf{b}}\left(\left(i-1\right)×{\mathbf{istepb}}+1\right)$. In your function from which nag_dot_complex_prec (x03ab) is called, b can be part of a multidimensional array and the actual argument must be the array element containing the first vector element.
3:     $\mathrm{n}$int64int32nag_int scalar
$n$, the number of elements in the scalar product.
4:     $\mathrm{istepa}$int64int32nag_int scalar
The step length between elements of the first vector in array a.
Constraint: ${\mathbf{istepa}}>0$.
5:     $\mathrm{istepb}$int64int32nag_int scalar
The step length between elements of the second vector in array b.
Constraint: ${\mathbf{istepb}}>0$.
6:     $\mathrm{cx}$ – complex scalar
The initial value $c$.
7:     $\mathrm{sw}$ – logical scalar
The precision to be used in the calculation.
${\mathbf{sw}}=\mathit{true}$
${\mathbf{sw}}=\mathit{false}$
basic precision.

### Optional Input Parameters

1:     $\mathrm{isizea}$int64int32nag_int scalar
Default: the dimension of the array a.
The dimension of the array a.
The upper bound for isizea is found by multiplying together the dimensions of a as declared in your function from which nag_dot_complex_prec (x03ab) is called, subtracting the starting position and adding $1$.
Constraint: ${\mathbf{isizea}}\ge \left({\mathbf{n}}-1\right)×{\mathbf{istepa}}+1$.
2:     $\mathrm{isizeb}$int64int32nag_int scalar
Default: the dimension of the array b.
The dimension of the array b.
The upper bound for isizeb is found by multiplying together the dimensions of b as declared in your function from which nag_dot_complex_prec (x03ab) is called, subtracting the starting position and adding $1$.
Constraint: ${\mathbf{isizeb}}\ge \left({\mathbf{n}}-1\right)×{\mathbf{istepb}}+1$.

### Output Parameters

1:     $\mathrm{dx}$ – complex scalar
The result $d$.
2:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{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:
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{istepa}}\le 0$, or ${\mathbf{istepb}}\le 0$.
${\mathbf{ifail}}=2$
 On entry, ${\mathbf{isizea}}<\left({\mathbf{n}}-1\right)×{\mathbf{istepa}}+1$, or ${\mathbf{isizeb}}<\left({\mathbf{n}}-1\right)×{\mathbf{istepb}}+1$.
${\mathbf{ifail}}=-99$
An unexpected error has been triggered by this routine. Please contact NAG.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

## Accuracy

If the calculation is in additional precision, the result is correct to full implementation accuracy provided that exceptionally severe cancellation does not occur in the summation. If the calculation is in basic precision, such accuracy cannot be guaranteed.

The time taken by nag_dot_complex_prec (x03ab) is approximately proportional to $n$ and also depends on whether basic precision or additional precision is used.

## Example

This example calculates the scalar product of the second column of the matrix $A$ and the vector ${\mathbf{b}}$, and add it to an initial value of $1+i$, where
 $A= -1 -i 1 -2+3i i 2i -0 -1-i 1-2i , b= i 1-i -i .$
```function x03ab_example

fprintf('x03ab example results\n\n');

% Evaluate d = c + a(:,2).b, where
a = [-1 + 0i   0 - 1e20i   1 + 0i;
2 + 3i   0 + 1e-19i  0 + 2i;
0 + 0i  -1 - 1e20i   1 - 2i];
b = [ 0 + 1i;
1 - 1i;
0 - 1i];
n = int64(size(b,1));

% c is stored in basic precision only
cx =  1e-20 + 1i;

% elements are stored contiguously in a and b
istepa = int64(1);
istepb = istepa;

% Calculate dodt-product in extended precision
sw = true;

[dx, ifail] = x03ab( ...
a(:,2), b, n, istepa, istepb, cx, sw);

fprintf('Accumulated dot-product = %20.15e + %20.15ei\n', ...
real(dx), imag(dx));

```
```x03ab example results

Accumulated dot-product = 1.100000000000000e-19 + 2.000000000000000e+00i
```

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–2015