NAG FL Interfacef06faf (dvcos)

▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

1Purpose

f06faf computes the cosine of the angle between two real vectors.

2Specification

Fortran Interface
 Function f06faf ( n, j, tolx, x, incx, toly, y, incy)
 Real (Kind=nag_wp) :: f06faf Integer, Intent (In) :: n, j, incx, incy Real (Kind=nag_wp), Intent (In) :: tolx, x(*), toly, y(*)
C Header Interface
#include <nag.h>
 double f06faf_ (const Integer *n, const Integer *j, const double *tolx, const double x[], const Integer *incx, const double *toly, const double y[], const Integer *incy)
The routine may be called by the names f06faf or nagf_blas_dvcos.

3Description

f06faf returns, via the function name, the cosine of the angle between two $n$-element real vectors $x$ and $y$, given by the expression
 $xTy ‖x‖2‖y‖2 .$
If $1\le j\le n$, $y$ is taken to be the unit vector ${e}_{j}$, in which case the array y is not referenced.
If ${‖x‖}_{2}\le \mathit{tolx}$, the routine returns $2.0$; if ${‖x‖}_{2}>\mathit{tolx}$ but ${‖y‖}_{2}\le \mathit{tol}y$, the routine returns $-2.0$; otherwise the value returned is in the range $\left(-1.0,1.0\right)$.

None.

5Arguments

1: $\mathbf{n}$Integer Input
On entry: $n$, the number of elements in $x$ and $y$.
2: $\mathbf{j}$Integer Input
On entry: if the vector $y$ is supplied in y, j should be set to $0$. Otherwise, j specifies the index $j$ of the unit vector ${e}_{j}$ to be used as $y$.
3: $\mathbf{tolx}$Real (Kind=nag_wp) Input
On entry: the value $\mathit{tolx}$, used to determine whether ${‖x‖}_{2}$ is effectively zero.
If tolx is negative, the value zero is used.
4: $\mathbf{x}\left(*\right)$Real (Kind=nag_wp) array Input
Note: the dimension of the array x must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,1+\left({\mathbf{n}}-1\right)×|{\mathbf{incx}}|\right)$.
On entry: the $n$-element vector $x$.
If ${\mathbf{incx}}>0$, ${x}_{\mathit{i}}$ must be stored in ${\mathbf{x}}\left(1+\left(\mathit{i}-1\right)×{\mathbf{incx}}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
If ${\mathbf{incx}}<0$, ${x}_{\mathit{i}}$ must be stored in ${\mathbf{x}}\left(1-\left({\mathbf{n}}-\mathit{i}\right)×{\mathbf{incx}}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
Intermediate elements of x are not referenced.
5: $\mathbf{incx}$Integer Input
On entry: the increment in the subscripts of x between successive elements of $x$.
6: $\mathbf{toly}$Real (Kind=nag_wp) Input
On entry: the value $\mathit{toly}$, used to determine whether ${‖y‖}_{2}$ is effectively zero.
If toly is negative, the value zero is used.
7: $\mathbf{y}\left(*\right)$Real (Kind=nag_wp) array Input
Note: the dimension of the array y must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,1+\left({\mathbf{n}}-1\right)×|{\mathbf{incy}}|\right)$.
On entry: if $1\le {\mathbf{j}}\le {\mathbf{n}}$, y is not referenced. Otherwise, y holds the vector $y$.
If ${\mathbf{incy}}>0$, ${y}_{\mathit{i}}$ must be stored in ${\mathbf{y}}\left(1+\left(\mathit{i}-1\right)×{\mathbf{incy}}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
If ${\mathbf{incy}}<0$, ${y}_{\mathit{i}}$ must be stored in ${\mathbf{y}}\left(1-\left({\mathbf{n}}-\mathit{i}\right)×{\mathbf{incy}}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
Intermediate elements of y are not referenced.
8: $\mathbf{incy}$Integer Input
On entry: the increment in the subscripts of y between successive elements of $y$.

None.

Not applicable.

8Parallelism and Performance

f06faf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

None.

None.