Use references rather than pointers.
This commit is contained in:
@@ -209,8 +209,7 @@ void AdjustSync::AutosyncTempo()
|
||||
{
|
||||
float fSlope = 0.0f;
|
||||
float fIntercept = 0.0f;
|
||||
if( !CalcLeastSquares( s_vAutosyncTempoData,
|
||||
&fSlope, &fIntercept, &s_fAverageError ) )
|
||||
if( !CalcLeastSquares( s_vAutosyncTempoData, fSlope, fIntercept, s_fAverageError ) )
|
||||
{
|
||||
s_vAutosyncTempoData.clear();
|
||||
return;
|
||||
@@ -230,8 +229,7 @@ void AdjustSync::AutosyncTempo()
|
||||
fSlope, fIntercept, ERROR_TOO_HIGH );
|
||||
s_iStepsFiltered -= s_vAutosyncTempoData.size();
|
||||
|
||||
if( !CalcLeastSquares( s_vAutosyncTempoData,
|
||||
&fSlope, &fIntercept, &fFilteredError ) )
|
||||
if( !CalcLeastSquares( s_vAutosyncTempoData, fSlope, fIntercept, fFilteredError ) )
|
||||
return;
|
||||
|
||||
GAMESTATE->m_pCurSong->m_Timing.m_fBeat0OffsetInSeconds += fIntercept;
|
||||
|
||||
@@ -1000,10 +1000,8 @@ float calc_stddev( const float *pStart, const float *pEnd, bool bSample )
|
||||
}
|
||||
|
||||
bool CalcLeastSquares( const vector< pair<float, float> > &vCoordinates,
|
||||
float *pfSlope, float *pfIntercept, float *pfError )
|
||||
float &pfSlope, float &pfIntercept, float &pfError )
|
||||
{
|
||||
ASSERT( pfSlope != NULL );
|
||||
ASSERT( pfIntercept != NULL );
|
||||
int iNumSamples = vCoordinates.size();
|
||||
float fNumSamples = static_cast<float>(iNumSamples);
|
||||
if( iNumSamples == 0 )
|
||||
@@ -1019,17 +1017,17 @@ bool CalcLeastSquares( const vector< pair<float, float> > &vCoordinates,
|
||||
fSumY += vCoordinates[i].second;
|
||||
}
|
||||
float fDenominator = fNumSamples * fSumXX - fSumX * fSumX;
|
||||
*pfSlope = (fNumSamples * fSumXY - fSumX * fSumY) / fDenominator;
|
||||
*pfIntercept = (fSumXX * fSumY - fSumX * fSumXY) / fDenominator;
|
||||
pfSlope = (fNumSamples * fSumXY - fSumX * fSumY) / fDenominator;
|
||||
pfIntercept = (fSumXX * fSumY - fSumX * fSumXY) / fDenominator;
|
||||
|
||||
*pfError = 0.0f;
|
||||
pfError = 0.0f;
|
||||
for( int i = 0; i < iNumSamples; ++i )
|
||||
{
|
||||
float fOneError = (vCoordinates[i].second - (*pfIntercept + *pfSlope * vCoordinates[i].first));
|
||||
*pfError += fOneError * fOneError;
|
||||
float fOneError = (vCoordinates[i].second - (pfIntercept + pfSlope * vCoordinates[i].first));
|
||||
pfError += fOneError * fOneError;
|
||||
}
|
||||
*pfError /= fNumSamples;
|
||||
*pfError = sqrtf( *pfError );
|
||||
pfError /= fNumSamples;
|
||||
pfError = sqrtf( pfError );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -450,7 +450,7 @@ float calc_stddev( const float *pStart, const float *pEnd, bool bSample = false
|
||||
* Returns true on success, false on failure.
|
||||
*/
|
||||
bool CalcLeastSquares( const vector< pair<float, float> > &vCoordinates,
|
||||
float *p_fSlope, float *p_fIntercept, float *p_fError );
|
||||
float &p_fSlope, float &p_fIntercept, float &p_fError );
|
||||
|
||||
/*
|
||||
* This method throws away any points that are more than fCutoff away from
|
||||
|
||||
Reference in New Issue
Block a user