protected override void UpdateState(RowCursorState state)
 {
     // Calculate the current group DCG, NDCG and MaxDcg.
     RankerUtils.QueryMaxDcg(_labelGains, _truncationLevel, state.QueryLabels, state.QueryOutputs,
                             state.MaxDcgCur);
     RankerUtils.QueryDcg(_labelGains, _truncationLevel, state.QueryLabels, state.QueryOutputs, state.DcgCur);
     for (int t = 0; t < _truncationLevel; t++)
     {
         Double ndcg = state.MaxDcgCur[t] > 0 ? state.DcgCur[t] / state.MaxDcgCur[t] * 100 : 0;
         state.NdcgCur[t] = ndcg;
     }
     state.QueryLabels.Clear();
     state.QueryOutputs.Clear();
 }
                public void UpdateGroup(Single weight)
                {
                    RankerUtils.QueryMaxDcg(_labelGains, TruncationLevel, _queryLabels, _queryOutputs, _groupMaxDcgCur);
                    if (_groupMaxDcg != null)
                    {
                        var maxDcg = new Double[TruncationLevel];
                        Array.Copy(_groupMaxDcgCur, maxDcg, TruncationLevel);
                        _groupMaxDcg.Add(maxDcg);
                    }

                    RankerUtils.QueryDcg(_labelGains, TruncationLevel, _queryLabels, _queryOutputs, _groupDcgCur);
                    if (_groupDcg != null)
                    {
                        var groupDcg = new Double[TruncationLevel];
                        Array.Copy(_groupDcgCur, groupDcg, TruncationLevel);
                        _groupDcg.Add(groupDcg);
                    }

                    var groupNdcg = new Double[TruncationLevel];

                    for (int t = 0; t < TruncationLevel; t++)
                    {
                        Double ndcg = _groupMaxDcgCur[t] > 0 ? _groupDcgCur[t] / _groupMaxDcgCur[t] * 100 : 0;
                        _sumNdcgAtN[t] += ndcg * weight;
                        _sumDcgAtN[t]  += _groupDcgCur[t] * weight;
                        groupNdcg[t]    = ndcg;
                    }
                    _sumWeights += weight;

                    if (_groupNdcg != null)
                    {
                        _groupNdcg.Add(groupNdcg);
                    }

                    _queryLabels.Clear();
                    _queryOutputs.Clear();
                }