Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Sparse Arrays

Name: Anonymous 2011-12-23 0:08

Alright /proglodites/, let's hear how all of you implement a sparse arrays that stores two-dimensional data.

Name: Anonymous 2011-12-24 15:46

def (SparseMatrix = Hash.dup).new(h); h.default = 0; h; end

# example:
sm = SparseMatrix.new( [1, 2] => 4.14, [-1, 0] => 6.23 )
p sm[[1, 2]], sm[[3, 5]]

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List