コード例 #1
0
float OpenNaturalCubicSpline::inverse( float x, float tGuess, float epsilon, int maxIterations )
{
	float result = tGuess;
	float xResult = evaluateAt( result );
	float error = x - xResult;
	float absError = fabs( error );

	int n = 0;
	while( ( absError > epsilon ) && ( n < maxIterations ) )
	{
		float dxdt = derivativeAt( result );
		result += error / dxdt;
		xResult = evaluateAt( result );
		error = x - xResult;
		absError = fabs( error );

		++n;
	}

#if _DEBUG
	if( n == maxIterations )
	{
		printf( "max iterations reached! " );
	}
	printf( "error = %f\n", absError );
#endif

	return result;
}
コード例 #2
0
Complex HighPrecisionComplexPolynom::evaluateAt(Complex z) {
  cln::cl_N precZ = complex(cl_float(z.x,clnDIGIT), cl_float(z.y,clnDIGIT));
  cln::cl_N precRes = evaluateAt(precZ);
  Complex res(double_approx(realpart(precRes)), double_approx(imagpart(precRes)));

  return res;
}
コード例 #3
0
ファイル: uniformgridfield.C プロジェクト: Micket/oofem
int
UniformGridField :: evaluateAt(FloatArray &answer, DofManager *dman, ValueModeType mode, TimeStep *tStep)
{
    if ( dman->hasCoordinates()) {
        int result=evaluateAt(answer,*(dman->giveCoordinates()),mode,tStep);
        return ( result == 1 );
    }
    // failed -> dman without coordinates
    return 1; 
}
コード例 #4
0
ファイル: Spline2f.cpp プロジェクト: jiawen/libcgt
void Spline2f::updateCache()
{
    int nPointsToEvaluate = numPointsToEvaluate();

    m_cache.resize( nPointsToEvaluate );
    float delta = 1.f / ( nPointsToEvaluate - 1 );

    for( int i = 0; i < nPointsToEvaluate; ++i )
    {
        // compute t between 0 and 1
        float t = i * delta;
        Vector2f splinePoint = evaluateAt( t );
        m_cache[ i ] = splinePoint;
    }

    m_bCacheIsDirty = false;
}