Ejemplo n.º 1
0
inline
typename get_pod_type<eT>::result
spop_var::iterator_var
  (
  T1& it,
  const T1& end,
  const uword n_zero,
  const uword norm_type,
  const eT junk1,
  const typename arma_cx_only<eT>::result* junk2
  )
  {
  arma_extra_debug_sigprint();
  arma_ignore(junk1);
  arma_ignore(junk2);

  typedef typename get_pod_type<eT>::result T;

  T1 new_it(it); // for mean
  // T1 backup_it(it); // in case we have to call robust iterator_var
  eT mean = spop_mean::iterator_mean(new_it, end, n_zero, eT(0));

   T acc2 =  T(0);
  eT acc3 = eT(0);

  const uword it_begin_pos = it.pos();

  while (it != end)
    {
    eT tmp = mean - (*it);

    acc2 += std::norm(tmp);
    acc3 += (tmp);

    ++it;
    }

  const uword n_nonzero = (it.pos() - it_begin_pos);
  if (n_nonzero == 0)
    {
    return T(0);
    }

  if (n_nonzero + n_zero == 1)
    {
    return T(0); // only one element
    }

  // Add in entries for zero elements.
  acc2 += T(n_zero) * std::norm(mean);
  acc3 += T(n_zero) * mean;

  const T norm_val = (norm_type == 0) ? T(n_zero + n_nonzero - 1) : T(n_zero + n_nonzero);
  const T var_val  = (acc2 - std::norm(acc3) / T(n_nonzero + n_zero)) / norm_val;

  return var_val;
  }
Ejemplo n.º 2
0
void initialise_search(WERD_RES_LIST &src_list, WERD_RES_LIST &new_list) {
  WERD_RES_IT src_it(&src_list);
  WERD_RES_IT new_it(&new_list);
  WERD_RES *src_wd;
  WERD_RES *new_wd;

  for (src_it.mark_cycle_pt(); !src_it.cycled_list(); src_it.forward()) {
    src_wd = src_it.data();
    if (!src_wd->combination) {
      new_wd = new WERD_RES(*src_wd);
      new_wd->combination = FALSE;
      new_wd->part_of_combo = FALSE;
      new_it.add_after_then_move(new_wd);
    }
  }
}
Ejemplo n.º 3
0
dictionary_t::value_type& dictionary_t::operator[]( const dictionary_t::key_type& key)
{
    if( !pimpl_)
        pimpl_ = new impl();

    impl::iterator it( pimpl_->items.find( key ));

    if( it != pimpl_->items.end())
        return it->second;
    else
    {
        std::pair<impl::iterator, bool> new_it( pimpl_->items.insert( std::make_pair( key,
                                                                                      dictionary_t::value_type())));
        return new_it.first->second;
    }
}
Ejemplo n.º 4
0
Archivo: cf_it.c Proyecto: edhodapp/cf
CF
e(void)
{
  return new_it(ef);
}