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
/*
22
* StorageKey
23
* Node with a word member. Comparisons are allowed and are according
24
* to lexicographic order of the words.
25
*
26
* Written by: Bryant Lee
27
* Date: 11/4/04
28
*/
29
30
#include "StorageKey.h"
31
#include "StringOps.h"
32
33
//no argument constructor
34
StorageKey::StorageKey() {
35
word = NULL;
36
wordLength = 0;
37
}
38
39
//primary constructor
40
StorageKey::StorageKey(byte *inWord, unsigned int inWordLength) {
41
unsigned int i = 0;
42
43
wordLength = inWordLength;
44
word = new byte[wordLength];
45
46
//copy
47
for(i = 0; i < wordLength; i++) {
48
word[i] = inWord[i];
49
}
50
}
51
52
//copy constructor
53
StorageKey::StorageKey(const StorageKey &m) {
54
word = NULL;
55
wordLength = 0;
56
57
operator=(m);
58
}
59
60
//destructor
61
StorageKey::~StorageKey() {
62
delete[] word;
63
}
64
65
//operator =
66
const StorageKey & StorageKey::operator=(const StorageKey &right) {
67
unsigned int i = 0;
68
69
delete[] word; //delete the old word
70
71
wordLength = right.wordLength;
72
word = new byte[wordLength];
73
74
//copy
75
for(i = 0; i < wordLength; i++) {
76
word[i] = right.word[i];
77
}
78
79
return (*this);
80
}
81
82
//compare
83
//if > m, return positive
84
//if < m, return negative
85
//if == m, return 0
86
int StorageKey::compareTo(const StorageKey &m) const{
87
unsigned int i = 0;
88
int ret = 0;
89
90
for(i = 0; i < wordLength; i++) {
91
if(word[i] != m.word[i]) {
92
ret = word[i] - m.word[i];
93
break;
94
}
95
}
96
97
return ret;
98
}
99
100
//relational operators
101
bool StorageKey::operator==(const StorageKey &right) const {
102
return (compareTo(right) == 0);
103
}
104
105
bool StorageKey::operator!=(const StorageKey &right) const {
106
return (compareTo(right) != 0);
107
}
108
109
bool StorageKey::operator<(const StorageKey &right) const {
110
return (compareTo(right) < 0);
111
}
112
113
bool StorageKey::operator>(const StorageKey &right) const {
114
return (compareTo(right) > 0);
115
}
116
117
bool StorageKey::operator<=(const StorageKey &right) const {
118
return (compareTo(right) <= 0);
119
}
120
121
bool StorageKey::operator>=(const StorageKey &right) const {
122
return (compareTo(right) >= 0);
123
}
124
125
//print
126
void StorageKey::print() const {
127
printArray(word, wordLength);
128
//cout << "Pointer: " << (unsigned int) word << "\n";
129
}
130
131
132
133
134
135
136
137