Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

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: [mg68938] Re: How to handle Arrays that has functional parameters:
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Fri, 25 Aug 2006 05:34:50 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <echej1$oqk$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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.
> 
> I wanted to know if we can build this relation directly into the array definition?
> 
> Like say, func1[[i,j]][s_,t_]:=s^i t^j, inside the Do loop, or other alternatives.
> 
> The reason is I have some functions of a variable, which I dont want to evaluate until the last step of the solution - i.e., I dont want to evaluate them during the do loop operations, and keep it safe and then evaluate in another do loop operation where only the variables will change to evaluate the lagrangian and hence the individual solution for the variable value. I can use the following method, it takes some time to fix it, but would like to know if we can do it some other way.

And using directly Table does not help?

  func1= Table[ a[ i,j], { i,3}, { j,3}];
  func2[ s_,t_,i_,j_]:=s^i*t^j;
  Do[ func1[ [ i,j]]= func2[ s,t,i,j], { i,3}, { j,3}];

  func3= Table[ func2[ s,t,i,j], { i,3}, { j,3}];
  func3===func1

--> True

HTH,
Jean-Marc


  • Prev by Date: Re: Where Style Sheets are located
  • Next by Date: Re: Random numbers according to a rule / function
  • Previous by thread: Re: How to handle Arrays that has functional parameters:
  • Next by thread: Re: How to handle Arrays that has functional parameters: