From e2302deb9f435d0308d06780138eeff2659c81e4 Mon Sep 17 00:00:00 2001 From: Vincent Beffara Date: Wed, 11 May 2016 15:36:48 +0200 Subject: [PATCH] Move the domino shuffle into the 2D folder where it belongs --- tests/shuffle.cpp | 146 ---------------------------------------------- 1 file changed, 146 deletions(-) delete mode 100644 tests/shuffle.cpp diff --git a/tests/shuffle.cpp b/tests/shuffle.cpp deleted file mode 100644 index 3dd3b072..00000000 --- a/tests/shuffle.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// Initial code in Python by Sunil Chhita, ported to C++ by VB. - -#include -#include -#include - -using namespace vb; using namespace std; - -auto weights (int m, const Array & p) { - int n = m*lcm(p.ww,p.hh); - Array A (n,n); for (auto z : coos(A)) A[z] = p.atp(z); return A; -} - -auto dupe (const Array & a) { Array aa (2*a.ww,2*a.hh); for (auto z : coos(aa)) aa[z] = a[z/2]; return aa; } - -auto twoperiodic (int m, double a, double b) { return weights (m, dupe (Array ({{a,b},{b,a}}))); } -auto threeperiodic (int m, double a, double b, double c) { return weights (m, dupe (Array ({{a,b,c},{b,c,a},{c,a,b}}))); } - -auto threebytwo(int m, double b) { Array p (6,6,1); p[coo(0,0)]=b; p[coo(4,2)]=b; p[coo(2,4)]=b; return weights (m,p); } - -auto d3p (const Array & x1) { - int n = x1.ww; vector>> A (n/2); - - A[0].resize(n,n); for (auto z : coos(x1)) if (double w = x1[z]) A[0][z] = {w,0}; else A[0][z] = {1,1}; - - for (int k=0; k & x1) { - auto a0 = d3p (x1); int n = a0.size(); vector> A (n); - - for (int k=0; k a0[n-k-1][coo(2*i+1,2*j)].second + a0[n-k-1][coo(2*i,2*j+1)].second) - A[k][z] = 0; - else if (a0[n-k-1][coo(2*i,2*j)].second + a0[n-k-1][coo(2*i+1,2*j+1)].second < a0[n-k-1][coo(2*i+1,2*j)].second + a0[n-k-1][coo(2*i,2*j+1)].second) - A[k][z] = 1; - else - A[k][z] = (a0[n-k-1][coo(2*i+1,2*j+1)].first * a0[n-k-1][coo(2*i,2*j)].first / - (a0[n-k-1][coo(2*i+1,2*j+1)].first * a0[n-k-1][coo(2*i,2*j)].first + a0[n-k-1][coo(2*i+1,2*j)].first*a0[n-k-1][coo(2*i,2*j+1)].first)); - } - } - return A; -} - -auto delslide (const Array & x1) { - int n = x1.ww; Array a0 (n+2,n+2); - for (int i=0; i & x0, const Array & p) { - int n = x0.ww; - for (int i=0; i0) a1 = (x0[coo(2*i,2*j-1)]==0) && (x0[coo(2*i+1,2*j-1)]==0); else a1 = true; - if (j0) a3 = (x0[coo(2*i-1,2*j)]==0) && (x0[coo(2*i-1,2*j+1)]==0); else a3 = true; - if (i & xr) { - auto x0 = probs(xr); int n = x0.size(); Array a1; - if (prng.bernoulli(x0[0][coo(0,0)])) a1 = Array ({{1,0},{0,1}}); else a1 = Array ({{0,1},{1,0}}); - for (int i=0; i & A) { - int m = A.ww/2; Array h (m+1,m+1,0); int z=0; - for (int x=0; x TP; - if (H['w'] == "unif") TP = weights (m, Array (1,1,1)); else - if (H['w'] == "two") TP = twoperiodic (m,H['a'],H['b']); else - if (H['w'] == "three") TP = threeperiodic (m,H['a'],H['b'],H['c']); else - if (H['w'] == "kenyon") TP = threebytwo (m,H['b']); else { - cerr << "No such weight, \"" << string(H['w']) << "\".\n"; exit(1); - } - - auto A1 = aztecgen(TP); auto H1 = height(A1); - - string name = H.dir + H.title; ofstream asy (name + ".asy"); - for (auto z : coos(A1)) if (A1[z]) { - double eps = ((z.x+z.y)%2) ? .5 : -.5; - asy << "draw ((" << z.x-.5 << "," << z.y-eps << ")--(" << z.x+.5 << "," << z.y+eps << "), gray (" << TP[z]/1.3 << "));" << endl; - } - - ofstream dat (name + ".dat"); - for (auto z : coos(H1)) { dat << H1[z] << " "; if (z.x == H1.ww-1) dat << endl; } - - system (("asy -fpdf -o " + H.dir + " \"" + name + ".asy\"").c_str()); -}