Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #14285 > unrolled thread
| Started by | Ray Koopman <koopman@sfu.ca> |
|---|---|
| First post | 2013-04-24 11:01 +0000 |
| Last post | 2013-04-24 11:01 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
Re: Sparse Array Question Ray Koopman <koopman@sfu.ca> - 2013-04-24 11:01 +0000
| From | Ray Koopman <koopman@sfu.ca> |
|---|---|
| Date | 2013-04-24 11:01 +0000 |
| Subject | Re: Sparse Array Question |
| Message-ID | <kl8e37$om5$1@smc.vnet.net> |
In[1]:= $Version
Out[1]= 5.2 for Mac OS X (June 20, 2005)
In[2]:= myList = {{1,1}->1,{2,1}->2,{1,1}->3};
In[3]:= Rule[#[[1,1]],Tr@#[[All,2]]]& /@
Split[Sort@myList,#1[[1]]==#2[[1]]&]
Out[3]= {{1,1}->4,{2,1}->2}
On Mon, Apr 22, 2013 @ 09:04 PM, christopher arthur <chris.arthur1@gmail.com> wrote:
> Hello,
>
> I have a list of rules for defining a SparseArray. The list has some
> coordinates repeated with different values. If a coordinate appears in
> the list more than once, I want to sum up the values, and then have a
> SparseArray
>
> i.e., if my list were myList={{1,1}->1,{2,1}->2,{1,1}->3} then my
> SparseArray should have {1,1}->4. I've tried using ReplacePart on an
> array to say myArray=ReplacePart[myArray,...] but this seems horribly
> inefficient as a way to change values in an array.
>
> I'm using Mathematica 5.2
>
> Cheers,
>
> Chris
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web