Пример #1
0
> static inline void rotate_pair(first_type &first, second_type &second, int n)
{
	if (second_order > first_order)
		return rotate_pair<
			second_type, first_type, second_order,
			first_order, radix
		>(second, first, n);

	constexpr first_type f_max(pow<first_type, int>(
		first_type(radix), first_order
	));
	constexpr second_type s_max(pow<second_type, int>(
		second_type(radix), second_order
	));

	n = n % (first_order + second_order);
	if (n < 0)
		n = first_order + second_order + n;

	if (n <= second_order) {
		first_type p(std::pow<first_type, int>(
			first_type(radix), n
		));

		first_type f1((first % (f_max / p)) * p);
		first_type f2(second / (s_max / p));
		second_type s1((second % (s_max / p)) * p);
		second_type s2(first / (f_max / p));
		first = f1 + f2;
		second = s1 + s2;
	} else if (n > first_order) {
		first_type p(std::pow<first_type, int>(
			first_type(radix), first_order + second_order - n
		));

		first_type f1(first / p);
		first_type f2((second % p) * (f_max / p));
		second_type s1(second / p);
		second_type s2((first % p) * (s_max / p));
		first = f1 + f2;
		second = s1 + s2;
	} else {
		first_type p(std::pow<first_type, int>(
			first_type(radix), n
		));

		first_type f1(first / (f_max / (p / s_max)));
		first_type f2(second * (p / s_max));
		first_type f3((first % (f_max / p)) * p);
		second = (first / (f_max / p)) % s_max;
		first = f1 + f2 + f3;
	}
}
Пример #2
0
 diploid_t() : first(first_type()),second(second_type()),i(std::numeric_limits<unsigned>::max()) {}