Package it.unimi.dsi.law.util
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 Summary
Constructors Constructor Description ExchangeWeigher(Int2DoubleFunction weigher, int[] perm, double[] v, int[] rank, boolean multiplicative, int[] support)Creates a new exchange weigher. -
Method Summary
Modifier and Type Method Description doubleweigh()Computes the weight of exchanges for the current data.
-
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 ofperm.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 asperm. Ifnull, 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.
-