# mjdominus/spark forked from holman/spark

Switch branches/tags
Nothing to show
Commits on Nov 16, 2011
1. mjdominus committed Nov 16, 2011
Commits on Nov 15, 2011
1. gwern authored and mjdominus committed Nov 15, 2011
2. mjdominus committed Nov 15, 2011
3. mjdominus committed Nov 15, 2011
`plus tests`
4. mjdominus committed Nov 15, 2011
5. mjdominus committed Nov 15, 2011
```Use rational arithmetic throughout to avoid shelling out to bc, which
is slow and apparently nonportable.  Instead of dealing with decimal
numbers like 4.35, we convert 4.35 to 435 / 100 and deal with the
integers 435 and 100.

It is ridiculous, but it is a lot faster.

All the tests pass now.```
6. mjdominus committed Nov 15, 2011
7. mjdominus committed Nov 15, 2011
```Since 5.5 is the minimal input value, it should be at the baseline,
and should have the shortest possible tick, not the second-shortest.```
8. mjdominus committed Nov 15, 2011
```The input data were 1,5,22,13,5

Say 1 maps to a bar of height 0 and 22 to a bar of height 6.
Then the linear mapping has that x :-> (x-1) * 2/7.

So 13 :-> 24/7 = 3.43.  The test data had it displayed as a bar of
height 4, and I changed it to a bar of height 3.```
9. mjdominus committed Nov 15, 2011
10. mjdominus committed Nov 15, 2011
11. mjdominus committed Nov 15, 2011
12. mjdominus committed Nov 15, 2011
13. mjdominus committed Nov 15, 2011
`also use division instead of looping with trial multiplication`
14. holman committed Nov 15, 2011
15. holman committed Nov 15, 2011
16. holman committed Nov 15, 2011
`…spark into patricklucas-allow_spaced_input`
17. holman committed Nov 15, 2011
18. patricklucas committed Nov 15, 2011
```Instead of interpreting input "1 3 2 6 8" as "13268", treat spaces
as commas then condense.```
19. patricklucas committed Nov 15, 2011
`Minimizes this branches overall change.`
20. patricklucas committed Nov 15, 2011
```This allows input like "1, 2, 4, 7, 9" which is sometimes useful
with longer lists.```
21. holman committed Nov 15, 2011
```…fc67

obvious shell cleanups```
22. peff committed Nov 15, 2011
```This shaves a few lines from the print_ticks function. We
use "printf" instead of "echo -n" as the former is more
portable (although we are hopelessly tied to bash due to the
use of arrays, anyway, so either would be fine).```
23. peff committed Nov 15, 2011
```This is way faster than invoking bc repeatedly.

Before:

\$ DATA=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
\$ time spark.old \$DATA >/dev/null
real    0m1.018s
user    0m0.020s
sys     0m0.060s

After:

\$ time spark \$DATA >/dev/null
real    0m0.089s
user    0m0.000s
sys     0m0.008s

Or to make it more clear:

\$ elapsed_ms() {
/usr/bin/time -f %e "\$@" 2>&1 >/dev/null |
perl -lpe '\$_ *= 1000'
}
\$ spark "\$(elapsed_ms spark.old \$DATA),\$(elapsed_ms spark \$DATA)"
▇▁```
24. peff committed Nov 15, 2011
```We just reassign the data to itself in the loop, and then
25. holman committed Nov 15, 2011
26. holman committed Nov 15, 2011
`Add simple roundup tests.`
27. benburkert committed Nov 15, 2011
28. JeffAbrahamson authored and holman committed Nov 15, 2011
`This should be a bit quicker (and portable).`
29. holman committed Nov 15, 2011
30. holman committed Nov 15, 2011
31. holman committed Nov 15, 2011
`Missing "`
32. Tom Bell committed Nov 15, 2011
33. holman committed Nov 15, 2011
34. holman committed Nov 15, 2011
`Added U+2584 to get smother ticks.`