       Re: Function to handle array with variable _number_ of dimensions?

• To: mathgroup at smc.vnet.net
• Subject: [mg58544] Re: Function to handle array with variable _number_ of dimensions?
• From: "dkr" <dkrjeg at adelphia.net>
• Date: Wed, 6 Jul 2005 03:11:30 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Let h[k,m,{p,q}] denote the element km of the array, h[k,m,n,{p,q}]
denote element kmn of the array and so forth, where the sublist simply
allows the array element to depend on p and q.  Let g denote the
function you wish to apply to your array.

In:=
fun[p_,q_]:=
g[Table[h[Sequence@@Array[i,q],{p,q}],
Evaluate[Sequence@@Table[{i[j],p},{j,q}]]]];

For example, setting p=2 and q=2 yields a 2x2 array to which g is
applied:

In:= fun[2,2]

Out=
g[{{h[1,1,{2,2}],h[1,2,{2,2}]},{h[2,1,{2,2}],h[2,2,{2,2}]}}]

Setting p=2 and q=3  yields a 2x2x2 array (i.e., p x p x p  (i.e., q
factors)) to which g is applied:

In:= fun[2,3]

Out=
g[{{{h[1,1,1,{2,3}],h[1,1,2,{2,3}]},{h[1,2,1,{2,3}],

h[1,2,2,{2,3}]}},{{h[2,1,1,{2,3}],h[2,1,2,{2,3}]},{h[2,2,1,{2,3}],
h[2,2,2,{2,3}]}}}]

```

• Prev by Date: Re: Partial diff equations
• Next by Date: Re: Any ideas about solving an underdetermined system?
• Previous by thread: Re: Function to handle array with variable _number_ of dimensions?
• Next by thread: Re: Function to handle array with variable _number_ of dimensions?