package brotli

/* Copyright 2013 Google Inc. All Rights Reserved.

   Distributed under MIT license.
   See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/

/* Functions for clustering similar histograms together. */

type histogramPair struct {
	idx1       uint32
	idx2       uint32
	cost_combo float64
	cost_diff  float64
}

func histogramPairIsLess( *histogramPair,  *histogramPair) bool {
	if .cost_diff != .cost_diff {
		return .cost_diff > .cost_diff
	}

	return (.idx2 - .idx1) > (.idx2 - .idx1)
}

/* Returns entropy reduction of the context map when we combine two clusters. */
func clusterCostDiff( uint,  uint) float64 {
	var  uint =  + 
	return float64()*fastLog2() + float64()*fastLog2() - float64()*fastLog2()
}