MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Replacement rules for large matrixes

  • To: mathgroup at
  • Subject: [mg119859] Re: Replacement rules for large matrixes
  • From: Gabriel Landi <gtlandi at>
  • Date: Sun, 26 Jun 2011 06:26:06 -0400 (EDT)
  • References: <>

Dear Daniel,

Thank you for the reply. My matrix is constructed from a system of
polynomial equations using CoefficientArrays.
Indeed, replacement does not work. What I was doing was (sadly)

SparseArray[Normal@matrix /.rules].


On Sat, Jun 25, 2011 at 6:27 AM, dr DanW <dmaxwarren at> wrote:

> Is your matrix a nested list or a SparseArray[]?  From your description, I
> am guessing it is a nested list.  Try working with your matrix as a
> SparseArray[] instead.
> Next problem: Replace[] does not work on SparseArray[]'s.  However, you can
> use BlockRules[] (code below) to do the replacement.
> Code for BlockRules[] by Andrew Moylen at Wolfram, from an earlier posting
> on this group that I can't find right now:
> SetAttributes[BlockRules, HoldRest];
> BlockRules[rules_, expr_] := Block @@ Append[Apply[Set, Hold[rules], {2}],
>    Unevaluated[expr]]
> Enjoy,
> Daniel

  • Prev by Date: Re: How can I concatenate elements
  • Next by Date: Re: How can I write the input code for a comparison
  • Previous by thread: Re: Replacement rules for large matrixes
  • Next by thread: Why doesn't mathematica evaluate this?