mesh-rb 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/ext/mesh/extconf.rb +22 -4
- data/ext/mesh/mesh.tar.gz +0 -0
- data/lib/mesh/version.rb +1 -1
- data/mesh.gemspec +3 -2
- metadata +4 -120
- data/ext/mesh/mesh/.bazelrc +0 -20
- data/ext/mesh/mesh/.bazelversion +0 -1
- data/ext/mesh/mesh/.clang-format +0 -15
- data/ext/mesh/mesh/.dockerignore +0 -5
- data/ext/mesh/mesh/.editorconfig +0 -16
- data/ext/mesh/mesh/.gitattributes +0 -4
- data/ext/mesh/mesh/.github/workflows/main.yml +0 -144
- data/ext/mesh/mesh/.gitignore +0 -51
- data/ext/mesh/mesh/AUTHORS +0 -5
- data/ext/mesh/mesh/CMakeLists.txt +0 -270
- data/ext/mesh/mesh/CODE_OF_CONDUCT.md +0 -77
- data/ext/mesh/mesh/Dockerfile +0 -30
- data/ext/mesh/mesh/LICENSE +0 -201
- data/ext/mesh/mesh/Makefile +0 -81
- data/ext/mesh/mesh/README.md +0 -97
- data/ext/mesh/mesh/WORKSPACE +0 -50
- data/ext/mesh/mesh/bazel +0 -350
- data/ext/mesh/mesh/mesh-pldi19-powers.pdf +0 -0
- data/ext/mesh/mesh/src/BUILD +0 -222
- data/ext/mesh/mesh/src/CMakeLists.txt +0 -85
- data/ext/mesh/mesh/src/bitmap.h +0 -590
- data/ext/mesh/mesh/src/cheap_heap.h +0 -170
- data/ext/mesh/mesh/src/common.h +0 -377
- data/ext/mesh/mesh/src/copts.bzl +0 -31
- data/ext/mesh/mesh/src/d_assert.cc +0 -75
- data/ext/mesh/mesh/src/fixed_array.h +0 -124
- data/ext/mesh/mesh/src/global_heap.cc +0 -547
- data/ext/mesh/mesh/src/global_heap.h +0 -569
- data/ext/mesh/mesh/src/gnu_wrapper.cc +0 -75
- data/ext/mesh/mesh/src/internal.h +0 -356
- data/ext/mesh/mesh/src/libmesh.cc +0 -239
- data/ext/mesh/mesh/src/mac_wrapper.cc +0 -528
- data/ext/mesh/mesh/src/measure_rss.cc +0 -44
- data/ext/mesh/mesh/src/measure_rss.h +0 -20
- data/ext/mesh/mesh/src/meshable_arena.cc +0 -776
- data/ext/mesh/mesh/src/meshable_arena.h +0 -309
- data/ext/mesh/mesh/src/meshing.h +0 -60
- data/ext/mesh/mesh/src/mini_heap.h +0 -532
- data/ext/mesh/mesh/src/mmap_heap.h +0 -104
- data/ext/mesh/mesh/src/one_way_mmap_heap.h +0 -77
- data/ext/mesh/mesh/src/partitioned_heap.h +0 -111
- data/ext/mesh/mesh/src/plasma/mesh.h +0 -33
- data/ext/mesh/mesh/src/real.cc +0 -52
- data/ext/mesh/mesh/src/real.h +0 -36
- data/ext/mesh/mesh/src/rng/mwc.h +0 -296
- data/ext/mesh/mesh/src/rng/mwc64.h +0 -58
- data/ext/mesh/mesh/src/rpl_printf.c +0 -1991
- data/ext/mesh/mesh/src/runtime.cc +0 -393
- data/ext/mesh/mesh/src/runtime.h +0 -114
- data/ext/mesh/mesh/src/shuffle_vector.h +0 -287
- data/ext/mesh/mesh/src/size_classes.def +0 -251
- data/ext/mesh/mesh/src/static/if.h +0 -36
- data/ext/mesh/mesh/src/static/log.h +0 -43
- data/ext/mesh/mesh/src/testing/benchmark/local_refill.cc +0 -103
- data/ext/mesh/mesh/src/testing/big-alloc.c +0 -28
- data/ext/mesh/mesh/src/testing/fragmenter.cc +0 -128
- data/ext/mesh/mesh/src/testing/global-large-stress.cc +0 -25
- data/ext/mesh/mesh/src/testing/local-alloc.c +0 -16
- data/ext/mesh/mesh/src/testing/meshing_benchmark.cc +0 -189
- data/ext/mesh/mesh/src/testing/thread.cc +0 -35
- data/ext/mesh/mesh/src/testing/unit/alignment.cc +0 -56
- data/ext/mesh/mesh/src/testing/unit/bitmap_test.cc +0 -274
- data/ext/mesh/mesh/src/testing/unit/concurrent_mesh_test.cc +0 -185
- data/ext/mesh/mesh/src/testing/unit/mesh_test.cc +0 -143
- data/ext/mesh/mesh/src/testing/unit/rng_test.cc +0 -22
- data/ext/mesh/mesh/src/testing/unit/size_class_test.cc +0 -66
- data/ext/mesh/mesh/src/testing/unit/triple_mesh_test.cc +0 -285
- data/ext/mesh/mesh/src/testing/userfaultfd-kernel-copy.cc +0 -164
- data/ext/mesh/mesh/src/thread_local_heap.cc +0 -163
- data/ext/mesh/mesh/src/thread_local_heap.h +0 -268
- data/ext/mesh/mesh/src/wrapper.cc +0 -433
- data/ext/mesh/mesh/support/export_mesh.cmake +0 -28
- data/ext/mesh/mesh/support/gen-size-classes +0 -57
- data/ext/mesh/mesh/support/install_all_configs +0 -33
- data/ext/mesh/mesh/support/remove_export_mesh.cmake +0 -48
- data/ext/mesh/mesh/support/update-bazelisk +0 -8
- data/ext/mesh/mesh/theory/32m80.png +0 -0
- data/ext/mesh/mesh/theory/64m80ind.png +0 -0
- data/ext/mesh/mesh/theory/bound_comparison.py +0 -67
- data/ext/mesh/mesh/theory/bounds/impdeg+1 +0 -135
- data/ext/mesh/mesh/theory/choose.py +0 -43
- data/ext/mesh/mesh/theory/common.py +0 -42
- data/ext/mesh/mesh/theory/compute_exp_Y.py +0 -134
- data/ext/mesh/mesh/theory/createRandomString.py +0 -69
- data/ext/mesh/mesh/theory/deg_bound_check.py +0 -100
- data/ext/mesh/mesh/theory/degcheck.py +0 -47
- data/ext/mesh/mesh/theory/dumps/32,1,80,dumb.txt +0 -81
- data/ext/mesh/mesh/theory/dumps/32,2,80,dumb.txt +0 -81
- data/ext/mesh/mesh/theory/dumps/32,3,80,dumb.txt +0 -81
- data/ext/mesh/mesh/theory/dumps/32,4,80,dumb.txt +0 -81
- data/ext/mesh/mesh/theory/dumps/32,5,80,dumb.txt +0 -81
- data/ext/mesh/mesh/theory/dumps/32,6,80,dumb.txt +0 -81
- data/ext/mesh/mesh/theory/dumps/32,7,80,dumb.txt +0 -81
- data/ext/mesh/mesh/theory/dumps/32,8,80,dumb.txt +0 -81
- data/ext/mesh/mesh/theory/dumps/32,9,80,dumb.txt +0 -81
- data/ext/mesh/mesh/theory/experiment.py +0 -303
- data/ext/mesh/mesh/theory/experiment_raw_results/.gitignore +0 -0
- data/ext/mesh/mesh/theory/greedy_experiment.py +0 -66
- data/ext/mesh/mesh/theory/greedy_experiment_copy.py +0 -46
- data/ext/mesh/mesh/theory/greedy_experiment_q.py +0 -75
- data/ext/mesh/mesh/theory/makeGraph.py +0 -64
- data/ext/mesh/mesh/theory/manyreps.png +0 -0
- data/ext/mesh/mesh/theory/manystrings.png +0 -0
- data/ext/mesh/mesh/theory/match_vs_color_experiment.py +0 -94
- data/ext/mesh/mesh/theory/maxmatch_vs_E[Y].py +0 -162
- data/ext/mesh/mesh/theory/maxmatch_vs_greedymatch.py +0 -96
- data/ext/mesh/mesh/theory/maxvdeg+1imp++32,80.png +0 -0
- data/ext/mesh/mesh/theory/mesh_util.py +0 -322
- data/ext/mesh/mesh/theory/meshers.py +0 -452
- data/ext/mesh/mesh/theory/meshingBenchmark.py +0 -96
- data/ext/mesh/mesh/theory/occupancyComparison.py +0 -133
- data/ext/mesh/mesh/theory/randmatch_vs_greedymatch.py +0 -97
- data/ext/mesh/mesh/theory/randmatch_vs_greedymatch_q.py +0 -103
- data/ext/mesh/mesh/theory/randmatch_vs_greedymatch_time.py +0 -117
- data/ext/mesh/mesh/theory/read_mesh_dump.py +0 -82
- data/ext/mesh/mesh/theory/test.py +0 -70
- data/ext/mesh/mesh/tools/bazel +0 -1
@@ -1,57 +0,0 @@
|
|
1
|
-
#!/usr/bin/env python3
|
2
|
-
|
3
|
-
import sys
|
4
|
-
|
5
|
-
# NO 8-byte size classes
|
6
|
-
|
7
|
-
SIZE_CLASSES = [
|
8
|
-
16,
|
9
|
-
16,
|
10
|
-
32,
|
11
|
-
48,
|
12
|
-
64,
|
13
|
-
80,
|
14
|
-
96,
|
15
|
-
112,
|
16
|
-
128,
|
17
|
-
160,
|
18
|
-
192,
|
19
|
-
224,
|
20
|
-
256,
|
21
|
-
320,
|
22
|
-
384,
|
23
|
-
448,
|
24
|
-
512,
|
25
|
-
640,
|
26
|
-
768,
|
27
|
-
896,
|
28
|
-
1024,
|
29
|
-
2048,
|
30
|
-
4096,
|
31
|
-
8192,
|
32
|
-
16384,
|
33
|
-
]
|
34
|
-
|
35
|
-
SIZE_CLASS_INDICES = {x: i for i, x in enumerate(SIZE_CLASSES)}
|
36
|
-
|
37
|
-
def get_next(i):
|
38
|
-
for sz in SIZE_CLASSES:
|
39
|
-
if i <= sz:
|
40
|
-
return sz
|
41
|
-
assert False
|
42
|
-
|
43
|
-
def main():
|
44
|
-
print('// small size classes')
|
45
|
-
for i in range(0, 1025, 8):
|
46
|
-
size_class = get_next(i)
|
47
|
-
print('\t%d,\t// %5d -> %5d' % (SIZE_CLASS_INDICES[size_class], i, size_class))
|
48
|
-
|
49
|
-
print('// large size classes')
|
50
|
-
for i in range(1024, 16385, 128):
|
51
|
-
if i == 1024:
|
52
|
-
continue
|
53
|
-
size_class = get_next(i)
|
54
|
-
print('\t%d,\t// %5d -> %5d' % (SIZE_CLASS_INDICES[size_class], i, size_class))
|
55
|
-
|
56
|
-
if __name__ == '__main__':
|
57
|
-
sys.exit(main())
|
@@ -1,33 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
set -euo pipefail
|
3
|
-
|
4
|
-
for n in 0 1 2; do
|
5
|
-
for meshing in y n; do
|
6
|
-
suffix="${n}${meshing}"
|
7
|
-
rand_config=''
|
8
|
-
meshing_config=''
|
9
|
-
case "$n" in
|
10
|
-
0)
|
11
|
-
rand_config='--config=disable-randomization'
|
12
|
-
;;
|
13
|
-
1)
|
14
|
-
# already the default
|
15
|
-
;;
|
16
|
-
2)
|
17
|
-
rand_config='--config=shuffle-on-free'
|
18
|
-
;;
|
19
|
-
esac
|
20
|
-
case "$meshing" in
|
21
|
-
n)
|
22
|
-
meshing_config='--config=disable-meshing'
|
23
|
-
;;
|
24
|
-
y)
|
25
|
-
# already the default
|
26
|
-
;;
|
27
|
-
esac
|
28
|
-
bazel_config="$rand_config $meshing_config"
|
29
|
-
echo building "'" "$bazel_config" "'"
|
30
|
-
make V=1 BAZEL_CONFIG="$bazel_config"
|
31
|
-
sudo V=1 make install LIB_SUFFIX="$suffix"
|
32
|
-
done
|
33
|
-
done
|
@@ -1,48 +0,0 @@
|
|
1
|
-
#Edit configuration files to remove mesh exported configs and varaibles
|
2
|
-
|
3
|
-
function(get_rid_of_path bash_config_contents path_to_get_rid bash_contents_updated)
|
4
|
-
#Remove libmesh path export
|
5
|
-
string(REPLACE "export LIBMESH_PATH=\"${path_to_get_rid}\"\n" "" bash_config_content_lines "${bash_config_contents}")
|
6
|
-
#Remove DYLD_FALLBACK export
|
7
|
-
string(REPLACE "export DYLD_FALLBACK_LIBRARY_PATH=\"${path_to_get_rid}\"\n" "" bash_config_contents "${bash_config_content_lines}")
|
8
|
-
#Save results to the variable from the parent scope
|
9
|
-
set(bash_contents_updated "${bash_config_contents}" PARENT_SCOPE)
|
10
|
-
endfunction(get_rid_of_path)
|
11
|
-
|
12
|
-
|
13
|
-
set(LINUX_BASH_FILE /home/${USER}/.bashrc)
|
14
|
-
set(MAC_BASH_FILE /Users/${USER}/.bash_profile)
|
15
|
-
|
16
|
-
if(SYSWIDE)
|
17
|
-
#Install to system/public folders (exports the path to the library and refresh cache on Linux). Mac is weird, the library was completely ignored.
|
18
|
-
if(WIN32)
|
19
|
-
#Remove exported variables
|
20
|
-
execute_process(COMMAND setx /M LIBMESH_PATH=)
|
21
|
-
elseif(APPLE)
|
22
|
-
else()
|
23
|
-
#Linux
|
24
|
-
file(REMOVE "/etc/ld.so.conf.d/mesh.conf") #write path to libmesh
|
25
|
-
execute_process(COMMAND ldconfig) # renew shared lib cache
|
26
|
-
endif()
|
27
|
-
endif()
|
28
|
-
|
29
|
-
#Install to user profile (just exports a variable containing the path to the library)
|
30
|
-
if(WIN32)
|
31
|
-
#Remove exported variable
|
32
|
-
execute_process(COMMAND setx LIBMESH_PATH=)
|
33
|
-
elseif(APPLE)
|
34
|
-
#Remove exported variable
|
35
|
-
file(COPY ${MAC_BASH_FILE} DESTINATION ${MAC_BASH_FILE}.bak) #backup before doing anything
|
36
|
-
file(READ ${MAC_BASH_FILE} bash_contents)
|
37
|
-
set(bash_contents_updated)
|
38
|
-
get_rid_of_path("${bash_contents}" "${INSTALLATION_DIR}/lib/" bash_contents_updated)
|
39
|
-
file(WRITE ${MAC_BASH_FILE} "${bash_contents_updated}")
|
40
|
-
else()
|
41
|
-
#Linux
|
42
|
-
#Remove exported variable
|
43
|
-
file(COPY ${LINUX_BASH_FILE} DESTINATION ${LINUX_BASH_FILE}.bak) #backup before doing anything
|
44
|
-
file(READ ${LINUX_BASH_FILE} bash_contents)
|
45
|
-
set(bash_contents_updated)
|
46
|
-
get_rid_of_path("${bash_contents}" "${INSTALLATION_DIR}/lib/" bash_contents_updated)
|
47
|
-
file(WRITE ${LINUX_BASH_FILE} "${bash_contents_updated}")
|
48
|
-
endif()
|
Binary file
|
Binary file
|
@@ -1,67 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
"""
|
3
|
-
Created on Wed Feb 01 19:18:42 2017
|
4
|
-
|
5
|
-
@author: devd
|
6
|
-
"""
|
7
|
-
|
8
|
-
from __future__ import division
|
9
|
-
from createRandomString import *
|
10
|
-
from makeGraph import *
|
11
|
-
import matplotlib.pyplot as plt
|
12
|
-
import matplotlib.patches as mpatches
|
13
|
-
import networkx as nx
|
14
|
-
import numpy as np
|
15
|
-
import time
|
16
|
-
from compute_exp_Y import compute_exp_Y, compute_degree_bound, compute_isolated_edge_bound, compute_degreeplusone_bound
|
17
|
-
from choose import compute_q
|
18
|
-
|
19
|
-
def experiment(length, ones_range_min, ones_range_max, reps, numStrings):
|
20
|
-
ones = []
|
21
|
-
y_estimate = []
|
22
|
-
deg_estimate = []
|
23
|
-
|
24
|
-
for numOnes in range(ones_range_min, ones_range_max+1):
|
25
|
-
ones.append(numOnes)
|
26
|
-
|
27
|
-
y = compute_exp_Y(length, numOnes, numStrings)
|
28
|
-
yperc = (math.floor(y)/numStrings)*100
|
29
|
-
y_estimate.append(yperc)
|
30
|
-
|
31
|
-
deg = compute_degreeplusone_bound(length, numOnes, numStrings)
|
32
|
-
degperc = (math.floor(deg)/numStrings)*100
|
33
|
-
deg_estimate.append(degperc)
|
34
|
-
|
35
|
-
return ones, y_estimate, deg_estimate
|
36
|
-
|
37
|
-
def plot_it(length, ones_range_min, ones_range_max, reps, numStrings):
|
38
|
-
ones, y_estimate, deg_estimate = experiment(length, ones_range_min, ones_range_max, reps, numStrings)
|
39
|
-
|
40
|
-
plt.errorbar(np.asarray(ones), np.asarray(y_estimate), np.zeros(len(ones)), markersize = 3, lw=1, fmt='o')
|
41
|
-
plt.errorbar(np.asarray(ones), np.asarray(deg_estimate), np.zeros(len(ones)), markersize = 3, lw=1, fmt='o')
|
42
|
-
plt.ylim([0,60])
|
43
|
-
plt.ylabel('Percentage of pages freed')
|
44
|
-
plt.xlabel('Number of objects per page')
|
45
|
-
blue_patch = mpatches.Patch(color='blue', label='E[Y] bound')
|
46
|
-
green_patch = mpatches.Patch(color = 'green', label = 'deg+1 bound')
|
47
|
-
plt.legend(handles=[blue_patch, green_patch])
|
48
|
-
plt.title('E[Y] vs DEG+1 BOUND RESULTS \n{}-object pages, {} pages'.format(length, numStrings))
|
49
|
-
plt.show()
|
50
|
-
# plt.savefig('E[Y]vsdeg{},{}'.format(length, numStrings) + '.png', dpi = 1000)
|
51
|
-
plt.close()
|
52
|
-
|
53
|
-
if __name__ == '__main__':
|
54
|
-
#length = [32,64]
|
55
|
-
length = [32]
|
56
|
-
ones_range_min = 1
|
57
|
-
ones_range_max = 32
|
58
|
-
reps = 10
|
59
|
-
#numStrings = [80,100,150,200]
|
60
|
-
numStrings= [80]
|
61
|
-
|
62
|
-
|
63
|
-
for l in length:
|
64
|
-
for n in numStrings:
|
65
|
-
plot_it(l, ones_range_min, int(l/2), reps, n)
|
66
|
-
# plot_it(l, 10, 13, 10, n)
|
67
|
-
print 'max match vs E[Y] plot {},{} done'.format(l,n)
|
@@ -1,135 +0,0 @@
|
|
1
|
-
(dp1
|
2
|
-
(I16
|
3
|
-
I4
|
4
|
-
I50
|
5
|
-
tp2
|
6
|
-
cnumpy.core.multiarray
|
7
|
-
scalar
|
8
|
-
p3
|
9
|
-
(cnumpy
|
10
|
-
dtype
|
11
|
-
p4
|
12
|
-
(S'f8'
|
13
|
-
I0
|
14
|
-
I1
|
15
|
-
tRp5
|
16
|
-
(I3
|
17
|
-
S'<'
|
18
|
-
NNNI-1
|
19
|
-
I-1
|
20
|
-
I0
|
21
|
-
tbS'\x08\x1dN\xcf\xb1\x1e4@'
|
22
|
-
tRp6
|
23
|
-
s(I64
|
24
|
-
I1
|
25
|
-
I1000
|
26
|
-
tp7
|
27
|
-
g3
|
28
|
-
(g5
|
29
|
-
S'\xd6\x11;\xd2\xd8%\x7f@'
|
30
|
-
tRp8
|
31
|
-
s(I16
|
32
|
-
I5
|
33
|
-
I50
|
34
|
-
tp9
|
35
|
-
g3
|
36
|
-
(g5
|
37
|
-
S'\xaa\x17j\x92\xe1u0@'
|
38
|
-
tRp10
|
39
|
-
s(I16
|
40
|
-
I1
|
41
|
-
I100
|
42
|
-
tp11
|
43
|
-
g3
|
44
|
-
(g5
|
45
|
-
S'4/a\x94\xde]H@'
|
46
|
-
tRp12
|
47
|
-
s(I16
|
48
|
-
I1
|
49
|
-
I50
|
50
|
-
tp13
|
51
|
-
g3
|
52
|
-
(g5
|
53
|
-
S'\x17J\xf1\x11-\xf67@'
|
54
|
-
tRp14
|
55
|
-
s(I16
|
56
|
-
I5
|
57
|
-
I100
|
58
|
-
tp15
|
59
|
-
g3
|
60
|
-
(g5
|
61
|
-
S'\x18f\xa7\xb6\x87"C@'
|
62
|
-
tRp16
|
63
|
-
s(I16
|
64
|
-
I6
|
65
|
-
I50
|
66
|
-
tp17
|
67
|
-
g3
|
68
|
-
(g5
|
69
|
-
S'R\xa1\xf7tBn(@'
|
70
|
-
tRp18
|
71
|
-
s(I16
|
72
|
-
I2
|
73
|
-
I100
|
74
|
-
tp19
|
75
|
-
g3
|
76
|
-
(g5
|
77
|
-
S'\xb7D\xf1DW\xd7G@'
|
78
|
-
tRp20
|
79
|
-
s(I16
|
80
|
-
I2
|
81
|
-
I50
|
82
|
-
tp21
|
83
|
-
g3
|
84
|
-
(g5
|
85
|
-
S'\xc0M\x08\x08.27@'
|
86
|
-
tRp22
|
87
|
-
s(I16
|
88
|
-
I6
|
89
|
-
I100
|
90
|
-
tp23
|
91
|
-
g3
|
92
|
-
(g5
|
93
|
-
S'\xb1\xb6r\x93\xe1o<@'
|
94
|
-
tRp24
|
95
|
-
s(I16
|
96
|
-
I3
|
97
|
-
I100
|
98
|
-
tp25
|
99
|
-
g3
|
100
|
-
(g5
|
101
|
-
S'+p\xb5\x17\x88\x0fG@'
|
102
|
-
tRp26
|
103
|
-
s(I16
|
104
|
-
I7
|
105
|
-
I50
|
106
|
-
tp27
|
107
|
-
g3
|
108
|
-
(g5
|
109
|
-
S'\x0c\x18-\xaf}\x9d\n@'
|
110
|
-
tRp28
|
111
|
-
s(I16
|
112
|
-
I7
|
113
|
-
I100
|
114
|
-
tp29
|
115
|
-
g3
|
116
|
-
(g5
|
117
|
-
S"0,\x8e\xee\xe1G'@"
|
118
|
-
tRp30
|
119
|
-
s(I16
|
120
|
-
I3
|
121
|
-
I50
|
122
|
-
tp31
|
123
|
-
g3
|
124
|
-
(g5
|
125
|
-
S'\xb6\x06ER\xd9\x0b6@'
|
126
|
-
tRp32
|
127
|
-
s(I16
|
128
|
-
I4
|
129
|
-
I100
|
130
|
-
tp33
|
131
|
-
g3
|
132
|
-
(g5
|
133
|
-
S'>a\xb9\x9c\x14\xc1E@'
|
134
|
-
tRp34
|
135
|
-
s.
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
"""
|
3
|
-
Created on Wed Apr 27 16:52:27 2016
|
4
|
-
|
5
|
-
@author: devd
|
6
|
-
"""
|
7
|
-
#from __future__ import division
|
8
|
-
from math import factorial
|
9
|
-
from scipy.misc import comb
|
10
|
-
|
11
|
-
|
12
|
-
#def nCr(n, r):
|
13
|
-
# return factorial(n) // factorial(n-r) // factorial(r)
|
14
|
-
|
15
|
-
#def nCr(n,r):
|
16
|
-
# result = factorial(n)
|
17
|
-
# result /= factorial(r)
|
18
|
-
# result /= factorial(n-r)
|
19
|
-
# return result
|
20
|
-
|
21
|
-
def nCr(n,r):
|
22
|
-
return comb(n,r)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
def compute_q(length, numOnes):
|
28
|
-
result = float((nCr(length-numOnes, numOnes)))/(nCr(length, numOnes))
|
29
|
-
return result
|
30
|
-
|
31
|
-
def compute_p3(length, numOnes):
|
32
|
-
result = float((nCr(length-(2*numOnes), numOnes)))/(nCr(length, numOnes))
|
33
|
-
return result
|
34
|
-
|
35
|
-
#print compute_q(32,1)
|
36
|
-
|
37
|
-
|
38
|
-
if __name__ == '__main__':
|
39
|
-
for i in range(9,16):
|
40
|
-
print 'q val for {}: {}\n'.format(i,compute_q(32,i))
|
41
|
-
#print compute_q(32,13)
|
42
|
-
if __name__ == "__main__":
|
43
|
-
print compute_q(32, 6)
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
import sys
|
4
|
-
|
5
|
-
__all__ = ['ERROR', 'WARN', 'INFO', 'DEBUG', 'log', 'slurp']
|
6
|
-
|
7
|
-
# from rainbow
|
8
|
-
def make_reporter(verbosity, quiet, filelike):
|
9
|
-
'''
|
10
|
-
Returns a function suitable for logging use.
|
11
|
-
'''
|
12
|
-
if not quiet:
|
13
|
-
|
14
|
-
def report(level, msg, *args):
|
15
|
-
'Log if the specified severity is <= the initial verbosity.'
|
16
|
-
if level <= verbosity:
|
17
|
-
if len(args):
|
18
|
-
filelike.write(msg % args + '\n')
|
19
|
-
else:
|
20
|
-
filelike.write('%s\n' % (msg, ))
|
21
|
-
else:
|
22
|
-
|
23
|
-
def report(level, msg, *args):
|
24
|
-
'/dev/null logger.'
|
25
|
-
pass
|
26
|
-
|
27
|
-
return report
|
28
|
-
|
29
|
-
|
30
|
-
ERROR = 0
|
31
|
-
WARN = 1
|
32
|
-
INFO = 2
|
33
|
-
DEBUG = 3
|
34
|
-
|
35
|
-
log = make_reporter(DEBUG, False, sys.stderr)
|
36
|
-
|
37
|
-
def slurp(file_name):
|
38
|
-
'''
|
39
|
-
Reads in a file, stripping leading and trailing whitespace.
|
40
|
-
'''
|
41
|
-
with open(file_name, 'r') as f:
|
42
|
-
return f.read().strip()
|