Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*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 1999

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

Search the Archive

Re: InputStream in version 3 vs version 4

  • To: mathgroup at smc.vnet.net
  • Subject: [mg18818] Re: InputStream in version 3 vs version 4
  • From: "David Bailey" <dave-bailey at freeuk.com>
  • Date: Thu, 22 Jul 1999 08:19:32 -0400
  • References: <7n1313$bda@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

ELLIS, Luci wrote in message <7n1313$bda at smc.vnet.net>...
>
>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]]},
>
>I've tried various combinations of Map, MapThread, Thread and Inner without
>success.
>

First, we can neaten up your list of functions, but you could still use pure
functions if you need them of course.

functions = {f, g, h};

Now we define some data:

ss = Array[a, {5, 3}]


{{a[1, 1], a[1, 2], a[1, 3]}, {a[2, 1], a[2, 2], a[2, 3]}, {a[3, 1], a[3,
2],
    a[3, 3]}, {a[4, 1], a[4, 2], a[4, 3]}, {a[5, 1], a[5, 2], a[5, 3]}}

This will apply the functions as you require. There are probably many other
ways of doing this!

Transpose[MapThread[Map, {functions, Transpose[ss]}]]

David Bailey
Salford Software
db at salford-software.com




  • Prev by Date: Re: HDF export
  • Next by Date: Re: ValueBoxes
  • Previous by thread: Re: InputStream in version 3 vs version 4
  • Next by thread: System Modelling with Mathematica