PDF version (NAG web site
, 64-bit version, 64-bit version)
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
to give a correctly rounded result
:
If
,
.
The vector elements
and
are stored in selected elements of the one-dimensional array arguments
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
Arguments for details, and
Example for an example.
Both the initial value
and the result
are defined by a pair of double variables, so that they may take either
basic precision or
additional precision values.
(a) |
If , 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 , 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:
– double array
-
The elements of the first vector.
The
th vector element is stored in the array element
. 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:
– double array
-
The elements of the second vector.
The
th vector element is stored in the array element
. 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:
– int64int32nag_int scalar
-
, the number of elements in the scalar product.
- 4:
– int64int32nag_int scalar
-
The step length between elements of the first vector in array
a.
Constraint:
.
- 5:
– int64int32nag_int scalar
-
The step length between elements of the second vector in array
b.
Constraint:
.
- 6:
– double scalar
- 7:
– double scalar
-
c1 and
c2 must specify the initial value
:
. Normally, if
is in
additional precision,
c1 specifies the most significant part and
c2 the least significant part; if
is in
basic precision, then
c1 specifies
and
c2 must have the value
. Both
c1 and
c2 must be defined on entry.
- 8:
– logical scalar
-
The precision to be used in the calculation.
- additional precision.
- basic precision.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the array
a.
The dimension of the array
a.
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
.
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the dimension of the array
b.
The dimension of the array
b.
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
.
Constraint:
.
Output Parameters
- 1:
– double scalar
- 2:
– double scalar
-
The result
.
If the calculation is in
additional precision (
),
- rounded to basic precision;
- ,
thus
d1 holds the correctly rounded
basic precision result and the sum
gives the result in
additional precision.
d2 may have the opposite sign to
d1
If the calculation is in
basic precision (
),
- 3:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
On entry, | , |
or | . |
-
-
On entry, | , |
or | . |
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
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 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
This example calculates the scalar product of the second column of the matrix
and the vector
, and add it to an initial value
where
Open in the MATLAB editor:
x03aa_example
function x03aa_example
fprintf('x03aa example results\n\n');
a = [ -2 -3 7;
2 -5 3;
-9 1e-19 0];
b = [ 8;
-4;
-2];
n = int64(size(a,2));
c1 = 1;
c2 = 1e-20;
istepa = int64(1);
istepb = istepa;
sw = true;
[d1, d2, ifail] = x03aa( ...
a(:,2), b, n, istepa, istepb, c1, c2, sw);
fprintf('Accumulated dot-product = %20.15e + %10.2e\n',d1,d2);
x03aa example results
Accumulated dot-product = -3.000000000000000e+00 + -1.90e-19
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015