#KMP Drawer with Graphviz
Given a pattern string, it generates the Graphviz dot script to draw the implicit automaton that uses the KMP string matching algorithm.
To compile:
g++ -std=c++0x -Wall kmpdraw.cpp -o kmpdraw
Example:
| SpecialPlane horPlane = new SpecialPlane(0,0.2, new PVector(253, 184, 19)); | |
| SpecialPlane parPlane = new SpecialPlane(1, 0.5, new PVector(246, 139, 31)); | |
| SpecialPlane obPlane = new SpecialPlane(0.5, 0.3, new PVector(241, 112, 34)); | |
| VPlane vertPlane = new VPlane(-0.4, new PVector(238, 246, 108)); | |
| boolean[] visible = {true, true, true, true, true}; // which parts of the cone are visible | |
| float rotY = 0, rotX = 0; | |
| PVector[][] ps = generatePoints(100); | |
| void setup() { |
| original_image = imread('butterfly.jpg'); | |
| [n m c] = size(original_image); | |
| assert(c == 3); | |
| angles = linspace(0, 20 * pi, 1000); | |
| for i=1:length(angles) | |
| radius = 200; | |
| c = 0.5 + sin(angles(i)) / 2; | |
| [x y] = meshgrid(1:m, 1:n); |
#KMP Drawer with Graphviz
Given a pattern string, it generates the Graphviz dot script to draw the implicit automaton that uses the KMP string matching algorithm.
To compile:
g++ -std=c++0x -Wall kmpdraw.cpp -o kmpdraw
Example:
| % Generate the points | |
| clf | |
| subplot(2,1,1); | |
| axis equal | |
| mu1 = [5 4]'; | |
| sigma1 = [2 -0.8; -0.8 1]; | |
| mu2 = [0 1]'; | |
| sigma2 = [1 -0.06;-0.06 0.5]; | |
| chol(sigma1); | |
| chol(sigma2); % verifica definida positiva |
| template <typename T> | |
| using minheap = priority_queue<T, vector<T>, greater>; | |
| vector<int> kwaymerge(vector<vector<int>>& vs) { | |
| int k = vs.size(); | |
| vector<int> readcount(k, 0); | |
| vector<int> res; | |
| vector<pair<int, int>> vec; | |
| for (int i = 0; i < k; i++) { | |
| if (vs[i].size() > 0){ |
| # 1) for m in 0..n compute g_s(z_m) = mex{g(Z_i_1) xor ... xor g(z_i_j) : 0 <= i_1 < .. < i_j < m, j <=s} | |
| import itertools | |
| import operator | |
| n = 8 | |
| s = 3 # s = d - 2 | |
| def pack(idxs, n): | |
| return [int(i in idxs) for i in xrange(n)] |
| #include <iostream> | |
| #include <stack> | |
| #include <algorithm> | |
| using namespace std; | |
| struct node { | |
| int value; | |
| node* left; | |
| node* right; |
| #include <iostream> | |
| #include <cassert> | |
| using namespace std; | |
| struct node { | |
| int value; | |
| node* left; | |
| node* right; | |
| node *parent; |