edu.umd.cfar.lamp.viper.util
Class DataMatrices

java.lang.Object
  extended byedu.umd.cfar.lamp.viper.util.DataMatrices

public class DataMatrices
extends java.lang.Object

A variety of static methods for manipulating data matrices, including a transpose function and a function for computing the optimal assignment via the Hungarian algorithm. The implementation of the Hungarian algorithm is as Knuth presented in his book of graph algorithms in CWEB.

Author:
davidm

Nested Class Summary
static interface DataMatrices.GetCost
          This interface is for functor objects that uses the nodes of a DataMatrix2d as weighted edges of a bipartite graph.
static class DataMatrices.PassThrough
          Assumes Object is an instance of Number, and calls its getLong() method to determine the node cost.
 
Constructor Summary
DataMatrices()
           
 
Method Summary
static java.util.List assign(DataMatrix2d mtx, DataMatrices.GetCost c)
          Returns the data elements in the data matrix that minimize the total cost of the bipartite graph whose edges are the weighted using the objects in the matrix mtx using the cost function c.
static DataMatrix2d transpose(DataMatrix2d mtx)
          Returns a version of the matrix, flipped.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataMatrices

public DataMatrices()
Method Detail

transpose

public static DataMatrix2d transpose(DataMatrix2d mtx)
Returns a version of the matrix, flipped.

Parameters:
mtx - the matrix to transpose
Returns:
a copy of the matrix, with m.get(x,y) == transpose(m).get(y,x)

assign

public static java.util.List assign(DataMatrix2d mtx,
                                    DataMatrices.GetCost c)
Returns the data elements in the data matrix that minimize the total cost of the bipartite graph whose edges are the weighted using the objects in the matrix mtx using the cost function c.

Parameters:
mtx - the matrix to be used as the edge list of the bigraph
c - the cost function, called on each element of mtx
Returns:
a list of nodes from mtx, at most one from each column or row, that minimizes the total cost