# HG changeset patch # User Tuomo Valkonen # Date 1585604807 18000 # Node ID 762e20b8a343253bc6ba2bf6092809a4b8282e35 # Parent e9edf00242a344ba5cbe3cba168e0a07b77a172b Added README.md diff -r e9edf00242a3 -r 762e20b8a343 README.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Mon Mar 30 16:46:47 2020 -0500 @@ -0,0 +1,56 @@ + +# Algorithm tools for Julia + +Author: Tuomo Valkonen + +This repository contains some general utility routines and tools for doing +iterative algorithms in Julia: + + * Tools to facilitate working with `Channel`s + * Linked lists and writing them to log files. + * Structs: iteration, field replacement + * Calculation of norms, dot products, projections + * Conditional thread execution macros + * Template for conveniently writing iterative algorithms using `do`-block anonymous functions as algorithm steps, with visualisation/verbosity implemented generally in iterator. + + The code is used, for example, by . + +## Iterative algorithms example + +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: + +```julia +using AlgTools.Iterate + +params = (verbose_iter = 10, maxiter = 100,) + +begin + local x = 1 + simple_iterate(params) do verbose + # This is our computational step, as an anonymous + # `do`-block function. It has one parameter: `verbose`, + # itself a function. + x = x + √x + verbose() do + # This is another anonymous function that will + # only get called when decided by `verbose`. + # If we do get called, return current value + return x, nothing + end + end +end +``` +This will output +``` +10/100 J=31.051164 +20/100 J=108.493699 +30/100 J=234.690039 +40/100 J=410.056327 +50/100 J=634.799262 +60/100 J=909.042928 +70/100 J=1232.870172 +80/100 J=1606.340254 +90/100 J=2029.497673 +100/100 J=2502.377071 +``` +