Re: best solution?
- To: mathgroup at smc.vnet.net
- Subject: [mg22924] Re: [mg22899] best solution?
- From: Bojan Bistrovic <bojanb at python.physics.odu.edu>
- Date: Thu, 6 Apr 2000 02:04:40 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
> I have a function e.g F[a,b,c,x] =a Sin[b x +c] and a number of parameter
> triplets
> k={{a1,b1,c1},{a2,b2,c2},{a3,b3,c3},....}.
> I would like to feed my function the parameter values in an good and simple
> way, how?
>
> (Picking out the elements like k[[3,2]]=b3 e.t.c is not what I want.)
> /Peter
>
>
>
How about this: define new function G[{a_,b_,c_},x_]:= a Sin[b x +c] (or just
G[{a_,b_,c_},x_]:=F[a,b,c,x]) and then feed your parameters as
Thread[G[k,x]] or Map[G[#,x]&,k] :
In[1]:= k={{a1,b1,c1},{a2,b2,c2},{a3,b3,c3}};
In[2]:= G[{a_,b_,c_},x_]:=F[a,b,c,x]
In[3]:= Thread[G[k,x]]
Out[3]= {F[a1,a2,a3,x],F[b1,b2,b3,x],F[c1,c2,c3,x]}
In[4]:= Map[G[#,x]&,k]
Out[4]= {F[a1,a2,a3,x],F[b1,b2,b3,x],F[c1,c2,c3,x]}
Bye, Bojan
--
---------------------------------------------------------------------
Bojan Bistrovic, bojanb at jlab.org
Old Dominion University, Norfolk VA & Jefferson Lab, Newport News, VA
---------------------------------------------------------------------