コード例 #1
0
ファイル: CyclicCurves3.cpp プロジェクト: Ezakhiel/BezierGP
    GLboolean CyclicCurve3::CalculateDerivatives(
            GLuint max_order_of_derivatives, GLdouble u, Derivatives& d )const
    {
        d.ResizeRows(max_order_of_derivatives + 1);
	d.LoadNullVectors();

        DCoordinate3 centroid;

        for(GLuint i = 0; i <= 2 * _n; ++i)
	{
            centroid += _data[i];
	}
        centroid /= (GLdouble)(2 * _n + 1);

	for(GLuint r = 0; r <= max_order_of_derivatives; ++r)
	{
            for(GLuint i = 0; i <= 2 * _n; ++i)
            {
                GLdouble sum_k=0.0;

                for(GLuint k = 0; k <= _n - 1; ++k)
                {
                    sum_k += pow(_n - k, (GLint)r) * _bc(2 * _n, k)* cos((_n - k) * (u - i *_lambda_n) + r * PI/2.0);
                }
                d[r] += sum_k * _data[i];
            }

            d[r] *= 2.0;
            d[r] /= (GLdouble)(2 * _n + 1);
            d[r] /= _bc(2 * _n,_n);

            if(r==0)
            {
                d[r] += centroid;
            }
	}

        return GL_TRUE;
    }
コード例 #2
0
ファイル: _cIsing.c プロジェクト: mal2/Project-Simulation
int _getLocalEnergy(int* config, int x, int y, int m) {
    return config[x*m+y]*(config[_bc(x+1,m)*m+y]+config[_bc(x-1,m)*m+y]+config[x*m+_bc(y+1,m)]+config[x*m+_bc(y-1,m)]);
}