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_imin_val (f16dp)

## Purpose

nag_blast_imin_val (f16dp) computes the smallest component of an integer vector, along with the index of that component.

## Syntax

[k, ii] = f16dp(n, x, incx)
[k, ii] = nag_blast_imin_val(n, x, incx)

## Description

nag_blast_imin_val (f16dp) computes the smallest component, $i$, of an $n$-element integer vector $x$, and determines the smallest index, $k$, such that
 $i=xk=minjxj.$

## 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)$int64int32nag_int 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 ${\mathbf{n}}=0$, x is not referenced.
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{k}$int64int32nag_int scalar
$k$, the index, from the set $\left\{1,2,\dots ,{\mathbf{n}}\right\}$, of the smallest component of $x$. If ${\mathbf{n}}\le 0$ on input then k is returned as $0$.
2:     $\mathrm{ii}$int64int32nag_int scalar
$i$, the smallest component of $x$. If ${\mathbf{n}}\le 0$ on input then ii is returned as $0$.

## 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 smallest component and index of that component for the vector
 $x= 1,10,11,-2,9T .$
```function f16dp_example

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

% Minimum of vector of integers and its location
n    = int64(5);
x    = [int64(1)   10   11   -2    9];
incx = int64(1);

[xloc, xmin] = f16dp(n, x, incx);

fprintf('min(');
fprintf('%4d',x);
fprintf(') = x(%4d) = %5d\n', xloc, xmin);

```
```f16dp example results

min(   1  10  11  -2   9) = x(   4) =    -2
```