summaryrefslogtreecommitdiff
path: root/src/wolff_potts.cpp
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-26 16:55:17 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-26 16:55:17 -0400
commit5f1eb9a12821e7462b7b2853e0d95c8c863bf900 (patch)
tree6aa091a95846923e253a83886c5da2a8a62d5e93 /src/wolff_potts.cpp
parent1160baa61bad605cf8a1d583e8ae356a54a942df (diff)
downloadc++-5f1eb9a12821e7462b7b2853e0d95c8c863bf900.tar.gz
c++-5f1eb9a12821e7462b7b2853e0d95c8c863bf900.tar.bz2
c++-5f1eb9a12821e7462b7b2853e0d95c8c863bf900.zip
now using const passing of object reference instead of pointers
Diffstat (limited to 'src/wolff_potts.cpp')
-rw-r--r--src/wolff_potts.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/wolff_potts.cpp b/src/wolff_potts.cpp
index 2bc306b..9fe3ffe 100644
--- a/src/wolff_potts.cpp
+++ b/src/wolff_potts.cpp
@@ -135,12 +135,12 @@ int main(int argc, char *argv[]) {
FILE **outfiles = measure_setup_files(measurement_flags, timestamp);
- std::function <void(const sim_t *)> other_f;
+ std::function <void(const sim_t&)> other_f;
uint64_t sum_of_clusterSize = 0;
if (N_is_sweeps) {
- other_f = [&] (const sim_t *s) {
- sum_of_clusterSize += s->last_cluster_size;
+ other_f = [&] (const sim_t& s) {
+ sum_of_clusterSize += s.last_cluster_size;
};
} else if (draw) {
#ifdef HAVE_GLUT
@@ -154,21 +154,21 @@ int main(int argc, char *argv[]) {
glLoadIdentity();
gluOrtho2D(0.0, L, 0.0, L);
- other_f = [] (const sim_t *s) {
+ other_f = [] (const sim_t& s) {
glClear(GL_COLOR_BUFFER_BIT);
- for (v_t i = 0; i < pow(s->L, 2); i++) {
- potts_t<POTTSQ> tmp_s = s->R.act_inverse(s->spins[i]);
+ for (v_t i = 0; i < pow(s.L, 2); i++) {
+ potts_t<POTTSQ> tmp_s = s.R.act_inverse(s.spins[i]);
glColor3f(hue_to_R(tmp_s.x * 2 * M_PI / POTTSQ), hue_to_G(tmp_s.x * 2 * M_PI / POTTSQ), hue_to_B(tmp_s.x * 2 * M_PI / POTTSQ));
- glRecti(i / s->L, i % s->L, (i / s->L) + 1, (i % s->L) + 1);
+ glRecti(i / s.L, i % s.L, (i / s.L) + 1, (i % s.L) + 1);
}
glFlush();
};
#endif
} else {
- other_f = [] (const sim_t *s) {};
+ other_f = [] (const sim_t& s) {};
}
- std::function <void(const sim_t *)> measurements = measure_function_write_files(measurement_flags, outfiles, other_f);
+ std::function <void(const sim_t&)> measurements = measure_function_write_files(measurement_flags, outfiles, other_f);
// add line to metadata file with run info
{
@@ -194,12 +194,12 @@ int main(int argc, char *argv[]) {
printf("\n");
while (sum_of_clusterSize < N * s.nv) {
printf("\033[F\033[J\033[F\033[JWOLFF: sweep %" PRIu64 " / %" PRIu64 ": E = %.2f, S = %" PRIv "\n", (count_t)((double)sum_of_clusterSize / (double)s.nv), N, s.E, s.last_cluster_size);
- wolff(N, &s, gen_R, measurements, r, silent);
+ wolff(N, s, gen_R, measurements, r, silent);
N_rounds++;
}
printf("\033[F\033[J\033[F\033[JWOLFF: sweep %" PRIu64 " / %" PRIu64 ": E = %.2f, S = %" PRIv "\n\n", (count_t)((double)sum_of_clusterSize / (double)s.nv), N, s.E, s.last_cluster_size);
} else {
- wolff(N, &s, gen_R, measurements, r, silent);
+ wolff(N, s, gen_R, measurements, r, silent);
}
// free the random number generator