NAG FL Interfacex03aaf (real_​prec)

1Purpose

x03aaf calculates the value of a scalar product using basic precision or additional precision and adds it to a basic precision or additional precision initial value.

2Specification

Fortran Interface
 Subroutine x03aaf ( a, b, n, c1, c2, d1, d2, sw,
 Integer, Intent (In) :: isizea, isizeb, n, istepa, istepb Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: a(isizea), b(isizeb), c1, c2 Real (Kind=nag_wp), Intent (Out) :: d1, d2 Logical, Intent (In) :: sw
#include <nag.h>
 void x03aaf_ (const double a[], const Integer *isizea, const double b[], const Integer *isizeb, const Integer *n, const Integer *istepa, const Integer *istepb, const double *c1, const double *c2, double *d1, double *d2, const logical *sw, Integer *ifail)
The routine may be called by the names x03aaf or nagf_dot_real_prec.

3Description

x03aaf calculates the scalar product of two real 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 subroutine from which x03aaf 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 5 for details, and Section 10 for an example.
Both the initial value $c$ and the result $d$ are defined by a pair of real variables, so that they may take either basic precision or additional precision values.
1. (a)If ${\mathbf{sw}}=\mathrm{.TRUE.}$, the products are accumulated in additional precision, and on exit the result is available either in basic precision, correctly rounded, or in additional precision.
2. (b)If ${\mathbf{sw}}=\mathrm{.FALSE.}$, the products are accumulated in basic precision, and the result is returned in basic precision.
This routine is designed primarily for use as an auxiliary routine by other routines in the NAG Library, especially those in the chapters on Linear Algebra.

None.

5Arguments

1: $\mathbf{a}\left({\mathbf{isizea}}\right)$Real (Kind=nag_wp) array Input
On entry: 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 subroutine from which x03aaf 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: $\mathbf{isizea}$Integer Input
On entry: the dimension of the array a as declared in the (sub)program from which x03aaf is called.
The upper bound for isizea is found by multiplying together the dimensions of a as declared in your subroutine from which x03aaf is called, subtracting the starting position and adding $1$.
Constraint: ${\mathbf{isizea}}\ge \left({\mathbf{n}}-1\right)×{\mathbf{istepa}}+1$.
3: $\mathbf{b}\left({\mathbf{isizeb}}\right)$Real (Kind=nag_wp) array Input
On entry: 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 subroutine from which x03aaf is called, b can be part of a multidimensional array and the actual argument must be the array element containing the first vector element.
4: $\mathbf{isizeb}$Integer Input
On entry: the dimension of the array b as declared in the (sub)program from which x03aaf is called.
The upper bound for isizeb is found by multiplying together the dimensions of b as declared in your subroutine from which x03aaf is called, subtracting the starting position and adding $1$.
Constraint: ${\mathbf{isizeb}}\ge \left({\mathbf{n}}-1\right)×{\mathbf{istepb}}+1$.
5: $\mathbf{n}$Integer Input
On entry: $n$, the number of elements in the scalar product.
6: $\mathbf{istepa}$Integer Input
On entry: the step length between elements of the first vector in array a.
Constraint: ${\mathbf{istepa}}>0$.
7: $\mathbf{istepb}$Integer Input
On entry: the step length between elements of the second vector in array b.
Constraint: ${\mathbf{istepb}}>0$.
8: $\mathbf{c1}$Real (Kind=nag_wp) Input
9: $\mathbf{c2}$Real (Kind=nag_wp) Input
On entry: c1 and c2 must specify the initial value $c$: $c={\mathbf{c1}}+{\mathbf{c2}}$. Normally, if $c$ is in additional precision, c1 specifies the most significant part and c2 the least significant part; if $c$ is in basic precision, then c1 specifies $c$ and c2 must have the value $0.0$. Both c1 and c2 must be defined on entry.
10: $\mathbf{d1}$Real (Kind=nag_wp) Output
11: $\mathbf{d2}$Real (Kind=nag_wp) Output
On exit: the result $d$.
If the calculation is in additional precision (${\mathbf{sw}}=\mathrm{.TRUE.}$),
• ${\mathbf{d1}}=d$ rounded to basic precision;
• ${\mathbf{d2}}=d-{\mathbf{d1}}$,
thus d1 holds the correctly rounded basic precision result and the sum ${\mathbf{d1}}+{\mathbf{d2}}$ gives the result in additional precision. d2 may have the opposite sign to d1.
If the calculation is in basic precision (${\mathbf{sw}}=\mathrm{.FALSE.}$),
• ${\mathbf{d1}}=d$;
• ${\mathbf{d2}}=0.0$.
12: $\mathbf{sw}$Logical Input
On entry: the precision to be used in the calculation.
${\mathbf{sw}}=\mathrm{.TRUE.}$
${\mathbf{sw}}=\mathrm{.FALSE.}$
basic precision.
13: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, . If you are unfamiliar with this argument you should refer to Section 4 in the Introduction to the NAG Library FL Interface for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this argument, the recommended value is $0$. When the value is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-1$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
${\mathbf{ifail}}=1$
On entry, ${\mathbf{istepa}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{istepa}}>0$.
On entry, ${\mathbf{istepb}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{istepb}}>0$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{isizea}}=〈\mathit{\text{value}}〉$, ${\mathbf{n}}=〈\mathit{\text{value}}〉$ and ${\mathbf{istepa}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{isizea}}\ge \left({\mathbf{n}}-1\right)×{\mathbf{istepa}}+1$.
On entry, ${\mathbf{isizeb}}=〈\mathit{\text{value}}〉$, ${\mathbf{n}}=〈\mathit{\text{value}}〉$ and ${\mathbf{istepb}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{isizeb}}\ge \left({\mathbf{n}}-1\right)×{\mathbf{istepb}}+1$.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7Accuracy

If the calculation is an additional precision, the rounded basic precision result d1 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.

8Parallelism and Performance

x03aaf is not threaded in any implementation.

The time taken by x03aaf is approximately proportional to $n$ and also depends on whether basic precision or additional precision is used.
On exit the variables d1 and d2 may be used directly to supply a basic precision or additional precision initial value for a subsequent call of x03aaf.

10Example

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 $1.0$ where
 $A= -2 -3 7 2 -5 3 -9 1 0 , b= 8 -4 -2 .$

10.1Program Text

Program Text (x03aafe.f90)

10.2Program Data

Program Data (x03aafe.d)

10.3Program Results

Program Results (x03aafe.r)