Пример #1
0
void Polygon::CosSumIntegral( f32 x, f32 y, f32 c, int n, std::vector<f32> &R ) const
{
	const f32 sinx = std::sin( x );
	const f32 siny = std::sin( y );
	const f32 cosx = std::cos( x );
	const f32 cosy = std::cos( y );
	const f32 cosxsq = cosx * cosx;
	const f32 cosysq = cosy * cosy;

	static const vec2f i1( 1, 1 );
	static const vec2f i2( 2, 2 );
	vec2i i( 0, 1 );
	vec2f F( y - x, siny - sinx );
	vec2f S( 0.f, 0.f );

	vec2f pow_c( 1.f, c );
	vec2f pow_cosx( cosx, cosxsq );
	vec2f pow_cosy( cosy, cosysq );

	while ( i[1] <= n )
	{
		S += pow_c * F;

		R[i[1] + 0] = S[0];
		R[i[1] + 1] = S[1];

		vec2f T = pow_cosy * siny - pow_cosx * sinx;
		F = ( T + ( i + i1 ) * F ) / ( i + i2 );

		i += i2;
		pow_c *= c*c;
		pow_cosx *= cosxsq;
		pow_cosy *= cosysq;
	}
}
Пример #2
0
float gamma(float x) {\n\
float num = x+1;\n\
float result0_ = 0;\n\
float result1_ = 0;\n\
float a_ = 0;\n\
float b_ = num*25;\n\
float n_ = 250;\n\
float dx_ = (b_ - a_)/n_;\n\
float h = a_;\n\
result0_ += pow_c(h, (num-1))*exp(-h);\n\
h = b_;\n\
result0_ += pow_c(h, (num-1))*exp(-h);\n\
for(float k_ = 1; k_ < n_; k_++) {\n\
h = a_+(k_*dx_);\n\
result1_ += 2*pow_c(h, (num-1))*exp(-h);\n\
}\n\
return (dx_/2)*(result0_ + result1_)/x;\n\
\n}\n";