Efficient Replacement Rules to Matrix?

*To*: mathgroup at smc.vnet.net*Subject*: [mg21743] Efficient Replacement Rules to Matrix?*From*: Roger Jones <rmj at leland.stanford.edu>*Date*: Wed, 26 Jan 2000 03:45:42 -0500 (EST)*Organization*: Stanford Univ*Sender*: owner-wri-mathgroup at wolfram.com

What is the most efficient (in terms of time) method to transform a set of replacement rules to a matrix. For example, I have: matrix = ZeroMatrix[5]; repmat = {{1, 1} -> 4., {5, 5} -> 3,{4, 4} -> 10,{2, 2} -> 2 + I 6, {3, 3} -> 40.}; and I transfor to a matrix thus: matrix = ReplacePart[matrix, Sequence @@ #]) & /@ ( {Last[#], #[[1]]} & /@ matrix); But for large matrices this is quite slow! Is there a more efficient method? I then will form a matrix product with this sparse matrix: result= matrix.avector and this is indeed my goal. I would appreciate any ideas on this matter. Many thanks! -Roger Jones PS This comes to light in the context of using the new Mathematica function "SparseLinearSolve"

**Follow-Ups**:**Re: Efficient Replacement Rules to Matrix?***From:*Hartmut Wolf <hwolf@debis.com>