private unsafe void SumupLeaf(SumupInputData input, FeatureHistogram histogram) { if (_length == 0) { return; } int nextStep = _deltas[0]; int pos = 0; fixed(int *pDocIndicesFixed = input.DocIndices) fixed(FloatType * pOutputsFixed = input.Outputs) fixed(double *pWeightsFixed = input.Weights) fixed(double *pSumWeightsFixed = histogram.SumWeightsByBin) { int * pdoc = pDocIndicesFixed; int * end = pDocIndicesFixed + input.TotalCount; FloatType *pOutputs = pOutputsFixed; double * pWeights = pWeightsFixed; while (pdoc < end) { while (nextStep <= *pdoc) { nextStep += _deltas[++pos]; } int bin = _values[pos]; int count = 0; FloatType subsum = histogram.SumTargetsByBin[bin]; if (pWeightsFixed != null) { double subweightsum = histogram.SumWeightsByBin[bin]; while (pdoc < end && nextStep > *pdoc) { subsum += *(pOutputs++); subweightsum += *(pWeights++); count++; pdoc++; } histogram.SumWeightsByBin[bin] = subweightsum; } else { while (pdoc < end && nextStep > *pdoc) { subsum += *(pOutputs++); count++; pdoc++; } } histogram.SumTargetsByBin[bin] = subsum; histogram.CountByBin[bin] += count; } } }
private unsafe void SumupRoot(SumupInputData input, FeatureHistogram histogram) { fixed(FloatType *pOutputsFixed = input.Outputs) fixed(FloatType * pSumTargetsFixed = histogram.SumTargetsByBin) fixed(double *pWeightsFixed = input.Weights) fixed(double *pSumWeightsFixed = histogram.SumWeightsByBin) { FloatType *pOutputs = pOutputsFixed; double * pWeights = pWeightsFixed; for (int i = 0; i < _values.Length; i++) { int featureBin = _values[i]; //FloatType* pSumTargets = pSumTargetsFixed + featureBin; FloatType subsum = pSumTargetsFixed[featureBin]; for (int j = 0; j < _deltas[i]; ++j) { subsum += pOutputs[j]; } pSumTargetsFixed[featureBin] = subsum; if (pWeightsFixed != null) { double subweightsum = pSumWeightsFixed[featureBin]; for (int j = 0; j < _deltas[i]; ++j) { subweightsum += pWeights[j]; } pSumWeightsFixed[featureBin] = subweightsum; pWeights += _deltas[i]; } pOutputs += _deltas[i]; histogram.CountByBin[featureBin] += _deltas[i]; } } }
private static extern unsafe int C_Sumup_double( int numBits, byte *pData, int *pIndices, double *pSampleOutputs, double *pSampleOutputWeights, FloatType *pSumTargetsByBin, double *pSumTargets2ByBin, int *pCountByBin, int totalCount, double totalSampleOutputs, double totalSampleOutputWeights);