Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
VecDist.c
Go to the documentation of this file.
1 /************************************************************************/
2 /**
3 
4  \file VecDist.c
5 
6  \version V1.3
7  \date 07.07.14
8  \brief
9 
10  \copyright (c) UCL / Dr. Andrew C. R. Martin 1996-2014
11  \author Dr. Andrew C. R. Martin
12  \par
13  Institute of Structural & Molecular Biology,
14  University College London,
15  Gower Street,
16  London.
17  WC1E 6BT.
18  \par
19  andrew@bioinf.org.uk
20  andrew.martin@ucl.ac.uk
21 
22 **************************************************************************
23 
24  This code is NOT IN THE PUBLIC DOMAIN, but it may be copied
25  according to the conditions laid out in the accompanying file
26  COPYING.DOC.
27 
28  The code may be modified as required, but any modifications must be
29  documented so that the person responsible can be identified.
30 
31  The code may not be sold commercially or included as part of a
32  commercial product except as described in the file COPYING.DOC.
33 
34 **************************************************************************
35 
36  Description:
37  ============
38 
39 
40 **************************************************************************
41 
42  Usage:
43  ======
44 
45 **************************************************************************
46 
47  Revision History:
48  =================
49 - V1.0 29.01.96 Original By: ACRM
50 - V1.1 18.06.96 Added vector routines
51 - V1.2 06.10.98 Added VecAdd3()
52 - V1.3 07.07.14 Use bl prefix for functions By: CTP
53 
54 *************************************************************************/
55 /* Doxygen
56  -------
57  #GROUP Maths
58  #SUBGROUP Vectors
59  #FUNCTION blVecDist()
60  Finds the distance between two vectors of arbitrary length
61 */
62 /************************************************************************/
63 /* Includes
64 */
65 #include <math.h>
66 #include "MathType.h"
67 
68 /************************************************************************/
69 /* Defines and macros
70 */
71 
72 /************************************************************************/
73 /* Globals
74 */
75 
76 /************************************************************************/
77 /* Prototypes
78 */
79 
80 
81 /************************************************************************/
82 /*>REAL blVecDist(REAL *a, REAL *b, int len)
83  -----------------------------------------
84 *//**
85 
86  \param[in] *a An arbitrary length vector (as an array)
87  \param[in] *b An arbitrary length vector (as an array)
88  \param[in] len The dimensionality of the vectors (array
89  length)
90  \return The distance between the points described by
91  the two vectors
92 
93  Finds the distance between two vectors of arbitrary length
94 
95 - 28.07.95 Original By: ACRM
96 - 07.07.14 Use bl prefix for functions By: CTP
97 */
98 REAL blVecDist(REAL *a, REAL *b, int len)
99 {
100  REAL sumsq = 0.0;
101  int i;
102 
103  for(i=0; i<len; i++)
104  sumsq += (a[i] - b[i]) * (a[i] - b[i]);
105 
106  return((REAL)sqrt((double)sumsq));
107 }
108 
109 
REAL blVecDist(REAL *a, REAL *b, int len)
Definition: VecDist.c:98
double REAL
Definition: MathType.h:67
Type definitions for maths.