Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
Macros | Functions
MathUtil.h File Reference

Prototypes, etc. for maths utility routines. More...

#include <math.h>
#include "MathType.h"
#include "SysDefs.h"
#include "deprecated.h"

Go to the source code of this file.

Macros

#define _MATHUTIL_H_DEPRECATED
 

Functions

void blCalcSD (REAL val, int action, REAL *mean, REAL *SD)
 
void blCalcExtSD (REAL val, int action, REAL *Sx, REAL *SxSq, int *NValues, REAL *mean, REAL *SD)
 
REAL blPearson (REAL *x, REAL *y, int NItem)
 
REAL blPearson1 (REAL *x, REAL *y, int NItem)
 
void blCrossProd3 (VEC3F *Out, VEC3F In1, VEC3F In2)
 
void blVecSub3 (VEC3F *Out, VEC3F In1, VEC3F In2)
 
void blVecAdd3 (VEC3F *Out, VEC3F In1, VEC3F In2)
 
REAL blVecLen3 (VEC3F Vec)
 
REAL blDistPtLine (VEC3F Point, VEC3F End1, VEC3F End2)
 
REAL blPointLineDistance (REAL Px, REAL Py, REAL Pz, REAL P1x, REAL P1y, REAL P1z, REAL P2x, REAL P2y, REAL P2z, REAL *Rx, REAL *Ry, REAL *Rz, REAL *frac)
 
ULONG blFactorial (int n)
 
ULONG blFactdiv (int n1, int n2)
 
ULONG blNPerm (int n, int r)
 
ULONG blNComb (int n, int r)
 
BOOL blIsPrime (ULONG input)
 
ULONG blFindNextPrime (ULONG input, BOOL above)
 

Detailed Description

Prototypes, etc. for maths utility routines.

Version
V1.8
Date
20.07.15
Author
Dr. Andrew C. R. Martin
Institute of Structural & Molecular Biology, University College London, Gower Street, London. WC1E 6BT.
andre.nosp@m.w@bi.nosp@m.oinf..nosp@m.org..nosp@m.uk andre.nosp@m.w.ma.nosp@m.rtin@.nosp@m.ucl..nosp@m.ac.uk

This code is NOT IN THE PUBLIC DOMAIN, but it may be copied according to the conditions laid out in the accompanying file COPYING.DOC.

The code may be modified as required, but any modifications must be documented so that the person responsible can be identified.

The code may not be sold commercially or included as part of a commercial product except as described in the file COPYING.DOC.

Description:

Usage:

Revision History:

Definition in file MathUtil.h.

Macro Definition Documentation

#define _MATHUTIL_H_DEPRECATED

Definition at line 96 of file MathUtil.h.

Function Documentation

void blCalcExtSD ( REAL  val,
int  action,
REAL Sx,
REAL SxSq,
int *  NValues,
REAL mean,
REAL SD 
)
Parameters
[in]valThe value to be sampled
[in]action0: Sample the value 1: Calculate & return mean and SD 2: Clear the sample lists
[out]meanThe returned mean
[out]SDThe returned standard deviation
[in,out]SxSum of values
[in,out]SxSqSum of values squared
[in,out]NValuesNumber of values

Calculate the mean and standard deviation from a set of numbers. The routine is called with each value to be sampled and the action required is specified:

The output values are only set when action==1

This is the same as blCalcSD() except that the Sx, SxSq and NValues variables are kept outside the function instead of being static within the function

  • 13.10.93 Original based on CalcSD By: ACRM
  • 22.06.94 Fixed for only one value supplied
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 137 of file CalcExtSD.c.

void blCalcSD ( REAL  val,
int  action,
REAL mean,
REAL SD 
)
Parameters
[in]valThe value to be sampled
[in]action0: Sample the value 1: Calculate & return mean and SD 2: Clear the sample lists
[out]meanThe returned mean
[out]SDThe returned standard deviation

Calculate the mean and standard deviation from a set of numbers. The routine is called with each value to be sampled and the action required is specified.

The output values are only set when action=1

  • 30.03.90 Original By: ACRM
  • 17.06.93 Modified for book
  • 22.06.94 Fixed for 0 values supplied
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 124 of file CalcSD.c.

void blCrossProd3 ( VEC3F Out,
VEC3F  In1,
VEC3F  In2 
)
Parameters
[in]In1First vector
[in]In2Second vector
[out]OutOutput vector

Calculate the cross product of 2 3-vectors

  • 18.06.96 Original By: ACRM
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 94 of file CrossProd3.c.

REAL blDistPtLine ( VEC3F  Point,
VEC3F  End1,
VEC3F  End2 
)
Parameters
[in]PointThe coordinates of a point
[in]End1Coordinates of one end of vector
[in]End2Coordinates of other end of vector
Returns
The distance from pt to line

