public void test_neighbours() throws Exception {
   System.out.println("Testing neighbour function");
   int omax = HealpixBase.order_max;
   Random rng = new Random(5);
   for (int o = 0; o <= omax; ++o) {
     double maxang = 2.01 * HealpixProc.maxPixrad(o);
     for (int m = 0; m < nsamples; ++m) {
       long pix = (long) (rng.nextDouble() * HealpixProc.order2Npix(o));
       Vec3 v = HealpixProc.pix2vecRing(o, pix);
       long[] nb = HealpixProc.neighboursRing(o, pix);
       long[] nb2 = HealpixProc.neighboursNest(o, HealpixProc.ring2nest(o, pix));
       int nnb = 0;
       for (int n = 0; n < 8; ++n) {
         if (nb[n] < 0) assertTrue("neighbour problem 1", nb2[n] < 0);
         else {
           ++nnb;
           assertEquals("neighbour problem 2", HealpixProc.ring2nest(o, nb[n]), nb2[n]);
           assertTrue("neighbour problem 3", HealpixProc.pix2vecRing(o, nb[n]).angle(v) < maxang);
         }
       }
       assertTrue("neighbour problem 4 " + o + " " + nnb, (nnb >= 7) || ((o == 0) && (nnb >= 6)));
     }
   }
 }