Simplify doesn't simplify SparseArrays

Discussion in 'Mathematica' started by Scott Morrison, Jul 21, 2004.

  1. For example, I was expecting

    Normal[Simplify[SparseArray[{{1,1}->1/q^2+q(1/q+q)},{1,1}]]]

    to return the same as

    Simplify[Normal[SparseArray[{{1,1}->1/q^2+q(1/q+q)},{1,1}]]]

    but it doesn't. Any suggestions for a modification? I was thinking of
    unprotecting SparseArray, and defining

    SparseArray /: Simplify[sa_SparseArray] :=
    SparseArray[Simplify[ArrayRules[sa]],Dimensions[sa]]

    Should this work? Would it be better for this definition to go with
    Simplify rather than SparseArray?

    Thanks, Scott Morrison
     
    Scott Morrison, Jul 21, 2004
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.