Mathematical Subroutines
------------------------

Here are subroutines for

 - mean and standard deviation
 - chi^2
 - rmerge
 - calculating nref

calculations. The basic subroutines compute these parameters for a single
set of measurements and return a single number. The "2" versions of these
subroutines allow binning of the result based on provided indices, for example
to allow analysis as a function of batch.

Argument Notation
-----------------

 (i) -> comes in
 (o) -> goes out
 (io) -> both in & out

 [] -> array (size is assumed, subroutine will use (*))

Subroutine Groups
-----------------

Mean and Standard Deviation - meansd.f

 subroutine meansd((i) values[], (i) count, (i) ignore, (o) mean, (o) sd)

Chi^2 calculations - chisq.f

 subroutine chisq((i) values[], (i) errors[], (i) correct, (i) ecorrect,
                  (i) ignore, (i) count, (o) chi)
 subroutine chisq2((i) values[], (i) errors[], (i) correct, (i) ecorrect,
                   (i) indices[], (i) ignore, (i) count, 
                   (o) chi[], (o) chi_count[])

Rmerge Calculations - rmerge.f

 subroutine rmerge((i) values[], (i) count, (o) numerator, (o) denominator)
 subroutine rmerge2((i) values[], (i) indices[], (i) count, 
                    (o) numerator[], (o) denominator[])

Merging of reflections - merge.f

 subroutine merge((i) values, (i) errors, (i) count, (i) ignore, 
                  (o) mean, (o) sd)

Nref calculations - nref.f
 
 subroutine nref((i) hklin, (i) dmin, (i) dmax, (o) number)

 - alternatively the call can be split for more efficient 
   multiple resolution bin calculations

 subroutine nref_init((i) hklin, (o) nsymop)
 subroutine nref1((i) hklin, (i) nsymop, (i) dmin, (i) dmax, (o) number)
