This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <png.h> | |
#include <vector> | |
#include <iostream> | |
#include <stdlib.h> | |
//encode and write PNG to memory (std::vector) with libpng on C++ | |
typedef unsigned char ui8; | |
#define ASSERT_EX(cond, error_message) do { if (!(cond)) { std::cerr << error_message; exit(1);} } while(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sRGB_to_linear(c): | |
a = 0.055 | |
if c <= 0.04045: | |
return c / 12.92 | |
else: | |
return ((c + a) / (1+a)) ** 2.4 | |
def linear_to_sRGB(c): | |
a = 0.055 | |
if c <= 0.0031308: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <math.h> | |
#include <stdio.h> | |
template <class Number> | |
Number f(Number x) { | |
Number z = x; | |
for (int i = 0; i < 4; ++i) { | |
z = z*z - 0.1 + sin(z*3); | |
} | |
if (z < 1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sympy | |
def make_id(size): | |
return sympy.Matrix([[int(i==j) for j in xrange(size)] for i in xrange(size)]) | |
def add_absorb(k, m): | |
size = len(m) | |
assert size == len(m[0]) | |
return [row + [0] for row in m] + [ [0]* (size-1) + [k,1] ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import random | |
def id_mat(n): | |
return [[int(i == j) for j in xrange(n)] for i in xrange(n)] | |
def my_pow(x, n, mul_fun, one): | |
r = one | |
assert n >= 0 and int(n) == n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: dfa.c | |
=================================================================== | |
--- dfa.c (revision grep-2.14-faster-dfa) | |
+++ dfa.c (revision grep-2.14) | |
@@ -1992,6 +1992,133 @@ | |
s->elems[i] = s->elems[i + 1]; | |
} | |
+/* Merge implementation of sorted sets, then number of sets smore than 2. | |
+ Priority queue aka 'heap' data structure used to select maximum of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- dfa.c.back 2013-08-05 16:53:47.824514544 +0400 | |
+++ dfa.c 2013-08-25 04:23:18.783885918 +0400 | |
@@ -1992,6 +1992,115 @@ | |
s->elems[i] = s->elems[i + 1]; | |
} | |
+/* merge implementation of sorted sets, then number of sets smore than 2 | |
+ priority queue aka 'heap' data structure used to select maximum of | |
+ many elements */ | |
+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
int main() { | |
std::ifstream empty("empty.txt"); | |
std::ifstream no_file("no_file.txt"); | |
std::cout << "bool: " << (empty?"e 1":"e 0") << ' ' << (no_file?"n 1":"n 0") << '\n'; | |
std::cout << "rdstate:" << (empty.rdstate()?"e 1":"e 0") << ' ' << (no_file.rdstate()?"n 1":"n 0") << '\n'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Python.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#define UTF8_ACCEPT 0 | |
#define UTF8_REJECT 1 | |
#include <stdint.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$diff -u ~/tmp/grep-2.14/src/dfa.c.prev ~/tmp/grep-2.14/src/dfa.c | |
--- /home/dobrokot/tmp/grep-2.14/src/dfa.c.prev 2013-08-05 16:53:47.824514544 +0400 | |
+++ /home/dobrokot/tmp/grep-2.14/src/dfa.c 2013-08-05 16:50:41.435058597 +0400 | |
@@ -1978,6 +1978,52 @@ | |
m->elems[m->nelem++] = s2->elems[j++]; | |
} | |
+static void | |
+merge_inplace (position_set const *src, position_set *dst) | |
+{ |
NewerOlder