private void applyL1Reg(final double eta_t,Vec x){
  if (lambda1 > 0) {
    l1U+=eta_t * lambda1;
    for (int k=0; k < ws.length; k++) {
      final Vec w_k=ws[k];
      final double[] l1Q_k=l1Q[k];
      for (      IndexValue iv : x) {
        final int i=iv.getIndex();
        final double z=w_k.get(i);
        double newW_i=0;
        if (z > 0)         newW_i=Math.max(0,z - (l1U + l1Q_k[i]));
 else         if (z < 0)         newW_i=Math.min(0,z + (l1U - l1Q_k[i]));
        l1Q_k[i]+=(newW_i - z);
        w_k.set(i,newW_i);
      }
    }
  }
}

private void applyL1Reg ( final double eta_t , Vec x ) { if ( lambda1 > 0 ) { l1U += eta_t * lambda1 ; for ( int k = 0 ; k < ws . length ; k ++ ) { final Vec w_k = ws [ k ] ; final double [ ] l1Q_k = l1Q [ k ] ; for ( IndexValue iv : x ) { final int i = iv . getIndex ( ) ; final double z = w_k . get ( i ) ; double newW_i = 0 ; if ( z > 0 ) newW_i = Math . max ( 0 , z - ( l1U + l1Q_k [ i ] ) ) ; else if ( z < 0 ) newW_i = Math . min ( 0 , z + ( l1U - l1Q_k [ i ] ) ) ; l1Q_k [ i ] += ( newW_i - z ) ; w_k . set ( i , newW_i ) ; } } } }
applies l1 regularization to the model
