-
Notifications
You must be signed in to change notification settings - Fork 0
Programs to generate all S^T words and convert to transition counts
License
dchaws/GenWordsTrans
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Copyright (C) 2011 David C. Haws www.davidhaws.org This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. See LICENSE The program genwords takes in two arguments on the command line, S and T. It will generate all S^T words. E.g. ./genwords 3 2 1 1 1 2 1 3 2 1 2 2 2 3 3 1 3 2 3 3 The command line option -L will not allow self-loops (11). ./genwords 3 2 -L 1 2 1 3 2 1 2 3 3 1 3 2 The program words2trans will read in from standard input words, one per line, and output the transition counts. For example, the path 1212311 has (11) once, (12) twice, (21) once, (23) once and (31) once. It will print out a vector of length S^2, with the transitions in lexicographic order. E.g ./genwords 3 2 -L | ./words2trans 3 2 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 The option -L will not count the self loops. E.g. 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 The option -I will count the initial states. E.g. 1 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 Option -S produces words with no spaces between the states ./genwords 3 3 -S -L 121 123 131 132 212 213 231 232 312 313 321 323 The program gentrans is a much more efficient way to simply output all transitions of all words. It takes as input on the command line the number of states S and the length of the word. If T = 1, then it will print all the transitions. E.g. ./gentrans 3 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 genwords also respect the no selfLoops flag. ./gentrans 3 1 -L 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 When T!=1, then "gentrans S T" will read in from the standard input the transitions of all words S^(T-1), and output the new transitions. I.e. ./gentrans 3 1 | ./gentrans 3 2 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 or without selfloops: ./gentrans 3 1 -L | ./gentrans 3 2 -L 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 This programs works on the simple following recursion. When it reads a line which contains the initial state and the transition, it simulates prepending the word with all possible states, increasing the transitions from new state to the previous initial state. I.e. the transition (with self loops) 1 0 0 1 0 0 0 0 0 0 0 0 says the word started at 1 and had a transition 1 -> 2. When gentrans reads this line it will output the three lines 1 0 0 2 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 The shell script genmatrices will generate all the design matrices with no self loops and S=3 up to a user specified T. ./genmatrices 10 would generate the first 10 design matrices. ./genmatrices 10 -Z would generate the first 10 design matrices, but gzip the intermediate and final results. Very important for saving space. ./genmatrices 10 -Z -U would generate the first 10 design matrices, but gzip the intermediate and final results. Also, after the current run of paths of length T, it will take the previous result and strip the initial conditions, sort, uniq and zip the data. Now genmtatrices will do "sort -u" for each transition with initial counts. This dramatically improves the speed since the recursive method to compute the transitions from T-1 to T only depends on the transitoins! Hence, we only need the unique transitions. Added comp_in.sh which takes the gz files output from genmatrices and computes Normaliz input files. Added transpose.sh which transposes a text file. Added comp_4ti2.sh which takes the gz files output from genmatrices and computes 4ti2 input files. E.g. ./genmatrices.sh 20 -Z -U ./comp_4ti2.sh 20
About
Programs to generate all S^T words and convert to transition counts
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published