@Override
	protected void calculateCutScore(int[] ids, int col, double t,
			CutResult result) {
		if ( ! useWeights && ! hasNaN ) {
			int[][] factorCounts = new int[2][nFactors];
			for (int n=0; n<ids.length; n++) {
				factorCounts[input.get(ids[n], col) < t ?0 :1][ output[ids[n]] ]++;
			}
			result.countLeft  = sum(factorCounts[0]);
			result.countRight = sum(factorCounts[1]);
			double giniLeft  = getGiniIndex(factorCounts[0]);
			double giniRight = getGiniIndex(factorCounts[1]);
			result.score = (giniLeft*result.countLeft + giniRight*result.countRight) / (result.countLeft + result.countRight);
			result.leftConst  = giniLeft  < zero*zero;
			result.rightConst = giniRight < zero*zero;
		} else {
			// using weights, thus instead of counts we have weights, which are real numbers
			double[][] factorWeights = new double[2][nFactors];
			int[] branchCounts = new int[2];
			for (int n=0; n<ids.length; n++) {
				int id = ids[n];
				double value = input.get(id, col);
				double w = useWeights ?weights[id] :1.0;
				if (hasNaN) {
					if (Double.isNaN(value)) {
						result.nanWeigth += w;
						continue;
					}
				}
				int branch = value < t ?0 :1;
				factorWeights[ branch ][ output[id] ] += w;
				branchCounts[  branch ] ++;
			}
			result.countLeft  = branchCounts[0];
			result.countRight = branchCounts[1];
			double giniLeft  = getGiniIndex( factorWeights[0] );
			double giniRight = getGiniIndex( factorWeights[1] );
			double weightLeft  = sum(factorWeights[0]);
			double weightRight = sum(factorWeights[1]);
			result.score = (giniLeft*weightLeft + giniRight*weightRight) / (weightLeft + weightRight);
			result.leftConst  = giniLeft  < zero*zero;
			result.rightConst = giniRight < zero*zero;
		}
		
	}