nodes: 0, module; 1, function_definition; 2, function_name:_weave_dohist; 3, parameters; 4, block; 5, identifier:data; 6, identifier:s; 7, identifier:binsize; 8, identifier:hist; 9, identifier:rev; 10, default_parameter; 11, default_parameter; 12, if_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, return_statement; 17, identifier:dorev; 18, False; 19, identifier:verbose; 20, integer:0; 21, identifier:dorev; 22, block; 23, else_clause; 24, comment:"""
      Weave version of histogram with reverse_indices
  
      s is an index into data, sorted and possibly a subset
      """; 25, assignment; 26, call; 27, expression_statement; 28, block; 29, identifier:code; 30, comment:"""
  
      int64_t nbin = hist.size();
      int64_t binnum_old = -1;
  
      // index of minimum value
      int64_t imin = s(0);
      for (int64_t i=0; i<s.size(); i++) {
  
          int64_t offset = i+nbin+1;
          int64_t data_index = s(i);
  
  
          if (dorev) {
              rev(offset) = data_index;
          }
  
          int64_t binnum = (int64_t) ( (data(data_index)-data(imin))/binsize);
  
          if (binnum >= 0 && binnum < nbin) {
              if (dorev && (binnum > binnum_old) ) {
                  int64_t tbin = binnum_old + 1;
                  while (tbin <= binnum) {
                      rev(tbin) = offset;
                      tbin++;
                  }
              }
              hist(binnum) = hist(binnum) + 1;
              binnum_old = binnum;
          }
      }
  
      int64_t tbin = binnum_old + 1;
      while (tbin <= nbin) {
          if (dorev) {
              rev(tbin) = rev.size();
          }
          tbin++;
      }
  
      """; 31, attribute; 32, argument_list; 33, assignment; 34, expression_statement; 35, attribute; 36, identifier:inline; 37, identifier:code; 38, list; 39, keyword_argument; 40, keyword_argument; 41, identifier:dorev; 42, integer:1; 43, assignment; 44, identifier:scipy; 45, identifier:weave; 46, string; 47, string; 48, string; 49, string; 50, string; 51, string; 52, identifier:type_converters; 53, attribute; 54, identifier:verbose; 55, identifier:verbose; 56, identifier:dorev; 57, integer:0; 58, string_content:data; 59, string_content:s; 60, string_content:binsize; 61, string_content:hist; 62, string_content:rev; 63, string_content:dorev; 64, attribute; 65, identifier:blitz; 66, attribute; 67, identifier:converters; 68, identifier:scipy; 69, identifier:weave
code: def _weave_dohist(data, s, binsize, hist, rev, dorev=False, verbose=0):
  
      if dorev:
          dorev=1
      else:
          dorev=0
      """
      Weave version of histogram with reverse_indices
  
      s is an index into data, sorted and possibly a subset
      """
      code = """
  
      int64_t nbin = hist.size();
      int64_t binnum_old = -1;
  
      // index of minimum value
      int64_t imin = s(0);
      for (int64_t i=0; i<s.size(); i++) {
  
          int64_t offset = i+nbin+1;
          int64_t data_index = s(i);
  
  
          if (dorev) {
              rev(offset) = data_index;
          }
  
          int64_t binnum = (int64_t) ( (data(data_index)-data(imin))/binsize);
  
          if (binnum >= 0 && binnum < nbin) {
              if (dorev && (binnum > binnum_old) ) {
                  int64_t tbin = binnum_old + 1;
                  while (tbin <= binnum) {
                      rev(tbin) = offset;
                      tbin++;
                  }
              }
              hist(binnum) = hist(binnum) + 1;
              binnum_old = binnum;
          }
      }
  
      int64_t tbin = binnum_old + 1;
      while (tbin <= nbin) {
          if (dorev) {
              rev(tbin) = rev.size();
          }
          tbin++;
      }
  
      """
  
      scipy.weave.inline(code, ['data','s','binsize','hist','rev','dorev'],
                         type_converters = scipy.weave.converters.blitz, verbose=verbose)
      return