From ea0af731616517ced2b8f3c2e0e37bd8daa4e3eb Mon Sep 17 00:00:00 2001 From: Jan Huwald Date: Wed, 27 Feb 2013 13:53:28 +0100 Subject: Initial commit diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..010c76d --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +CXX=g++ -std=c++0x -O3 -Wall -Wextra -Werror + +all: cacount + +clean: + -rm cacount *~ \ No newline at end of file diff --git a/cacount.cpp b/cacount.cpp new file mode 100644 index 0000000..7c052d3 --- /dev/null +++ b/cacount.cpp @@ -0,0 +1,81 @@ +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +typedef uint32_t State; +const State logState = 16; +const State maxState = 1 << logState; + +bitset<8> rule(110); + +State update(State s) { + State r(0); + bitset b(s); + for (unsigned i=0; i Trans; + +void iterTrans(int times, function f) { + while (times--) + for (State s=0; s(s) << endl; +} + +void printTraj(State s, int count) { + while (count--) { + cout << bitset(s) << endl; + s = update(s); + } +} + +int main(int argc, char **argv) { + assert(argc >= 2); + rule = atoi(argv[1]); + if (!strcmp(argv[2], "traj")) { + assert(argc == 5); + printTraj(atoi(argv[3]), atoi(argv[4])); + } + if (!strcmp(argv[2], "cycle")) { + Trans &t = *(new Trans); + init(t); + Trans &c(*findCycle(t)); + print(c); + } + return 0; +} -- cgit v0.10.1