Mon, 20 Apr 2020 12:21:39 -0500
Link ImageTools
| 11 | 1 | |
| 13 | 2 | # AlgTools |
| 11 | 3 | |
| 4 | Author: Tuomo Valkonen <tuomov@iki.fi> | |
| 5 | ||
| 6 | This repository contains some general utility routines and tools for doing | |
| 7 | iterative algorithms in Julia: | |
| 8 | ||
| 9 | * Tools to facilitate working with `Channel`s | |
| 10 | * Linked lists and writing them to log files. | |
| 11 | * Structs: iteration, field replacement | |
| 12 | * Calculation of norms, dot products, projections | |
| 13 | * Conditional thread execution macros | |
| 12 | 14 | * Template for conveniently writing iterative algorithms using `do`-block anonymous functions as algorithm steps, with visualisation/verbosity implemented generally in iterator. |
| 11 | 15 | |
| 14 | 16 | The code is used by [ImageTools][] and both, for example, by <http://dx.doi.org/10.5281/zenodo.3659180>. |
| 11 | 17 | |
| 12 | 18 | ## Installation |
| 19 | ||
| 20 | To install this package, first clone the repository with [Mercurial](https://www.mercurial-scm.org/): | |
| 21 | ||
| 22 | ```console | |
| 23 | $ hg clone https://tuomov.iki.fi/repos/AlgTools/ | |
| 24 | ``` | |
| 25 | ||
| 26 | (Canonical public repository URL indicated here.) | |
| 27 | Then add the repository to Julia with `Pkg.develop`: | |
| 28 | ||
| 29 | ```console | |
| 30 | julia>] develop LOCATION_OF/AlgTools/ | |
| 31 | ``` | |
| 32 | ||
| 33 | Here replace `LOCATION_OF/AlgTools` with path where you cloned AlgTools. (If you did not change directory after cloning, simply use `AlgTools`.) | |
| 34 | Afterwards, you may use the package with: | |
| 35 | ||
| 36 | ```console | |
| 37 | julia> using AlgTools | |
| 38 | ``` | |
| 39 | ||
| 40 | This package is not and is not planned to be available via `Pkg.add` as it is based on the worst and must unusable version control system ever invented: Git. | |
| 41 | ||
| 11 | 42 | ## Iterative algorithms example |
| 43 | ||
| 44 | The package includes `simple_iterate` which helps separating the computational step of iterative algorithms for visualisation routines. It is merely intended to serve as a template, as different applications require different visualisation routines to be implemented in a replacement of `simple_iterate`. The computational step is implemented as a `do`-block anonymous function that gets passed another function is a parameter for doing the verbosity on request. Example: | |
| 45 | ||
| 46 | ```julia | |
| 47 | using AlgTools.Iterate | |
| 48 | ||
| 49 | params = (verbose_iter = 10, maxiter = 100,) | |
| 50 | ||
| 51 | begin | |
| 52 | local x = 1 | |
| 53 | simple_iterate(params) do verbose | |
| 54 | # This is our computational step, as an anonymous | |
| 55 | # `do`-block function. It has one parameter: `verbose`, | |
| 56 | # itself a function. | |
| 57 | x = x + √x | |
| 58 | verbose() do | |
| 59 | # This is another anonymous function that will | |
| 60 | # only get called when decided by `verbose`. | |
| 61 | # If we do get called, return current value | |
| 62 | return x, nothing | |
| 63 | end | |
| 64 | end | |
| 65 | end | |
| 66 | ``` | |
| 67 | This will output | |
| 68 | ``` | |
| 69 | 10/100 J=31.051164 | |
| 70 | 20/100 J=108.493699 | |
| 71 | 30/100 J=234.690039 | |
| 72 | 40/100 J=410.056327 | |
| 73 | 50/100 J=634.799262 | |
| 74 | 60/100 J=909.042928 | |
| 75 | 70/100 J=1232.870172 | |
| 76 | 80/100 J=1606.340254 | |
| 77 | 90/100 J=2029.497673 | |
| 78 | 100/100 J=2502.377071 | |
| 79 | ``` | |
| 80 | ||
| 14 | 81 | [ImageTools]: https://tuomov.iki.fi/software/ImageTools/ |