Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_blast_dsum (f16el)

## Purpose

nag_blast_dsum (f16el) sums the elements of a real vector.

## Syntax

[result] = f16el(n, x, incx)
[result] = nag_blast_dsum(n, x, incx)

## Description

nag_blast_dsum (f16el) returns the sum
 $x1 + x2 + ⋯ + xn$
of the elements of an $n$-element real vector $x$, via the function name.
If ${\mathbf{n}}\le 0$ on entry, nag_blast_dsum (f16el) returns the value $0$.

## 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{n}$int64int32nag_int scalar
$n$, the number of elements in $x$.
2:     $\mathrm{x}\left(1+\left({\mathbf{n}}-1\right)×\left|{\mathbf{incx}}\right|\right)$ – double array
The vector $x$. Element ${x}_{\mathit{i}}$ is stored in ${\mathbf{x}}\left(\left(\mathit{i}-1\right)×\left|{\mathbf{incx}}\right|+1\right)$, for $\mathit{i}=1,2,\dots ,n$.
3:     $\mathrm{incx}$int64int32nag_int scalar
The increment in the subscripts of x between successive elements of $x$.
Constraint: ${\mathbf{incx}}\ne 0$.

None.

### Output Parameters

1:     $\mathrm{result}$ – double scalar
The result of the function.

## Error Indicators and Warnings

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

## Accuracy

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 sum of the elements of
 $x = 1.1,10.2,11.5,-2.7,9.2T .$
```function f16el_example

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

% sum x
n    = int64(5);
x    = [1.1   10.2    11.5   -2.7    9.2];
incx = int64(1);

[xsum] = f16el(n, x, incx);

fprintf('sum(');
fprintf('%7.1f',x);
fprintf(') = %7.1f\n',xsum);

```
```f16el example results

sum(    1.1   10.2   11.5   -2.7    9.2) =    29.3
```