MathGroup Archive 2005

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

Search the Archive

Re: Modeling and Array Problem

  • To: mathgroup at
  • Subject: [mg58743] Re: Modeling and Array Problem
  • From: Jon Harrop <usenet at>
  • Date: Sun, 17 Jul 2005 03:03:57 -0400 (EDT)
  • References: <dba4gk$ekl$>
  • Sender: owner-wri-mathgroup at

Sycamor at wrote:
> While programming, I have found it necessary to change the value of
> certain elements of an array of ordered pairs, but have been unable to
> do so.
> In[1]:= array = {{1,1},{2,2},{3,3},{4,4},{5,5}};
> In[2]:= array[[1]][[1]]
> Out[2]= 1
> In[2]:= array[[1]][[1]] = 42
> Out[2]= Set::setps: test in assignment of part is not a symbol.

You probably want:

  array[[1, 1]] = 42;

> I have included what I have written so far at the end of this message
> to put my problem in context.  As I am new to Mathematica, I do not
> know hoe to write elegant, concise programs using the array of powerful
> built in functions, so I appologize for my clunky code.  There is
> probably a much easier way to accomplish my task.

You seem to be coding in Mathematica as you would in C or Fortran. Amongst
other things, this will give you incredibly bad performance. Try to use
functional programming, i.e. avoid setting elements, Do loops and so forth.
Your code will be much shorter, faster in Mathematica and easier to debug.

Dr Jon D Harrop, Flying Frog Consultancy

  • Prev by Date: Re: refining expression in terms of real numbers
  • Next by Date: Diagonalizing a non-Hermitian Matrix
  • Previous by thread: Re: Modeling and Array Problem
  • Next by thread: Re: Modeling and Array Problem