start tests on new binning method
use proper includes for STL
test case for trial binning in 1D
improve testing on 1d bin avg
testing
testing
section plots: can have coloured contours
binMean added
binmean1D() added
binMean2D() - start coding work [BROKEN]

Test code:

   library(oce)
   system("R CMD SHLIB bin.cpp")
   dyn.load("bin.so")
   set.seed(123)
   x <- runif(10000)
   y <- runif(10000)
   f <- x + y
   source('../R/misc.R')
   binMean2D(x, y, f)
typo in binMean2D
binMean2D() still broken can segfault
binMean2D() may be OK now
binMean1D() and binMean2D() improvements [but...]

... I am not really sure if I've done the x and y mapping right in the
indexing.  In any case, my goal is to get binMean2D() to give the same
answers as boxcarAverage2D() before I remove the latter.  Below is test
code (from src/bin.cpp) that shows a mismatch in array dimensions ...
why??

   library(oce)
   system("R CMD SHLIB bin.cpp") # must be in oce/src
   dyn.load("bin.so")
   set.seed(123)
   x <- rnorm(100, sd=1)
   y <- rnorm(100, sd=1)
   f <- x + y
   source('../R/misc.R')
   m <- binMean2D(x, y, f)
   a <- boxcarAverage2D(x, y, f, m$xmids, m$ymids)
   m$mean
   a$average
   cat("note mismatch above\n")
binMean2D() now agrees with old boxcarAverage2D()

   library(oce)
   system("R CMD SHLIB bin.cpp") # must be in oce/src
   dyn.load("bin.so")
   set.seed(123)
   x <- rnorm(100, sd=1)
   y <- rnorm(100, sd=1)
   f <- x + y
   source('../R/misc.R')
   m <- binMean2D(x, y, f)
   a <- boxcarAverage2D(x, y, f, m$xmids, m$ymids)
   cat("mismatch to old code:", sum((a$average-m$mean)^2, na.rm=TRUE),
"\n")
   str(m)
   str(a)
   plot(x, y)
   contour(m$xmids, m$ymids, m$mean, add=TRUE, lwd=4, col='pink')
   contour(a$x1out, a$x2out, a$average, add=TRUE, lwd=1)
remove boxcarAverage() and boxcarAverage2D()

These are covered exactly by the new binMean1D() and binMean2D(); see
commit notes for f48bbcdcda66e7cc9383fa63ed23609bc58fd87c
Merge branch 'bin-boxcar-testing' into develop