本文整理汇总了C++中math::power4方法的典型用法代码示例。如果您正苦于以下问题:C++ math::power4方法的具体用法?C++ math::power4怎么用?C++ math::power4使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类math
的用法示例。
在下文中一共展示了math::power4方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void run(alps::ObservableSet& obs) {
++mcs;
// initialize cluster information
std::fill(fragments.begin(), fragments.end(), fragment_t());
// cluster generation
for (double t = r_time(); t < 1; t += r_time()) {
int s0 = lattice.num_sites() * uniform_01();
int s1 = lattice.num_sites() * uniform_01();
if (spins[s0] == spins[s1]) unify(fragments, s0, s1);
}
// assign cluster id & accumulate cluster properties
int nc = 0;
double mag2 = 0, mag4 = 0;
BOOST_FOREACH(fragment_t& f, fragments) {
if (f.is_root()) {
f.set_id(nc++);
double w = f.weight();
mag2 += power2(w);
mag4 += power4(w);
}
}
BOOST_FOREACH(fragment_t& f, fragments) f.set_id(cluster_id(fragments, f));
// flip spins
for (int c = 0; c < nc; ++c) flip[c] = (uniform_01() < 0.5);
for (int s = 0; s < lattice.num_sites(); ++s)
if (flip[fragments[s].id()]) spins[s] ^= 1;
double mu = 0;
for (int s = 0; s < lattice.num_sites(); ++s) mu += 2 * spins[s] - 1;
obs["Number of Clusters"] << (double)nc;
obs["Magnetization (unimproved)"] << mu;
obs["Magnetization^2 (unimproved)"] << power2(mu);
obs["Magnetization^4 (unimproved)"] << power4(mu);
obs["Magnetization^2"] << mag2;
obs["Magnetization^4"] << (3 * power2(mag2) - 2 * mag4);
}