| Author |
Comment/Response |
yehuda
|
11/18/12 5:46pm
Array uses functional programming notation to generate the elements
So
Array[mat,50] expect mat to be a function of a single argument. if it is not defined, than it is just a head, since Mathematica is also symbolic language
example
Array[mat,10]
returns
{mat[1],mat[2],...,mat[10]}
however
mat1[x_]:=x^2
Array[mat1,5]
returns
{1,4,9,16,25}
The same as
Array[#^2&,5]
or
Array[Function[x,x^2],5]
As for timings, Table is usually faster, but has the benefit of a shorter syntax form and allows offsets for the indexes
one last comment is that usually there is no need to "prepare in advance" indexed functions or "variables"
HTH
yehuda
URL: , |
|