UltraScan III
List of all members | Classes | Static Public Member Functions | Static Private Member Functions
US_Math2 Class Reference

A collecion of methematical routines. All functions are static. More...

#include "us_math2.h"

Classes

class  Peptide
 A structure used for calculating a peptide sequence. More...
 
class  SolutionData
 A structure used for holding solution data. More...
 

Static Public Member Functions

static double box_muller (double, double)
 Normal random variate generator. More...
 
static double ranf (void)
 Return a random floating point number. More...
 
static double linefit (double **, double **, double *, double *, double *, double *, int)
 Given a line as a set of x and y coordinates, calculate the line's characteristics. More...
 
static int nearest_curve_point (double *, double *, const int, bool, double &, double &, double *, double *, double *, double *)
 Given a set of curve points and a given outside point, return the curve point nearest the given point. Return either a point in the curve array or one interpolated based on distance. Optionally also return a value in a third dimension that corresponds to the nearest point. More...
 
static bool intersect (double &, double &, double &, double &, double *, double *)
 Given the slopes and intercepts of two lines, return the intersection point of the two lines, if it exists. More...
 
static bool intersect (double *, double *, int, double *, double *, int, double *, double *)
 Given arrays representing two curves, return the intersection point of two lines fitted to them, if it exists. More...
 
static void calc_vbar (Peptide &, const QString &, double)
 A routine to calculate the vbar and MW of a peptide sequence. More...
 
static double adjust_vbar20 (double vbar, double degC)
 
static double adjust_vbar (double vbar, double degC)
 The inverse of adjust_vbar20. Returns vbar20. More...
 
static void data_correction (double, SolutionData &)
 Correct buffer data for temperature. More...
 
static double normal_distribution (double, double, double)
 A routine to calculate the value of a normally distributed value. More...
 
static double time_correction (const QVector< US_DataIO::EditedData > &)
 Calculate the time correction in a run due to acceleration of the rotor. More...
 
static uint randomize (void)
 Set the sysem random sequence. More...
 
static uint randomize (uint)
 Set the sysem random sequence. More...
 
static int nnls (double *a, int a_dim1, int m, int n, double *b, double *x, double *rnorm=NULL, double *wp=NULL, double *zzp=NULL, int *indexp=NULL)
 
static void gaussian_smoothing (QVector< double > &, int)
 Remove high frequency noise from a signal. More...
 
static double calcCommonVbar (US_Solution &, double)
 Calculate common vbar of a solution. More...
 
static double erfc (double)
 An approximation of the Complimentary Gauss Error Fiunction, erfc(). Use for WIN32 only as Linux already has it implemented in <math.h> More...
 
static int best_grid_reps (int &, int &)
 Compute best uniform grid repetitions for 2DSA and possibly modify grid point counts in each dimension. More...
 

Static Private Member Functions

static void _nnls_g1 (double a, double b, double *, double *, double *)
 
static int _nnls_h12 (int, int, int, int m, double *, int, double *, double *, int, int, int)
 

Detailed Description

A collecion of methematical routines. All functions are static.

Definition at line 25 of file us_math2.h.

Member Function Documentation

void US_Math2::_nnls_g1 ( double  a,
double  b,
double *  cterm,
double *  sterm,
double *  sig 
)
staticprivate

Definition at line 1058 of file us_math2.cpp.

int US_Math2::_nnls_h12 ( int  mode,
int  lpivot,
int  l1,
int  m,
double *  u,
int  u_dim1,
double *  up,
double *  cm,
int  ice,
int  icv,
int  ncv 
)
staticprivate

Definition at line 1102 of file us_math2.cpp.

static double US_Math2::adjust_vbar ( double  vbar,
double  degC 
)
inlinestatic

The inverse of adjust_vbar20. Returns vbar20.

Parameters
vbarThe vbar value at the specified temperature
degCThe temperature of the sample associated with vbar

Definition at line 177 of file us_math2.h.

static double US_Math2::adjust_vbar20 ( double  vbar,
double  degC 
)
inlinestatic

Adjust the vbar for temperature. The values used in the unadjusted calculations are based on 20 degrees C. We use an observed linear adjustment of 0.000425 per degreee.

Parameters
vbarThe unadjusted vbar value
degCThe temperature used for the adjustment

Definition at line 170 of file us_math2.h.

int US_Math2::best_grid_reps ( int &  ngrid_s,
int &  ngrid_k 
)
static

Compute best uniform grid repetitions for 2DSA and possibly modify grid point counts in each dimension.

Parameters
ngrid_sReference to grid points in the s dimension, both input and possibly modified value
ngrid_kReference to grid points in the k dimension, both input and possibly modified value
Returns
Computed best number of grid repetitions