Calculate the distance from a point to a line described by two vector end points

  • 18.06.96 Original By: ACRM
  • 07.07.14 Use bl prefix for functions By: CTP
  • 20.07.15 Renamed from blDistPtVect() By: ACRM

Definition at line 100 of file DistPtLine.c.

ULONG blFactdiv ( int  n1,
int  n2 
)

Calculates the factorial of one number divided by the factorial of another (smaller) number. Returns 0 on numeric overflow or if n2 > n1

  • 09.09.96 Original By: ACRM
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 91 of file factdiv.c.

ULONG blFactorial ( int  n)

Calculates the factorial of an integer. Returns 0 on numeric overflow.

  • 09.09.96 Original By: ACRM
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 89 of file factorial.c.

ULONG blFindNextPrime ( ULONG  primeNum,
BOOL  above 
)
Parameters
[in]primeNumInput number (prime or not)
[in]aboveAlways return a number above the input
Returns
The next prime

Returns a prime above (or equal to if 'above' is FALSE) the input number

  • 15.05.15 Original By: ACRM

Definition at line 97 of file prime.c.

BOOL blIsPrime ( ULONG  input)
Parameters
[in]inputNumber to test
Returns
Is this number a prime?

Tests whether the input number is a prime

  • 15.05.15 Original By: ACRM

Definition at line 142 of file prime.c.

ULONG blNComb ( int  n,
int  r 
)

Calculates number of combinations of n items in r groups Returns 0 if a numeric overflow occurs.

  • 09.09.96 Original By: ACRM
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 91 of file NComb.c.

ULONG blNPerm ( int  n,
int  r 
)

Calculates number of permutations of n items in r groups Returns 0 if a numeric overflow occurs.

  • 09.09.96 Original By: ACRM
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 90 of file NPerm.c.

REAL blPearson ( REAL x,
REAL y,
int  NItem 
)
Parameters
[in]*xArray of x items
[in]*yArray of y items
[in]NItemNumber of items
Returns
Pearson correlation coefficient

Calculates the Pearson correlation coefficient This version makes 2 passes through the data

  • 15.07.94 Original By: ACRM
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 99 of file pearson.c.

REAL blPearson1 ( REAL x,
REAL y,
int  NItem 
)
Parameters
[in]*xArray of x items
[in]*yArray of y items
[in]NItemNumber of items
Returns
Pearson correlation coefficient

This version makes a single pass through the data

  • 15.07.94 Original By: ACRM
  • 18.01.96 Alternative version which does a single pass through the data. Method from page 191 of Statistical Methods in Biology 2 ed. Norman TJ Bailey. Publ. Unibooks 1981 By: RM
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 98 of file pearson1.c.

REAL blPointLineDistance ( REAL  Px,
REAL  Py,
REAL  Pz,
REAL  P1x,
REAL  P1y,
REAL  P1z,
REAL  P2x,
REAL  P2y,
REAL  P2z,
REAL Rx,
REAL Ry,
REAL Rz,
REAL frac 
)
Parameters
[in]PxPoint x coordinate
[in]PyPoint y coordinate
[in]PzPoint z coordinate
[in]P1xLine start x coordinate
[in]P1yLine start y coordinate
[in]P1zLine start z coordinate
[in]P2xLine end x coordinate
[in]P2yLine end y coordinate
[in]P2zLine end z coordinate
[out]*RxNearest point on line x coordinate
[out]*RyNearest point on line y coordinate
[out]*RzNearest point on line z coordinate
[out]*fracFraction along P1-P2 of R
Returns
Distance from P to R

Calculates the shortest distance from a point P to a line between points P1 and P2. This value is returned.

If the Rx,Ry,Rz pointers are all non-NULL, then the point on the line nearest to P is output.

If the frac pointer is non-NULL then the fraction of R along the P1-P2 vector is output. Thus: R==P1 ==> frac=0 R==P2 ==> frac=1 Thus if (0<=frac<=1) then the point R is within the line segment P1-P2

  • 16.11.99 Original By: ACRM
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 126 of file pldist.c.

void blVecAdd3 ( VEC3F Out,
VEC3F  In1,
VEC3F  In2 
)
Parameters
[in]In1First vector
[in]In2Second vector
[out]OutOutput vector

Add 2 vectors

  • 06.10.98 Original By: ACRM
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 95 of file VecAdd3.c.

REAL blVecLen3 ( VEC3F  Vec)
Parameters
[in]VecVector
Returns
Length of vector

Calculate the length of a vector

  • 18.06.96 Original By: ACRM
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 94 of file VecLen3.c.

void blVecSub3 ( VEC3F Out,
VEC3F  In1,
VEC3F  In2 
)
Parameters
[in]In1First vector
[in]In2Second vector
[out]OutOutput vector

Subtract 2 vectors

  • 18.06.96 Original By: ACRM
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 94 of file VecSub3.c.