Skip to content

Elin-/PairwiseListMatrices.jl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PairwiseListMatrices

Linux, OSX: Build Status

Windows: Build status

Code Coverage: Coverage Status codecov.io

This package allows you to use a paired list as a Matrix.

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

In pairwise calculations like cor(), saving the result as a PairwiseListMatrix is N(N-1)/2 in space, instead of N*N. This is very useful when you need to compare a large number of elements.

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

Example

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, ASCIIString, false)
3x3 PairwiseListMatrices.PairwiseListMatrix{Int64,ASCIIString,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{ASCIIString}:
 "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

Benchmark

PairwiseListMatrix is faster when you work with all the values, since is cache efficient and requires less operations. However is slower than a full matrix for reducing along dimensions.

About

Use a pairwise or paired list as a matrix

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Julia 100.0%