Skip to content

Commit

Permalink
visualize: added cairo script and example outputs (#4)
Browse files Browse the repository at this point in the history
visualize: added cairo script and example outputs
  • Loading branch information
prowl[bot] authored Apr 3, 2019
2 parents 1ba064a + a0339e6 commit 0d8ff2d
Show file tree
Hide file tree
Showing 9 changed files with 307 additions and 8 deletions.
121 changes: 121 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ authors = ["Tom Milligan <tom@reinfer.io>"]
edition = "2018"

[dependencies]
cairo-rs = { version = "0.6.0", features = ["png"] }
clap = "^2.32.0"
env_logger = "^0.6.1"
lazy_static = "^1.3.0"
log = "^0.4.6"
num-bigint = "^0.2.2"
num-traits = "^0.2.6"
num_cpus = "^1.10.0"
png = "0.14.0"
threadpool = "^1.7.1"

30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,23 @@ This project uses the standard `rustup` and `cargo` toolchain. Originally tested

## Usage

A single binary `mpersist` will be built. Run with `cargo run`. Subcommands are:
Build binaries with `cargo build --release --bins`, they will be output in `target/release`:

- `search`: look for the smallest integer with the largest multiplicative persistence value
- `for`: get the multiplicative persistence of any positive integer
- `mpersist`
- `for`: get the multiplicative persistence of any positive integer
- `list`: get the multiplicative persistence of values in a range
- `search`: look for the smallest integer with the largest multiplicative persistence value
- `mp-visualize`

## Examples
### Data generation

```bash
cargo run -- for 12 # 1
cargo run -- for 77 # 4
./mpersist for 12 # 1
./mpersist -- for 77 # 4
```

```bash
cargo run -- search
./mpersist search
3 39
4 77
# etc.
Expand All @@ -32,6 +35,17 @@ cargo run -- search
# - starting with integers 233 digits in length
# - search for 10 rounds (i.e. search up to 243 digits in length)
# - use 4 threads
cargo run -- search -f 233 -n 10 -t 4
./mpersist search -f 233 -n 10 -t 4
# this might take some time!
```

### Visualization

For visualization examples, see the [example](example/) directory.
The `mp-visualize` binary reads the output of `mpersist list` from stdin, and lays it out in a [Sacks spiral](https://en.wikipedia.org/wiki/Ulam_spiral#Variants).

```bash
./mpersist list 0 3500 | ./mp-visualize default.png
./mpersist list 0 100000 | ./mp-visualize -d 0.5 -a 0.25 -r 4 -f 2.0 -w 900 shockwave.png
./mpersist list 0 25000 | ./mp-visualize -d 0.25 -a 0.25 -r 3.5 stars.png
```
Binary file added example/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/shockwave.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/stars.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions integrate/check
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ check() {
check 'for 77' for.stdout
check 'list 38 42' list.stdout
check 'search' search.stdout


cargo run --bin mpersist -- list 0 100 |
cargo run --bin mp-visualize -- /tmp/visualize.png &&
sha512sum -c ./integrate/visualize.png.sha512
1 change: 1 addition & 0 deletions integrate/visualize.png.sha512
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2229f7ca0465b940c3408ca1ae806c406b0ca39457a89ef37f4e28c6fa47f0430bea9167f6a69745ff63bb90df8c15e45053acb9dfd2c4512722022f82f1f751 /tmp/visualize.png
Loading

0 comments on commit 0d8ff2d

Please sign in to comment.