93 std::size_t counter1 = 0, counter2 = 0, counter3 = 0;
94 for( std::size_t i = 3; i <= x.size(); i++ ) {
95 if( (i-1) % 3 == 0 ) {
97 value[0] +=
sqr(x(i-1)-2*x( 1 )*::sin( 2 * M_PI * x( 0 ) + i*M_PI/x.size() ) );
98 }
else if( (i-2) % 3 == 0 ) {
100 value[1] +=
sqr(x(i-1)-2*x( 1 )*::sin( 2 * M_PI * x( 0 ) + i*M_PI/x.size() ) );
101 }
else if( i % 3 == 0 ) {
103 value[2] +=
sqr(x(i-1)-2*x( 1 )*::sin( 2 * M_PI * x( 0 ) + i*M_PI/x.size() ) );
107 value[0] *= counter1 > 0 ? 2./counter1 : 1;
108 value[1] *= counter2 > 0 ? 2./counter2 : 1;
109 value[2] *= counter3 > 0 ? 2./counter3 : 1;
111 value[0] += ::cos( 0.5*M_PI * x( 0 ) ) * ::cos( 0.5*M_PI * x( 1 ) );
112 value[1] += ::cos( 0.5*M_PI * x( 0 ) ) * ::sin( 0.5*M_PI * x( 1 ) );
113 value[2] += ::sin( 0.5*M_PI * x( 0 ) );