Skip to content

Commit 9bbe93e

Browse files
committed
Parallel array sum
1 parent 9b8e3f4 commit 9bbe93e

25 files changed

Lines changed: 586 additions & 166 deletions

‎.gitignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Compiled languages
22
*.o
3-
# Must be in src, because those in data should be included.
3+
# Must be in src, because the `.out` in data/ should be included.
44
/src/**/*.out
5+
gmon.out
56

67
# Java
78
*.class

‎beauty.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,16 @@ Easy to state, hard to prove.
4343

4444
Many other analogous questions like PSPACE vs NP.
4545

46+
### Computability
47+
4648
### Undecidability
4749

4850
<http://en.wikipedia.org/wiki/Undecidable_problem>
4951

5052
Mysterious feeling: there are problems that you can state, but not solve in general.
5153

54+
A recursive definition of computable for integer functions: <https://en.wikipedia.org/wiki/Primitive_recursive_function#Relationship_to_recursive_functions> Famous counter example which removes the "Minimisation operator": <https://en.wikipedia.org/wiki/Ackermann_function>, and falls under <https://en.wikipedia.org/wiki/Primitive_recursive_function>
55+
5256
### FPTAS
5357

5458
1/0 knapsack can be solved in polynomial time in $n$ and $\epsilon$ if solutions that are $1 - \epsion$ of the optimum are acceptable.
@@ -67,7 +71,7 @@ It is cool to understand how the following calculations can be implemented:
6771

6872
Specially interesting to look at efficient different implementations and their efficienty:
6973

70-
- simple recursive: $O(2^n)$ time!
74+
- simple recursive: $O(2^n)$ time!
7175

7276
- dynamic programming with array: $O(n)$ time, $O(n)$ memory.
7377

‎data-gen/README.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# data-gen
2+
3+
Executables in this directory generate test data to an output file.
4+
5+
The interface of each script is:
6+
7+
./script <output-file> [<parameters>...]
8+
9+
where `<parameters>` are parameters for the output generation, and depend on the exact script to be run.

‎data-gen/int_array‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
Generate an uniformly distributed array of integers.
5+
"""
6+
7+
import random
8+
import sys
9+
10+
output_path = sys.argv[1];
11+
if len(sys.argv) > 2:
12+
n = int(sys.argv[2])
13+
else:
14+
n = 1000;
15+
minv = -2**16
16+
maxv = 2**16 - 1
17+
18+
with open(output_path, 'w') as output_file:
19+
output_file.write(str(n) + '\n')
20+
for i in xrange(n - 1):
21+
output_file.write(str(random.randint(minv, maxv)) + ' ')
22+
output_file.write(str(random.randint(minv, maxv)) + '\n')

‎data/sum_array/16.in‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
16
2+
1 2 3 4 -1 -2 -3 -4 5 6 7 8 -5 -6 -7 -8

‎data/sum_array/16.out‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0

‎data/sum_array/3.in‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3
2+
1 2 3

‎data/sum_array/3.out‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6

‎data/sum_array/4.in‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
4
2+
1 -1 2 3

‎data/sum_array/4.out‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5

0 commit comments

Comments
 (0)