Definition at line 1364 of file us_math2.cpp.

double US_Math2::box_muller ( double  m,
double  s 
)
static

Normal random variate generator.

Parameters
m- mean
s- standard deviation

Definition at line 22 of file us_math2.cpp.

void US_Math2::calc_vbar ( Peptide pep,
const QString &  sequence,
double  temperature 
)
static

A routine to calculate the vbar and MW of a peptide sequence.

Parameters
pepThe structure to be populated
sequenceThe secuence used for the calculations
temperatureThe temperature to use for calculations

Definition at line 311 of file us_math2.cpp.

double US_Math2::calcCommonVbar ( US_Solution solution,
double  temperature 
)
static

Calculate common vbar of a solution.

Parameters
solutionSolution for which to calculate common vbar
temperatureAverage temperature of associated experiment
Returns
The common temperature-corrected vbar

Definition at line 1336 of file us_math2.cpp.

void US_Math2::data_correction ( double  t,
SolutionData d 
)
static

Correct buffer data for temperature.

Parameters
tTemperature of solution
dData to be corrected

The density of water. An empirical equation derived from density vs temperature data. See Krell, J. Chem. & Eng. Data 1975, 20.

\[ \rho_t = \xi_{max}{{c_0 + c_1 * t + c_2 * t^2 + c_3 * t^3 + c_4 * t^4 + c_5 * t^5} \over{ 1 + bt }} \]

where:
$ \xi_{max} = 1.000028 \times 10^{-3} $
$ c_0 = 999.83952 $
$ c_1 = 16.945176 $
$ c_2 = -7.9870401 \times 10^{-3} $
$ c_3 = -46.170461 \times 10^{-6} $
$ c_4 = 105.56302 \times 10^{-9} $
$ c_5 = -280.54253 \times 10^{-12}$
$ b = 16.879850 \times 10^{-3}$

Viscosity of water.
Implements an empirical equation taken from CRC Handbook of Chemistry and Physics, 55th Edition.

For temperature 0 to 20 degress C:

\[ \log_{10} \eta_t ={ c_0 \over{ c_1 + c_2 ( t-20 ) + c_3 ( t - 20 )^2 }} - c_4 \]

where:
$ \eta $ = viscosity in centipoise ( gm / sec-cm / 100 )
$ t $ = temperature ( Celcius )
$ c_0 = 1301$
$ c_1 = 998.333$
$ c_2 = 8.1855$
$ c_3 = 0.00585$
$ c_4 = 3.30233$

For temperature 20 to 100 degrees C:

\[ \log_{10}{\eta_t\over\eta_{20}} = { {c_1(20 - t) -c_2(t-20)^2}\over {t+c_3}} \]

where:
$ \eta $ = viscosity in centipoise ( gm / sec-cm / 100 )
$ t $ = temperature ( Celcius )
$ c_1 = 1.3272$
$ c_2 = 1.053 \times 10^{-3}$
$ c_3 = 105$

Definition at line 487 of file us_math2.cpp.

double US_Math2::erfc ( double  x)
static

An approximation of the Complimentary Gauss Error Fiunction, erfc(). Use for WIN32 only as Linux already has it implemented in <math.h>

Parameters
xThe input value
Returns
Approximation of erfc(x)

Definition at line 688 of file us_math2.cpp.

void US_Math2::gaussian_smoothing ( QVector< double > &  array,
int  smooth 
)
static

Remove high frequency noise from a signal.

Parameters
arrayData to be smoothed. This array will be modified.
smoothNumber of values to smooth to be considered when smoothing

Definition at line 1215 of file us_math2.cpp.

bool US_Math2::intersect ( double &  slope1,
double &  intcp1,
double &  slope2,
double &  intcp2,
double *  xisec,
double *  yisec 
)
static

Given the slopes and intercepts of two lines, return the intersection point of the two lines, if it exists.

Parameters
slope1The slope of the first line
intcp1The intercept of the first line
slope2The slope of the second line
intcp2The intercept of the second line
xisecPointer for return of x of the intersection point
yisecPointer for return of y of the intersection point
Returns
Boolean flag if intersection exists (false->parallel)

Definition at line 272 of file us_math2.cpp.

bool US_Math2::intersect ( double *  x1s,
double *  y1s,
int  npoint1,
double *  x2s,
double *  y2s,
int  npoint2,
double *  xisec,
double *  yisec 
)
static

Given arrays representing two curves, return the intersection point of two lines fitted to them, if it exists.

