QTrk
Static Public Member Functions | List of all members
ComputeMaxInterp< T, numPts > Class Template Reference

#include <LsqQuadraticFit.h>

Static Public Member Functions

static CUDA_SUPPORTED_FUNCmax_ (T a, T b)
 
static CUDA_SUPPORTED_FUNCmin_ (T a, T b)
 
static CUDA_SUPPORTED_FUNCCompute (T *data, int len, const T *weights, LsqSqQuadFit< T > *fit=0)
 

Detailed Description

template<typename T, int numPts = 3>
class ComputeMaxInterp< T, numPts >

Definition at line 141 of file LsqQuadraticFit.h.

Member Function Documentation

§ Compute()

template<typename T , int numPts = 3>
static CUDA_SUPPORTED_FUNC T ComputeMaxInterp< T, numPts >::Compute ( T *  data,
int  len,
const T *  weights,
LsqSqQuadFit< T > *  fit = 0 
)
inlinestatic

Definition at line 146 of file LsqQuadraticFit.h.

147  {
148  int iMax=0;
149  T vMax=data[0];
150  for (int k=1;k<len;k++) {
151  if (data[k]>vMax) {
152  vMax = data[k];
153  iMax = k;
154  }
155  }
156  T xs[numPts];
157  int startPos = max_(iMax-numPts/2, 0);
158  int endPos = min_(iMax+(numPts-numPts/2), len);
159  int numpoints = endPos - startPos;
160 
161  if (numpoints<3)
162  return iMax;
163  else {
164  for(int i=startPos;i<endPos;i++)
165  xs[i-startPos] = i-iMax;
166 
167  LsqSqQuadFit<T> qfit(numpoints, xs, &data[startPos], weights);
168  if (fit) *fit = qfit;
169  //printf("iMax: %d. qfit: data[%d]=%f\n", iMax, startPos, data[startPos]);
170  //for (int k=0;k<numpoints;k++) {
171  // printf("data[%d]=%f\n", startPos+k, data[startPos]);
172  //}
173 
174  if (fabs(qfit.a)<1e-9f)
175  return (T)iMax;
176  else {
177  T interpMax = qfit.maxPos();
178  return (T)iMax + interpMax;
179  }
180  }
181  }
CUDA_SUPPORTED_FUNC T maxPos()
static CUDA_SUPPORTED_FUNC T max_(T a, T b)
static CUDA_SUPPORTED_FUNC T min_(T a, T b)

§ max_()

template<typename T , int numPts = 3>
static CUDA_SUPPORTED_FUNC T ComputeMaxInterp< T, numPts >::max_ ( a,
b 
)
inlinestatic

Definition at line 143 of file LsqQuadraticFit.h.

143 { return a>b ? a : b; }

§ min_()

template<typename T , int numPts = 3>
static CUDA_SUPPORTED_FUNC T ComputeMaxInterp< T, numPts >::min_ ( a,
b 
)
inlinestatic

Definition at line 144 of file LsqQuadraticFit.h.

144 { return a<b ? a : b; }

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