MathGroup Archive 2006

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

Search the Archive

Re: How to handle Arrays that has functional parameters:

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68953] Re: How to handle Arrays that has functional parameters:
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Fri, 25 Aug 2006 05:35:08 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 8/23/06 at 7:15 AM, gopinathv at ou.edu (Gopinath Venkatesan) wrote:

>If we have to define an array but also work as a function, how do we
>define them?

>For example, consider the following:
>
>\!\(\(func1 = Table[a[i, j], {i, 3}, {j, 3}];\)\[IndentingNewLine]
>\(func2[s_, t_, i_, j_] := \(s\^i\) t\^j;\)\[IndentingNewLine]
>\(Do[func1[\([i, j]\)] = func2[s, t, i, j], {i, 3}, {j,
>3}];\)\[IndentingNewLine] func1 // MatrixForm\)

>Where I defined func1 to be an array, and func2 to be a function,
>and then assigned the func1 elements using func2 relation.

When you do:

func1 = Table[a[i, j], {i, 3}, {j, 3}];

you are defining func1 to be an array where each element is the function a evaluated at the array indices. Is this what you intended?

Once you have defined func1 it seems you want now define function a to be as you have defined func2. If I have this correct, it seems simple pattern matching would be effective here, i.e.,

In[14]:=
(#1 /. a[i_, j_] :> s^i*t^j & ) //@ func1

Out[14]=
{{s*t, s*t^2, s*t^3}, {s^2*t, s^2*t^2, s^2*t^3}, 
  {s^3*t, s^3*t^2, s^3*t^3}}

--
To reply via email subtract one hundred and four


  • Prev by Date: Re: A question about $Assumptions
  • Next by Date: Re: A question about $Assumptions
  • Previous by thread: Re: How to handle Arrays that has functional parameters:
  • Next by thread: Re: How to handle Arrays that has functional parameters: