hide long namesshow long names
hide short namesshow short names
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)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

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, α and β real scalars. If n is less than zero, or, if β is equal to one and either α 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:     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:     n int64int32nag_int scalar
n, the number of elements in x and y.
3:     alpha – double scalar
The scalar α.
4:     x1+n-1×incx – double array
The n-element vector x.
If incx>0, xi must be stored in xi-1×incx+1, for i=1,2,,n.
If incx<0, xi must be stored in xn-i×incx+1, for i=1,2,,n.
Intermediate elements of x are not referenced. If α=0.0 or n=0, x is not referenced.
5:     incx int64int32nag_int scalar
The increment in the subscripts of x between successive elements of x.
Constraint: incx0.
6:     beta – double scalar
The scalar β.
7:     y1+n-1×incy – double array
The n-element vector y.
If incy>0, yi must be stored in yi-1×incy+1, for i=1,2,,n.
If incy<0, yi must be stored in yn-i×incy+1, for i=1,2,,n.
Intermediate elements of y are not referenced. If α=0.0 or n=0, y is not referenced.
8:     incy int64int32nag_int scalar
The increment in the subscripts of y between successive elements of y.
Constraint: incy0.
9:     r – double scalar
The initial value, r, to be updated. If β=0.0, r need not be set on entry.

Optional Input Parameters

None.

Output Parameters

1:     r – double scalar
The value r, scaled by β and updated by the scaled dot product of x and y.

Error Indicators and Warnings

If incx=0 or incy=0, an error message is printed and program execution is terminated.

Accuracy

The dot product xTy  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)).

Further Comments

None.

Example

This example computes the scaled sum of two dot products, r= α1 xTy+ α2 uTv , 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