Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

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$c$ to give a correctly rounded result d$d$:
 n d = c + ∑ aibi. i = 1
$d=c+∑i=1naibi.$
If n < 1$n<1$, d = c$d=c$.
The vector elements ai${a}_{i}$ and bi${b}_{i}$ are stored in selected elements of the one-dimensional array parameters 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 Section [Parameters] for details, and Section [Example] for an example.
The products are accumulated in basic precision or additional precision depending on the parameter 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:     a(isizea) – complex array
isizea, the dimension of the array, must satisfy the constraint isizea(n1) × istepa + 1${\mathbf{isizea}}\ge \left({\mathbf{n}}-1\right)×{\mathbf{istepa}}+1$.
The elements of the first vector.
The i$i$th vector element is stored in the array element a((i1) × istepa + 1)${\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:     b(isizeb) – complex array
isizeb, the dimension of the array, must satisfy the constraint isizeb(n1) × istepb + 1${\mathbf{isizeb}}\ge \left({\mathbf{n}}-1\right)×{\mathbf{istepb}}+1$.
The elements of the second vector.
The i$i$th vector element is stored in the array element b((i1) × istepb + 1)${\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:     n – int64int32nag_int scalar
n$n$, the number of elements in the scalar product.
4:     istepa – int64int32nag_int scalar
The step length between elements of the first vector in array a.
Constraint: istepa > 0${\mathbf{istepa}}>0$.
5:     istepb – int64int32nag_int scalar
The step length between elements of the second vector in array b.
Constraint: istepb > 0${\mathbf{istepb}}>0$.
6:     cx – complex scalar
The initial value c$c$.
7:     sw – logical scalar
The precision to be used in the calculation.
sw = true${\mathbf{sw}}=\mathbf{true}$
sw = false${\mathbf{sw}}=\mathbf{false}$
basic precision.

### Optional Input Parameters

1:     isizea – int64int32nag_int scalar
Default: The dimension of the array a.
The dimension of the array a as declared in the (sub)program from which nag_dot_complex_prec (x03ab) is called.
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$1$.
Constraint: isizea(n1) × istepa + 1${\mathbf{isizea}}\ge \left({\mathbf{n}}-1\right)×{\mathbf{istepa}}+1$.
2:     isizeb – int64int32nag_int scalar
Default: The dimension of the array b.
The dimension of the array b as declared in the (sub)program from which nag_dot_complex_prec (x03ab) is called.
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$1$.
Constraint: isizeb(n1) × istepb + 1${\mathbf{isizeb}}\ge \left({\mathbf{n}}-1\right)×{\mathbf{istepb}}+1$.

None.

### Output Parameters

1:     dx – complex scalar
The result d$d$.
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, istepa ≤ 0${\mathbf{istepa}}\le 0$, or istepb ≤ 0${\mathbf{istepb}}\le 0$.
ifail = 2${\mathbf{ifail}}=2$
 On entry, isizea < (n − 1) × istepa + 1${\mathbf{isizea}}<\left({\mathbf{n}}-1\right)×{\mathbf{istepa}}+1$, or isizeb < (n − 1) × istepb + 1${\mathbf{isizeb}}<\left({\mathbf{n}}-1\right)×{\mathbf{istepb}}+1$.

## 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$n$ and also depends on whether basic precision or additional precision is used.

## Example

```function nag_dot_complex_prec_example
a = [ 0 - 1i;
0 + 1i;
-1 - 1i];
b = [ 0 + 1i;
1 - 1i;
0 - 1i];
n = int64(3);
istepa = int64(1);
istepb = int64(1);
cx =  1 + 1i;
sw = true;
[dx, ifail] = nag_dot_complex_prec(a, b, n, istepa, istepb, cx, sw)
```
```

dx =

2.0000 + 3.0000i

ifail =

0

```
```function x03ab_example
a = [ 0 - 1i;
0 + 1i;
-1 - 1i];
b = [ 0 + 1i;
1 - 1i;
0 - 1i];
n = int64(3);
istepa = int64(1);
istepb = int64(1);
cx =  1 + 1i;
sw = true;
[dx, ifail] = x03ab(a, b, n, istepa, istepb, cx, sw)
```
```

dx =

2.0000 + 3.0000i

ifail =

0

```