|
[Date Index]
[Thread Index]
[Author Index]
Re: modify elements of arb.dimensionality matrices
- To: mathgroup at smc.vnet.net
- Subject: [mg77351] Re: [mg77218] modify elements of arb.dimensionality matrices
- From: Carl Woll <carlw at wolfram.com>
- Date: Thu, 7 Jun 2007 03:48:16 -0400 (EDT)
- References: <200706051104.HAA02287@smc.vnet.net>
alexxx.magni at gmail.com wrote:
>I was able to write an interface to deal with matrices having
>dimension defined at runtime (see
>http://groups.google.it/group/comp.soft-sys.math.mathematica/browse_frm/thread/f286f5bdafba4195/c85eaca115f18a46?lnk=st&q=+%22Alessandro+Magni%22&rnum=2&hl=it#c85eaca115f18a46).
>
>My last problem - more a performance problem - is modify access to
>those matrices:
>
>reading access at a given index location i (where i is the location
>{x,y,z,...}) is made with:
>
>
>
>>Extract[h, i]
>>
>>
>
>while to increment h[[]] at i I use:
>
>
>
>>h = ReplacePart[h, i -> Extract[h, i] + 1]
>>
>>
>
>but I really miss the possibility to write h[[x,y]]=h[[x,y]]+1, and
>I'm user there are serious performance issues with my solution.
>
>
Why not use Increment or AddTo? For example:
In[1]:= h = ConstantArray[0, {3, 3}];
Using Increment:
In[2]:= h[[1, 2]]++
Out[2]= 0
In[3]:= h
Out[3]=
0 1 0
0 0 0
0 0 0
Using AddTo:
In[4]:= h[[2, 3]] += 10
Out[4]= 10
In[5]:= h
Out[5]=
0 1 0
0 0 10
0 0 0
Carl Woll
Wolfram Research
>The nearest I came to a solution was with:
>
>
>
>>h[[##]] & @@ i = "x"
>>
>>
>
>but I immediately get:
>
>
>
>>Set::write: Tag Apply in (s[[##1]]&)@@{1,2,1} is Protected. >>
>>
>>
>
>Do you have any idea on this?
>
>thank you!
>
>Alessandro Magni
>
>
>
Prev by Date:
Re: Best practice for Mathematica package development
Next by Date:
Re: Segregating the elements of a list based on given
Previous by thread:
modify elements of arb.dimensionality matrices
Next by thread:
Re: modify elements of arb.dimensionality matrices
|