本文整理汇总了C++中Lattice::area方法的典型用法代码示例。如果您正苦于以下问题:C++ Lattice::area方法的具体用法?C++ Lattice::area怎么用?C++ Lattice::area使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lattice
的用法示例。
在下文中一共展示了Lattice::area方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update_EnergyHistogram
//Wang-Landau: update energy histogram
void update_EnergyHistogram(double** ptrHistogram, Lattice lattice, double H_tot)
{
int L, j;
L = lattice.area();
j = ( H_tot + L * 2 ) * 0.25; // bias by +L*2 (to get only positive indices) and then *0.25 is divide by 4
*ptrHistogram[j] += 1;
}
示例2: get_maxlikelyhood_coordinates
int get_maxlikelyhood_coordinates(float* Matrix, std::vector<double>& coordinates, std::vector<double>& likelyhoods, Lattice lattice)
{
int D;
if (lattice.get_dimensions() == 2)
{
D = lattice.area();
}
else
{
D = lattice.volume();
}
std::vector<double>::iterator max_likelyhood = std::max_element(likelyhoods.begin(),likelyhoods.end());
int distance = std::distance(likelyhoods.begin(), max_likelyhood);
int S = distance * D;
std::vector<double>::const_iterator it;
int i = 0;
for (it = (coordinates.begin() + S); it != (coordinates.begin() + S + D); ++it)
{
Matrix[i] = *it;
++i;
}
return distance;
}
示例3: get_alternativelikelyhood_coordinates
int get_alternativelikelyhood_coordinates(float* Matrix, std::vector<double>& coordinates, std::vector<double>& likelyhoods, Lattice lattice, int distance, double& H_tot, int K_iteration)
{
int D;
if (lattice.get_dimensions() == 2)
{
D = lattice.area();
}
else
{
D = lattice.volume();
}
if (K_iteration == distance)
{
++K_iteration;
}
H_tot = likelyhoods.at(K_iteration);
int S = K_iteration * D;
std::vector<double>::const_iterator it;
int i = 0;
for (it = (coordinates.begin() + S); it != (coordinates.begin() + S + D); ++it)
{
Matrix[i] = *it;
++i;
}
return K_iteration;
}
开发者ID:smcantab,项目名称:mcising,代码行数:33,代码来源:mcising_NestedSampling_get_alternativelikelyhood_coordinates.cpp
示例4: reset_EnergyHistogram
//Wang-Landau: reset energy histogram
void reset_EnergyHistogram(double* Histogram, Lattice lattice)
{
int L,j;
L = lattice.area();
for (j=0; j < L - 1; j++)
{
Histogram[j] = 0;
}
}
示例5: HistogramMap
//Wang-Landau : density of states map between array and pointer array
void HistogramMap(double* Histogram, double** ptrHistogram, Lattice lattice)
{
int L = lattice.area();
for (int i = 2; i <= L-2; i++ )
{
ptrHistogram[i] = &Histogram[i-1];
}
ptrHistogram[0] = &Histogram[0];
ptrHistogram[L] = &Histogram[L-2];
}
示例6: main
int main(int argc, char ** argv)
{
std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now();
////////////////////////////////////OpenOutput/////////////////////////
std::ofstream output;
///////////////////////////////////////////////////////////////////////
/////////////////////////////SetConstants/////////////////////////////
Lattice lattice;
lattice.set_dimensions(10, 10);
double const J = 1;
double const h = 0.;
double label_coeff = FLT_MIN;
//std::cout<<"Label Coefficient: "<<std::setprecision(16)<<label_coeff<<std::endl;
int K = 100;
int const mcycle = 500000; //100000 cycles
double Z;
///////////////////////////////////////////////////////////////////////
float* M = allocateMatrix_2D(lattice);
float** ptrM = allocateptrMatrix_2D(lattice);
matrixmap_2D(M, ptrM, lattice);
std::vector<double> coordinates, likelyhoods, postlikelyhoods, list_X;
list_X.reserve(K);
RandomLib::Random r = initialise_random_number();
/////////////////////////Algorithm//////////////////////////////////
ising_NestedSampling_Algorithm_2D(ptrM, M, coordinates, likelyhoods, postlikelyhoods, lattice, r, J, h, label_coeff, K, mcycle);
std::vector<double>::const_iterator itp;
for (itp = postlikelyhoods.begin(); itp != postlikelyhoods.end(); itp++)
{
std::cout<< *itp << " ";
}
std::cout<<""<<std::endl;
//create list_X
double X = 1;
double const Kd = (double) K;
for(itp = postlikelyhoods.begin(); itp != postlikelyhoods.end(); ++itp)
{
X = X * exp(-2/Kd);//(Kd-1)/Kd; //Kd/(Kd+1);
list_X.insert(list_X.end(), X);
}
list_X.insert(list_X.begin(), 1);
list_X.insert(list_X.end(), 0);
/*
double L = 0;
int i = 0;
for(itp = postlikelyhoods.begin(); itp != postlikelyhoods.end(); ++itp) { L += 0.5*( list_X.at(i) - list_X.at(i+2)); ++i; }
std::cout<<"L: "<<L<<std::endl;
*/
//end list_X
int S = postlikelyhoods.size();
double renorm = 2/list_X.at(S);
output.open("../output/NestedSampling/NS_test_16.dat");
output<<"# 2D Nested-Sampling by Stefano Martiniani"<<std::endl;
output<<"# kT \t A"<<std::endl;
double A = 0;
double b, c;
for (c = 0.01; c <= 10; c += 0.01)
{
//Free energy
integrate(postlikelyhoods, list_X, lattice, Z, c, renorm);
A = -(1/c) * log(Z)/lattice.area();
b = 1/c;
output<<b<<"\t"<<A<<std::endl;
}
output.close();
output.open("../output/NestedSampling/NS_U_16.dat");
output<<"# 2D Nested-Sampling by Stefano Martiniani"<<std::endl;
output<<"# kT \t U"<<std::endl;
//internal energy
double U = 0;
double E, F, arg, w;
int i = 0;
/*
double G = 0;
for(itp = postlikelyhoods.begin(); itp != postlikelyhoods.end(); ++itp)
{
G += 0.5*( list_X.at(i) - list_X.at(i+2));
++i;
}
//.........这里部分代码省略.........