示例#1
0
 /*------------------------------------------*/ 
 static void find_max(const AzSmat *m_x, double ratio, int topk, AzDvect *v_max) {
   AzSmat m_tran; 
   m_x->transpose(&m_tran); 
   int kk = MAX(topk, (int)((double)m_x->colNum()*ratio)); 
   v_max->reform(m_x->rowNum()); 
   double *max = v_max->point_u(); 
   int row; 
   for (row = 0; row < m_x->rowNum(); ++row) {
     AzDvect v(m_tran.col(row)); 
     v.abs(); 
     AzIFarr ifa; 
     v.nonZero(&ifa); 
     ifa.sort_Float(false); /* descending order */
     ifa.cut(kk); 
     max[row] = ifa.sum() / (double)kk; 
   }
 }
示例#2
0
/*-------------------------------------------------------------------------*/
void AzPrepText2::set_ifeat(const AzSmat *m_feat, int top_num, 
                 int col, int offs, AzIFarr *ifa_ctx, feat_info fi[2]) const
{                 
  if (col < 0 || col >= m_feat->colNum()) return; 
  AzIFarr ifa; m_feat->col(col)->nonZero(&ifa); 
  fi[0].update(ifa); 
  if (top_num > 0 && ifa.size() > top_num) {
    ifa.sort_FloatInt(false); /* descending order */
    ifa.cut(top_num); 
  }
  fi[1].update(ifa); 
  if (offs == 0) ifa_ctx->concat(&ifa); 
  else {
    for (int ix = 0; ix < ifa.size(); ++ix) {
      int row = ifa.getInt(ix); 
      double val = ifa.get(ix); 
      ifa_ctx->put(row+offs, val); 
    }    
  }
}