Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

A (one dimensional) cellular automaton is a function1 F : Σ → Σ with the property that there is a K > 0 such that F (x)i depends only on the 2K + 1 coordinates xi−K , xi−K+1, . . . , xi−1, xi, xi+1, . . . , xi+K . A periodic point of σ is any x such that σ^p (x) = x for some p ∈ N, and a periodic point of F is any x such that F^q (x) = x for some q ∈ N. Given a cellular automaton F, a point x ∈ Σ is jointly periodic if there are p, q ∈ N such that σ^p (x) = F^q (x) = x, that is, it is a periodic point under both functions.

This project aims to explore the nature of one-dimensional Cellular Automata, in the hope of finding the structure of cellular automata through its periodic points.

2034 views
License: MIT
ubuntu2004
1
/*
2
* Copyright (C) 2004 Bryant Lee
3
*
4
* This file is part of FPeriod.
5
*
6
* FPeriod is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
*
11
* FPeriod is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with FPeriod; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
*/
20
21
/* FuncNode
22
* Node used to represent a single piece of a function (term, operator,
23
* or constant)
24
*
25
* Written by: Bryant Lee
26
* Date: 10/29/04
27
*/
28
29
#include "FuncNode.h"
30
31
#include <iostream>
32
#include <fstream> //for printing
33
34
extern int UINTSIZE;
35
36
//No argument constructor
37
FuncNode::FuncNode() {
38
type = 0;
39
val = 0;
40
}
41
42
//primary constructor
43
FuncNode::FuncNode(int iType, int iVal) {
44
type = iType;
45
val = iVal;
46
}
47
48
//copy constructor
49
FuncNode::FuncNode(const FuncNode &m) {
50
type = m.type;
51
val = m.val;
52
}
53
54
//copy assignment
55
const FuncNode& FuncNode::operator=(const FuncNode &right) {
56
type = right.type;
57
val = right.val;
58
59
return *this;
60
}
61
62
//deepCopy
63
FuncNode* FuncNode::deepCopy() {
64
return new FuncNode(*this);
65
}
66
67
//If holding a constant, returns the constant
68
//If holding a term, returns the term value based on
69
// the array x
70
int FuncNode::termValue(byte *x, int wLength, int i) {
71
int ret = -1, index = 0;
72
73
if(type == 1) { //term
74
index = (i + val) % wLength;
75
76
if(index < 0) {
77
index += wLength; //adjust for c's negative residuals
78
}
79
80
ret = x[index];
81
} else if(type == 3) { //constant
82
ret = val;
83
}
84
85
return ret;
86
}
87
88
//If holding a constant, returns the constant
89
//If holding a term, returns the term value based on
90
// the array x
91
int FuncNode::termValue(unsigned int *x, int wLength, int i) {
92
int ret = -1, index = 0;
93
94
if(type == 1) { //term
95
index = (i + val) % wLength;
96
97
if(index < 0) {
98
index += wLength; //adjust for c's negative residuals
99
}
100
101
if(index < UINTSIZE) { //if index < UINTSIZE, avoid divide ops
102
ret = (x[0] & (1 << index)) >> index;
103
}
104
else {
105
ret = (x[index/UINTSIZE] & (1 << (index % UINTSIZE)))
106
>> (index % UINTSIZE);
107
}
108
} else if(type == 3) { //constant
109
ret = val;
110
}
111
112
return ret;
113
}
114
115
//like above except used by inputs, rather than by actual word
116
int FuncNode::termValue_by_inputs(byte *itTerms, int numTerms,
117
const map<int,int> &optFindTerm) {
118
int ret = -1;
119
120
if(type == 1) { //term
121
ret = itTerms[optFindTerm.find(val)->second];
122
} else if(type == 3) { //constant
123
ret = val;
124
}
125
126
return ret;
127
}
128
129
130
//print
131
void FuncNode::print(ofstream & fout) {
132
if(type == 1) {
133
fout << "x[" << val << "]";
134
}else if (type == 2){
135
if(val == 1) {
136
fout << "+";
137
} else if(val == 2) {
138
fout << "-";
139
} else if(val == 3) {
140
fout << "*";
141
} else if(val == 4) {
142
fout << "^";
143
}
144
} else if(type == 3) {
145
fout << val;
146
}
147
}
148
149
//relational ops
150
bool FuncNode::operator==(const FuncNode &right) const{
151
return (this == &right);
152
}
153
154
bool FuncNode::operator!=(const FuncNode &right) const{
155
return !(operator==(right));
156
}
157
158
bool FuncNode::operator<(const FuncNode &right) const{
159
return (this < &right);
160
}
161
162
bool FuncNode::operator>(const FuncNode &right) const{
163
return (this > &right);
164
}
165
166
bool FuncNode::operator<=(const FuncNode &right) const{
167
return (operator<(right) || operator==(right));
168
}
169
170
bool FuncNode::operator>=(const FuncNode &right) const{
171
return (operator>(right) || operator==(right));
172
}
173
174
175
176
177
178
179