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_dot_real_prec (x03aa)

Purpose

nag_dot_real_prec (x03aa) 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.

Syntax

[d1, d2, ifail] = x03aa(a, b, n, istepa, istepb, c1, c2, sw, 'isizea', isizea, 'isizeb', isizeb)
[d1, d2, ifail] = nag_dot_real_prec(a, b, n, istepa, istepb, c1, c2, sw, 'isizea', isizea, 'isizeb', isizeb)

Description

nag_dot_real_prec (x03aa) calculates the scalar product of two double vectors and adds it to an initial value cc to give a correctly rounded result dd:
n
d = c + aibi.
i = 1
d=c+i=1naibi.
If n < 1n<1, d = cd=c.
The vector elements aiai and bibi are stored in selected elements of the one-dimensional array parameters a and b, which in the function from which nag_dot_real_prec (x03aa) 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.
Both the initial value cc and the result dd are defined by a pair of double variables, so that they may take either basic precision or additional precision values.
(a) If sw = truesw=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.
(b) If sw = falsesw=false, the products are accumulated in basic precision, and the result is returned in basic precision.
This function is designed primarily for use as an auxiliary function by other functions in the NAG Toolbox, especially those in the chapters on Linear Algebra.

References

None.

Parameters

Compulsory Input Parameters

1:     a(isizea) – double array
isizea, the dimension of the array, must satisfy the constraint isizea(n1) × istepa + 1isizea(n-1)×istepa+1.
The elements of the first vector.
The iith vector element is stored in the array element a((i1) × istepa + 1)a((i-1)×istepa+1). In your function from which nag_dot_real_prec (x03aa) 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) – double array
isizeb, the dimension of the array, must satisfy the constraint isizeb(n1) × istepb + 1isizeb(n-1)×istepb+1.
The elements of the second vector.
The iith vector element is stored in the array element b((i1) × istepb + 1)b((i-1)×istepb+1). In your function from which nag_dot_real_prec (x03aa) 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
nn, 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 > 0istepa>0.
5:     istepb – int64int32nag_int scalar
The step length between elements of the second vector in array b.
Constraint: istepb > 0istepb>0.
6:     c1 – double scalar
7:     c2 – double scalar
c1 and c2 must specify the initial value cc: c = c1 + c2c=c1+c2. Normally, if cc is in additional precision, c1 specifies the most significant part and c2 the least significant part; if cc is in basic precision, then c1 specifies cc and c2 must have the value 0.00.0. Both c1 and c2 must be defined on entry.
8:     sw – logical scalar
The precision to be used in the calculation.
sw = truesw=true
additional precision.
sw = falsesw=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_real_prec (x03aa) 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_real_prec (x03aa) is called, subtracting the starting position and adding 11.
Constraint: isizea(n1) × istepa + 1isizea(n-1)×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_real_prec (x03aa) 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_real_prec (x03aa) is called, subtracting the starting position and adding 11.
Constraint: isizeb(n1) × istepb + 1isizeb(n-1)×istepb+1.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     d1 – double scalar
2:     d2 – double scalar
The result dd.
If the calculation is in additional precision (sw = truesw=true),
  • d1 = dd1=d rounded to basic precision;
  • d2 = dd1d2=d-d1,
thus d1 holds the correctly rounded basic precision result and the sum d1 + d2d1+d2 gives the result in additional precision. d2 may have the opposite sign to d1
If the calculation is in basic precision (sw = falsesw=false),
  • d1 = dd1=d;
  • d2 = 0.0d2=0.0.
3:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,istepa0istepa0,
oristepb0istepb0.
  ifail = 2ifail=2
On entry,isizea > (n1) × istepa + 1isizea>(n-1)×istepa+1,
orisizeb > (n1) × istepb + 1isizeb>(n-1)×istepb+1.

Accuracy

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.

Further Comments

The time taken by nag_dot_real_prec (x03aa) is approximately proportional to nn 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 nag_dot_real_prec (x03aa).

Example

function nag_dot_real_prec_example
a = [-3;
     -5;
     1];
b = [8;
     -4;
     -2];
n = int64(3);
istepa = int64(1);
istepb = int64(1);
c1 = 1;
c2 = 0;
sw = true;
[d1, d2, ifail] = nag_dot_real_prec(a, b, n, istepa, istepb, c1, c2, sw)
 

d1 =

    -5


d2 =

     0


ifail =

                    0


function x03aa_example
a = [-3;
     -5;
     1];
b = [8;
     -4;
     -2];
n = int64(3);
istepa = int64(1);
istepb = int64(1);
c1 = 1;
c2 = 0;
sw = true;
[d1, d2, ifail] = x03aa(a, b, n, istepa, istepb, c1, c2, sw)
 

d1 =

    -5


d2 =

     0


ifail =

                    0



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