From 639552a2649139ba14363f30daa20786532b21b0 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Mon, 23 Jul 2018 13:51:13 -0400 Subject: implemented the discrete gaussian model for roughening --- lib/height.h | 75 +++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 24 deletions(-) (limited to 'lib/height.h') diff --git a/lib/height.h b/lib/height.h index 16c4dc5..81d3a2d 100644 --- a/lib/height.h +++ b/lib/height.h @@ -2,61 +2,88 @@ #pragma once #include +#include #include "types.h" -// object definition +/* The following is the minimum definition of a spin class. + * + * The class must contain an M_t and an F_t for holding the sum of an + * integer number of spins and a double-weighted number of spins, + * respectively. + * + * void init(X_t *p); + * void free_spin(X_t p); + * void free_spin(M_t p); + * void free_spin(F_t p); + * X_t copy(X_t x); + * void add(M_t *x1, int factor, X_t x2); + * void add(F_t *x1, double factor, X_t x2); + * M_t scalar_multiple(int factor, X_t x); + * F_t scalar_multiple(double factor, X_t x); + * double norm_squared(F_t x); + * void write_magnetization(M_t M, FILE *outfile); + * + */ + template -struct height_t { T x; }; +struct height_t { + T x; + + typedef T M_t; + typedef double F_t; +}; -// init, copy, add, subtract, scalar_multiple, free_spin, and -// write_magnetization are necessary for the operation of wolff.h template -void init(height_t *ptr) { +void init(height_t *ptr) { ptr->x = (T)0; } template -height_t copy (height_t h) { - return h; +void free_spin(height_t h) { + // do nothing! } template -void add (height_t *h1, height_t h2) { - h1->x += h2.x; +void free_spin(T h) { + // do nothing! } -template -void subtract (height_t *h1, height_T h2) { - h1->x -= h2.x; +void free_spin(double h) { + // do nothing! } template -height_t scalar_multiple(v_t a, height_t h) { - height_t hm; - hm.x = a * h.x; +height_t copy(height_t h) { + return h; +} - return hm; +template +void add(T *h1, int a, height_t h2) { + (*h1) += a * h2.x; } template -void free_spin (height_t h) { +void add(double *h1, double a, height_t h2) { + (*h1) += a * h2.x; } template -void write_magnetization(height_t M, FILE *outfile) { - fwrite(&(M.x), sizeof(T), 1, outfile); +T scalar_multiple(int factor, height_t h) { + return factor * h.x; } template -double correlation_component(height_t h) { - return (double)h.x; +double scalar_multiple(double factor, height_t h) { + return factor * h.x; } -// below here are not necessary for operation +double norm_squared(double h) { + return pow(h, 2); +} template -T dot(height_t h1, height_t h2) { - return (h1.x - h2.x) * (h1.x - h2.x); +void write_magnetization(T M, FILE *outfile) { + fwrite(&M, sizeof(T), 1, outfile); } -- cgit v1.2.3-70-g09d2