Parameters
x1sAn array of x values of the first curve
y1sAn array of y values of the first curve
npoint1The number of points for the first curve
x2sAn array of x values of the second curve
y2sAn array of y values of the second curve
npoint2The number of points for the second curve
xisecPointer for return of x of the intersection point
yisecPointer for return of y of the intersection point
Returns
Boolean flag if intersection exists (false=>parallel)

Definition at line 289 of file us_math2.cpp.

double US_Math2::linefit ( double **  x,
double **  y,
double *  slope,
double *  intercept,
double *  sigma,
double *  correlation,
int  arraysize 
)
static

Given a line as a set of x and y coordinates, calculate the line's characteristics.

Parameters
xPointer to an array of x values
yPointer to an array of y values
slopePointer to location to return the line's slope
interceptPointer to location to return the line's y intercept
sigmaPointer to location to return the standard deviation
correlationPointer to location to return the correlation
arraysizeInput array size

Definition at line 63 of file us_math2.cpp.

int US_Math2::nearest_curve_point ( double *  xs,
double *  ys,
const int  npoints,
bool  interp,
double &  xgiven,
double &  ygiven,
double *  xnear,
double *  ynear,
double *  zs,
double *  znear 
)
static

Given a set of curve points and a given outside point, return the curve point nearest the given point. Return either a point in the curve array or one interpolated based on distance. Optionally also return a value in a third dimension that corresponds to the nearest point.

Parameters
xsAn array of x values of the curve
ysAn array of y values of the curve
npointsThe number of curve points
interpFlag to interpolate curve point (false->exact point)
xgivenThe x value of the given point
ygivenThe y value of the given point
xnearPointer for return of x of the nearest curve point
ynearPointer for return of y of the nearest curve point
zsOptional third dimension values array (if non-NULL)
znearOptional pointer for return of z for nearest point
Returns
Index in arrays of nearest curve point

Definition at line 151 of file us_math2.cpp.

int US_Math2::nnls ( double *  a,
int  a_dim1,
int  m,
int  n,
double *  b,
double *  x,
double *  rnorm = NULL,
double *  wp = NULL,
double *  zzp = NULL,
int *  indexp = NULL 
)
static
Algorithm NNLS (Non-negative least-squares)

Given an m by n matrix A, and an m-vector B, computes an n-vector X, that solves the least squares problem A * X = B , subject to X>=0 The A matrix is formatted such that the columns are placed into a vector end-to-end, and the parameter a_dim1 contains the length of each column

Function returns 0 if succesful, 1, if iteration count exceeded 3*N, or 2 in case of invalid problem dimensions or memory allocation error.

Instead of pointers for working space, NULL can be given to let this function to allocate and free the required memory.

Parameters
aThe m by n matrix A. On exit, a[] contains the product matrix Q*A, where Q is an m by n orthogonal matrix generated implicitly by this function. The matrix is column major.
a_dim1Since matrix A is processed as a set of vectors, a_dim1 is needed to specify the storage increment between vectors in a[]
mColumns
nRows
bOn entry, b[] must contain the m-vector B. On exit, b[] contains Q*B
xOn exit, x[] will contain the solution vector.
rnormOn exit, rnorm contains the Euclidean norm of the residual vector. It may be set to NULL if the returned value is not needed.
wpAn n-array of working space, w[]. On exit, w[] will contain the dual solution vector. w[i]=0.0 for all i in set p and w[ i ] <= 0.0 for all i in set z.
zzpAn m-array of working space, zz[].
indexpAn n-array of working space, index[].

Definition at line 720 of file us_math2.cpp.

double US_Math2::normal_distribution ( double  sigma,
double  mean,
double  x 
)
static

A routine to calculate the value of a normally distributed value.

Parameters
sigmaStandard deviation of the distribution
meanMean value of the distribution
xPoint where to compute desired value

Definition at line 621 of file us_math2.cpp.

uint US_Math2::randomize ( void  )
static

Set the sysem random sequence.

Returns
The seed used to set the system time

Definition at line 661 of file us_math2.cpp.

uint US_Math2::randomize ( uint  seed)
static

Set the sysem random sequence.

Parameters
seedA predetermined seed
Returns
The seed used to set the system time

Definition at line 678 of file us_math2.cpp.

double US_Math2::ranf ( void  )
static

Return a random floating point number.

Definition at line 57 of file us_math2.cpp.

double US_Math2::time_correction ( const QVector< US_DataIO::EditedData > &  dataList)
static

Calculate the time correction in a run due to acceleration of the rotor.

Parameters
dataListThe list of editedData for the run

Definition at line 627 of file us_math2.cpp.


The documentation for this class was generated from the following files: