rename charmodel.c charmodel-predict.c

This is making way for charmodel-classify.c.
opt/helpers: fix out-of-range check in opt_set_floatval()

opt_set_floatval() uses opt_set_doubleval() to do initial conversion
and bounds checking before casting the result to float.  Previously
the out of bounds check compared the original and float values for
equality and declared anything unequal to be out of bounds. While this
trick works well in the orderly integer world, it can backfire with
floating point. For example, 3.1 resolves to the double more precisely
known as 3.100000000000000088817841970012523233890533447265625, while
3.1f resolves to 3.099999904632568359375.  These are not equal, though
3.1 is generally regarded as being in bounds for a float.  There are
around 8 billion other doubles (i.e. 3.1 +/- a little bit) that map to
the same 3.1f value, of which only one is strictly equal to it.

Why wasn't this discovered by the tests? It turns out that neither
set_floatval nor set_doubleval were tested against non-integral
numbers.  This is slightly improved here.

This patch uses the arguably more reasonable definition of bounds that
is found in opt_set_doubleval(): it excludes numbers that would get
rounded to zero or an infinity. One subtlety is that the double
version allows `--foo=INF` for an explicit infinity without overflow.
This is possibly useful, and there is some fiddling to allow this for
floats. Likewise an explicit zero is allowed, as you would expect.

It is perhaps worth noting that the `*f = d` cast/assignment at the
heart of it all can crash and core dump on overflow or underflow if
the floating point exception flags are in an unexpected state.

Signed-off-by: Douglas Bagnall <douglas@halo.gen.nz>
gitignore .juliahistory, which turned up somehow
README: add link to gstreamer site
test_backprop: set dumped ppm images via command line

If you set --periodic-pgm-dmp-images, it is assumed you mean to turn
on pgm dumping.
charmodel: shift common inline functions to charmodel-helpers.h
test_backprop: extra parentheses in IN_RANGE macro

Never hurts.
charmodel: find_alphabet in strings as well as files

This is in preparation for the XML parsing version, where the raw
file contains characters that aren't in the text, hence not in the
alphabet.

It is also (probably) a transitional step toward reading the file just
once.
charmodel: remove quiet attribute, which wasn't much used.
charmodel: add alloc_file_contents helper, begin to use it
charmodel: always close file in alloc_file_contents()
charmodel: adjust alloc_collapsed_text to use intermediate string

Rather than reading the file directly. This is in preparation for the
core of the function being reused with strings only.
charmodel: use flags to coalesce annoying boolean arguments

There used to be arguments flying around for case sensitivity, collapsed
space, and utf-8. It made all the function signatures long and complicated
and made me cross.  The flags argument reduces them all to one and leaves
room for expansion if necessary. It doesn't really shorten the code.
utf8.h: check for stricter compliance

It is possible, but illegal, to encode a low unicode point in a longer
than necessary sequence, simply by including lots of leading zeros. This
guards against this.

Scarcely tested though.
classify-test: --sort-files to order audio alphabetically

This avoids the file-initial shock when the audio is in fact continuous
and the file naming is sequential.
classify-test: option to estimate presence per-minute

or any other time period. Needless to say, classify.py is getting a
bit messy.
compare-nets: properly orient paths on git root
compare-nets: pass on --presence-index, as was intended
find-best-nets: option to ignore/downplay presence results

The presence numbers were of interest in the DOC contract, but not
universally.
charmodel: slightly simplify new_char_lut()