Class ExchangeWeigher

java.lang.Object
it.unimi.dsi.law.util.ExchangeWeigher

public class ExchangeWeigher
extends Object
Computes the weight of discordances using a generalisation of Knight's algorithm.
  • Constructor Details

    • ExchangeWeigher

      public ExchangeWeigher​(Int2DoubleFunction weigher, int[] perm, double[] v, int[] rank, boolean multiplicative, int[] support)
      Creates a new exchange weigher.
      Parameters:
      weigher - the function used to weight indices.
      perm - the array to be sorted.
      v - the score vector used to compare the element of perm.
      rank - a rank on the indices.
      multiplicative - whether to combine weights multiplicatively, rather than additively, which is the default.
      support - an array that will be used as temporary storage during the computation; its content will be erased, and it must be at least as long as perm. If null, it will be allocated.
  • Method Details

    • weigh

      public double weigh()
      Computes the weight of exchanges for the current data.

      Note that a call to this method will actually order the array provided at creation time using the comparator provided at creation time; thus, subsequent calls will always return 1.

      Returns:
      the weight of exchanges that will order the vector provided at creation time using the comparator provided at creation time.