| Author |
Comment/Response |
Don
|
01/06/12 7:59pm
It seems that in most cases where a list is modified in Mathematica, instead of updating the memory storing the list, a new list is created in memory, and the old reference is redirected to it. For very large lists, this makes it difficult to do list operations.
Question: How can I transform the elements of a list without making a new copy of that list?
Example:
Say I have a 3-dimensional array called "myList". It is large:
In[1]:= Dimensions[myList]
Out[1]:= {202, 384, 500}
Say I also have a 1-dimensional list called "myAdj".
It is the size of the third level of myList:
In[2]:= Dimensions[myAdj]
Out[2]:= {500}
I would like to subtract "myAdj" from every 2nd level element of "myList":
In[3]:=
Do[
Do[
myList[[i]][[j]] = myList[[i]][[j]] - myAdj,
{j, 384}],
{i, 202}]
URL: , |
|