[Haskell-cafe] hmatrix

Anatoly Yakovenko aeyakovenko at gmail.com
Sat May 31 15:09:58 EDT 2008

What is the most efficient way to update a position in a matrix or a
vector?  I came up with this:

updateVector :: Vector Double -> Int -> Double -> Vector Double
updateVector vec pos val = vec `add` v2
      v2 = fromList $ (replicate (pos) 0.0) ++ ((val - (vec @>
pos)):(replicate ((dim vec)- pos - 1) 0.0))

but this seems pretty inefficient to me.


More information about the Haskell-Cafe mailing list