MathGroup Archive 1999

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

Search the Archive

Re: InputStream in version 3 vs version 4

Dear Luci

ELLIS, Luci schrieb:
> Failing this, can anyone suggest a robust way to turn a list of functions
> and a matrix of data into a matrix where the elements of each row are the
> elements of the original matrix transformed by the corresponding function?
> That is:
> functions= {f[#]&, g[#]&, h[#]&}
> data = {{data[1,1],data[1,2],data[1,3]},{data[2,1],data[2,2],data[2,3},
> {data[3,1],data[3,2],data[3,3},
> {data[4,1],data[4,2],data[4,3]},{data[5,1],data[5,2],data[5,3}}
> {
> output= {f[data[1,1]], g[data[1,2]], h[data[1,3]]}, {f[data[2,1]],
> g[data[2,2]], h[data[2,3]]}, {f[data[3,1]], g[data[3,2]], h[data[3,3]]},
> {f[data[4,1]], g[data[4,2]], h[data[4,3]]}, {f[data[5,1]], g[data[5,2]],
> h[data[5,3]]},
If we Map at level 0, we get our tool:

In[1]:= Map[f,x,{0}]
Out[1]= f[x]

Operating on Lists of functions and arguments (generalisation of inner

In[2]:= Inner[Map[#1,#2,{0}]&,{f,g,h},{1,2,3},List]
Out[2]= {f[1],g[2],h[3]}

So now we can Map that over your List (of argument records)

In[3]:= funs={f,g,h};
In[4]:= data=Array[dd,{5,3}]

In[5]:= Inner[Map[#1,#2,{0}]&,funs,#,List]& /@ data

For your case, you may conveniently define

In[23]:= inapp[funs_]:=Inner[Map[#1,#2,{0}]&,funs,#,List]&

and work with the expression


kind regards, hw

  • Prev by Date: Re: How can I plot the region satisfying an inequality?
  • Next by Date: complex-valued expression not simplifying completely (was: ARghh!!)
  • Previous by thread: InputStream in version 3 vs version 4
  • Next by thread: Re: InputStream in version 3 vs version 4