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_blast_ddot (f16ea)

## Purpose

nag_blast_ddot (f16ea) updates a scalar by a scaled dot product of two real vectors.

## Syntax

[r] = f16ea(conj, n, alpha, x, incx, beta, y, incy, r)
[r] = nag_blast_ddot(conj, n, alpha, x, incx, beta, y, incy, r)

## Description

nag_blast_ddot (f16ea) performs the operation
 $r← βr+ αxTy$
where $x$ and $y$ are $n$-element real vectors, and $r$, $\alpha$ and $\beta$ real scalars. If $n$ is less than zero, or, if $\beta$ is equal to one and either $\alpha$ or $n$ is equal to zero, this function returns immediately.

## References

Basic Linear Algebra Subprograms Technical (BLAST) Forum (2001) Basic Linear Algebra Subprograms Technical (BLAST) Forum Standard University of Tennessee, Knoxville, Tennessee http://www.netlib.org/blas/blast-forum/blas-report.pdf

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{conj}$int64int32nag_int scalar
conj is not referenced and need not be set. The presence of this argument in the BLAST standard is for consistency with the interface of the complex variant of this function.
2:     $\mathrm{n}$int64int32nag_int scalar
$n$, the number of elements in $x$ and $y$.
3:     $\mathrm{alpha}$ – double scalar
The scalar $\alpha$.
4:     $\mathrm{x}\left(1+\left({\mathbf{n}}-1\right)×\left|{\mathbf{incx}}\right|\right)$ – double array
The $n$-element vector $x$.
If ${\mathbf{incx}}>0$, ${x}_{\mathit{i}}$ must be stored in ${\mathbf{x}}\left(\left(\mathit{i}-1\right)×\left|{\mathbf{incx}}\right|+1\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
If ${\mathbf{incx}}<0$, ${x}_{\mathit{i}}$ must be stored in ${\mathbf{x}}\left(\left({\mathbf{n}}-\mathit{i}\right)×\left|{\mathbf{incx}}\right|+1\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
Intermediate elements of x are not referenced. If $\alpha =0.0$ or ${\mathbf{n}}=0$, x is not referenced.
5:     $\mathrm{incx}$int64int32nag_int scalar
The increment in the subscripts of x between successive elements of $x$.
Constraint: ${\mathbf{incx}}\ne 0$.
6:     $\mathrm{beta}$ – double scalar
The scalar $\beta$.
7:     $\mathrm{y}\left(1+\left({\mathbf{n}}-1\right)×\left|{\mathbf{incy}}\right|\right)$ – double array
The $n$-element vector $y$.
If ${\mathbf{incy}}>0$, ${y}_{\mathit{i}}$ must be stored in ${\mathbf{y}}\left(\left(\mathit{i}-1\right)×\left|{\mathbf{incy}}\right|+1\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
If ${\mathbf{incy}}<0$, ${y}_{\mathit{i}}$ must be stored in ${\mathbf{y}}\left(\left({\mathbf{n}}-\mathit{i}\right)×\left|{\mathbf{incy}}\right|+1\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
Intermediate elements of y are not referenced. If $\alpha =0.0$ or ${\mathbf{n}}=0$, y is not referenced.
8:     $\mathrm{incy}$int64int32nag_int scalar
The increment in the subscripts of y between successive elements of $y$.
Constraint: ${\mathbf{incy}}\ne 0$.
9:     $\mathrm{r}$ – double scalar
The initial value, $r$, to be updated. If $\beta =0.0$, r need not be set on entry.

None.

### Output Parameters

1:     $\mathrm{r}$ – double scalar
The value $r$, scaled by $\beta$ and updated by the scaled dot product of $x$ and $y$.

## Error Indicators and Warnings

If ${\mathbf{incx}}=0$ or ${\mathbf{incy}}=0$, an error message is printed and program execution is terminated.

## Accuracy

The dot product ${x}^{\mathrm{T}}y$ is computed using the BLAS routine DDOT.
The BLAS standard requires accurate implementations which avoid unnecessary over/underflow (see Section 2.7 of Basic Linear Algebra Subprograms Technical (BLAST) Forum (2001)).

None.

## Example

This example computes the scaled sum of two dot products, $r={\alpha }_{1}{x}^{\mathrm{T}}y+{\alpha }_{2}{u}^{\mathrm{T}}v$, where
 $α1=0.3 , x= 1,2,3,4,5 , y= -5,-4,3,2,1 , α2 = -7.0 , u=v= 0.4,0.3,0.2,0.1 .$
$y$ and $v$ are stored in reverse order, and $u$ is stored in reverse order in every other element of a real array.
```function f16ea_example

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

% First dot product; equivalent of
% r =  0*r + 0.3*x*y(n:-1:1)'
n     = int64(5);
incx  = int64(1);
incy  = int64(-1);
x     = [1   2   3   4   5];
y     = [1   2   3  -4  -5];
alpha = 0.3;
beta  = 0;
conj  = int64(0);
r     = 0;

[r] = f16ea(...
conj, n, alpha, x, incx, beta, y, incy, r);

fprintf('      first dot product = %7.2f\n',r);

% Second ddot to be added to first; equivalent of
% r = r -7*x(2*(n-1)+1:-2:1)*y(n:-1:1)'
n     = int64(4);
incx  = int64(-2);
incy  = int64(-1);
alpha = -7.0;
beta  = 1;
x     = [0.1   9.9   0.2   9.9   0.3  9.9  0.4];
y     = [0.1   0.2   0.3   0.4];

[r] = f16ea(...
conj, n, alpha, x, incx, beta, y, incy, r);

fprintf('Accumulated dot product = %7.2f\n',r);

```
```f16ea example results

first dot product =    2.70
Accumulated dot product =    0.60
```

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