QTrk
Classes | Public Member Functions | Public Attributes | Private Member Functions | List of all members
LsqSqQuadFit< T > Class Template Reference

#include <LsqQuadraticFit.h>

Classes

struct  Coeff
 

Public Member Functions

CUDA_SUPPORTED_FUNC LsqSqQuadFit (uint numPts, const T *xval, const T *yval, const T *weights=0)
 
CUDA_SUPPORTED_FUNC LsqSqQuadFit ()
 
CUDA_SUPPORTED_FUNC void calculate (uint numPts, const T *X, const T *Y, const T *weights)
 
CUDA_SUPPORTED_FUNCcompute (T pos)
 
CUDA_SUPPORTED_FUNCcomputeDeriv (T pos)
 
CUDA_SUPPORTED_FUNCmaxPos ()
 
CUDA_SUPPORTED_FUNCvertexForm ()
 

Public Attributes

a
 
b
 
c
 
d
 
h
 
k
 
float xoffset
 

Private Member Functions

CUDA_SUPPORTED_FUNC Coeff computeSums (const T *X, const T *Y, const T *weights, uint numPts)
 

Detailed Description

template<typename T>
class LsqSqQuadFit< T >

Definition at line 9 of file LsqQuadraticFit.h.

Constructor & Destructor Documentation

§ LsqSqQuadFit() [1/2]

template<typename T>
CUDA_SUPPORTED_FUNC LsqSqQuadFit< T >::LsqSqQuadFit ( uint  numPts,
const T *  xval,
const T *  yval,
const T *  weights = 0 
)
inline

Definition at line 27 of file LsqQuadraticFit.h.

28  {
29  calculate(numPts, xval, yval, weights);
30  xoffset =0;
31  }
CUDA_SUPPORTED_FUNC void calculate(uint numPts, const T *X, const T *Y, const T *weights)

§ LsqSqQuadFit() [2/2]

template<typename T>
CUDA_SUPPORTED_FUNC LsqSqQuadFit< T >::LsqSqQuadFit ( )
inline

Definition at line 33 of file LsqQuadraticFit.h.

Member Function Documentation

§ calculate()

template<typename T>
CUDA_SUPPORTED_FUNC void LsqSqQuadFit< T >::calculate ( uint  numPts,
const T *  X,
const T *  Y,
const T *  weights 
)
inline

Definition at line 39 of file LsqQuadraticFit.h.

40  {
41  Coeff co = computeSums(X, Y, weights, numPts);
42  co.abc(a,b,c,d);
43  }
CUDA_SUPPORTED_FUNC Coeff computeSums(const T *X, const T *Y, const T *weights, uint numPts)

§ compute()

template<typename T>
CUDA_SUPPORTED_FUNC T LsqSqQuadFit< T >::compute ( pos)
inline

Definition at line 45 of file LsqQuadraticFit.h.

46  {
47  pos -= xoffset;
48  return a*pos*pos + b*pos + c;
49  }

§ computeDeriv()

template<typename T>
CUDA_SUPPORTED_FUNC T LsqSqQuadFit< T >::computeDeriv ( pos)
inline

Definition at line 51 of file LsqQuadraticFit.h.

52  {
53  pos -= xoffset;
54  return 2*a*pos + b;
55  }

§ computeSums()

template<typename T>
CUDA_SUPPORTED_FUNC Coeff LsqSqQuadFit< T >::computeSums ( const T *  X,
const T *  Y,
const T *  weights,
uint  numPts 
)
inlineprivate

Definition at line 72 of file LsqQuadraticFit.h.

73  {
74  //notation sjk to mean the sum of x_i^j*y_i^k.
75  /* s40 = getSx4(); //sum of x^4
76  s30 = getSx3(); //sum of x^3
77  s20 = getSx2(); //sum of x^2
78  s10 = getSx(); //sum of x
79 
80 
81  s21 = getSx2y(); //sum of x^2*y
82  s11 = getSxy(); //sum of x*y
83  s01 = getSy(); //sum of y
84  */
85 
86  if (weights) {
87  T Sx = 0, Sy = 0;
88  T Sx2 = 0, Sx3 = 0;
89  T Sxy = 0, Sx4=0, Sx2y=0;
90  T Sw = 0;
91  for (uint i=0;i<numPts;i++)
92  {
93  T x = X[i];
94  T y = Y[i];
95  Sx += x*weights[i];
96  Sy += y*weights[i];
97  T sq = x*x;
98  Sx2 += x*x*weights[i];
99  Sx3 += sq*x*weights[i];
100  Sx4 += sq*sq*weights[i];
101  Sxy += x*y*weights[i];
102  Sx2y += sq*y*weights[i];
103  Sw += weights[i];
104  }
105 
106  Coeff co;
107  co.s10 = Sx; co.s20 = Sx2; co.s30 = Sx3; co.s40 = Sx4;
108  co.s01 = Sy; co.s11 = Sxy; co.s21 = Sx2y;
109  co.s00 = Sw;
110  return co;
111  } else {
112  T Sx = 0, Sy = 0;
113  T Sx2 = 0, Sx3 = 0;
114  T Sxy = 0, Sx4=0, Sx2y=0;
115  for (uint i=0;i<numPts;i++)
116  {
117  T x = X[i];
118  T y = Y[i];
119  Sx += x;
120  Sy += y;
121  T sq = x*x;
122  Sx2 += x*x;
123  Sx3 += sq*x;
124  Sx4 += sq*sq;
125  Sxy += x*y;
126  Sx2y += sq*y;
127  }
128 
129  Coeff co;
130  co.s10 = Sx; co.s20 = Sx2; co.s30 = Sx3; co.s40 = Sx4;
131  co.s01 = Sy; co.s11 = Sxy; co.s21 = Sx2y;
132  co.s00 = numPts;
133  return co;
134  }
135  }
unsigned int uint
Definition: std_incl.h:127
float sq(float x)
Definition: utils.cpp:352

§ maxPos()

template<typename T>
CUDA_SUPPORTED_FUNC T LsqSqQuadFit< T >::maxPos ( )
inline

Definition at line 57 of file LsqQuadraticFit.h.

58  {
59  return -b/(2*a);
60  }

§ vertexForm()

template<typename T>
CUDA_SUPPORTED_FUNC T LsqSqQuadFit< T >::vertexForm ( )
inline

Definition at line 62 of file LsqQuadraticFit.h.

63  {
64  // Find equation in form a(x-h)^2+k
65  h = -b/(2*a);
66  k = c - a*h*h;
67  return k;
68  }

Member Data Documentation

§ a

template<typename T>
T LsqSqQuadFit< T >::a

Definition at line 12 of file LsqQuadraticFit.h.

§ b

template<typename T>
T LsqSqQuadFit< T >::b

Definition at line 12 of file LsqQuadraticFit.h.

§ c

template<typename T>
T LsqSqQuadFit< T >::c

Definition at line 12 of file LsqQuadraticFit.h.

§ d

template<typename T>
T LsqSqQuadFit< T >::d

Definition at line 12 of file LsqQuadraticFit.h.

§ h

template<typename T>
T LsqSqQuadFit< T >::h

Definition at line 12 of file LsqQuadraticFit.h.

§ k

template<typename T>
T LsqSqQuadFit< T >::k

Definition at line 12 of file LsqQuadraticFit.h.

§ xoffset

template<typename T>
float LsqSqQuadFit< T >::xoffset

Definition at line 13 of file LsqQuadraticFit.h.


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