Skip to content

Latest commit

 

History

History
95 lines (70 loc) · 3.64 KB

README.md

File metadata and controls

95 lines (70 loc) · 3.64 KB

PairwiseListMatrices

Julia 0.4: PairwiseListMatrices Linux, OSX: Build Status Windows: Build status Code Coverage: Coverage Status codecov.io

Documentation: http://diegozea.github.io/PairwiseListMatrices.jl/

Description

This package allows you to use a pairwise list as a matrix:

PLM

type PairwiseListMatrix{T, diagonal} <: AbstractArray{T, 2}
  list::AbstractVector{T}
  diag::AbstractVector{T}
  labels::IndexedArray
  nelements::Int
end

PairwiseListMatrix{T, diagonal} is a (squared) symmetric matrix that stores a list of values of type T for the pairwise comparison/measure of nelements. If the parameter diagonal is true the first element of the list is 1, 1, otherwise is 1, 2. The diagonal values are stored in a vector on the diag field when diagonal is false. Labels can be stored on the field labels as an IndexedArray.

Features

Labels

PairwiseListMatrix gives the option of save labels and allows to use them for indexing.

Space

In pairwise calculations like cor() if results are saved as PairwiseListMatrix the space is N(N+1)/2 instead of N*N. This is useful to compare a large number of elements, because you are saving ~ 50% of the memory.

Time

PairwiseListMatrix is faster than a full matrix to make operatation like sum and mean in the whole matrix, since it is cache efficient. However it is slower than a full matrix for reducing along dimensions.

Plots

Since this could be a representation for an adjacency matrix/list of an undirected graph, the function protovis provides an arc diagram and a matrix visualization on the web browser using Protovis.

Protovis example

Example

julia> # Pkg.add("PairwiseListMatrices")

julia> using PairwiseListMatrices

shell>  cat example.csv
A,B,10
A,C,20
B,C,30

julia> data = readcsv("example.csv")
3x3 Array{Any,2}:
 "A"  "B"  10
 "A"  "C"  20
 "B"  "C"  30

julia> list = from_table(data, Int, false)
3x3 PairwiseListMatrices.PairwiseListMatrix{Int64,false}:
  0  10  20
 10   0  30
 20  30   0

julia> list.list
3-element Array{Int64,1}:
 10
 20
 30

julia> labels(list)
3-element IndexedArrays.IndexedArray{Any}:
 "A"
 "B"
 "C"

julia> getlabel(list, "A", "B")
10

julia> list[1,2]
10

julia> full(list)
3x3 Array{Int64,2}:
  0  10  20
 10   0  30
 20  30   0