MathGroup Archive 2006

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

Search the Archive

RE: Thread function over matrix elements?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg69924] RE: [mg69865] Thread function over matrix elements?
  • From: "Erickson Paul-CPTP18" <Paul.Erickson at Motorola.com>
  • Date: Wed, 27 Sep 2006 06:05:39 -0400 (EDT)

Perhaps you might try:

Map[ f, mat, {2}]

It's the third "further examples" in the help for map.

Paul
 

-----Original Message-----
From: ben [mailto:benjamin.friedrich at gmail.com] 
To: mathgroup at smc.vnet.net
Subject: [mg69924] [mg69865] Thread function over matrix elements?

Dear all,

how do I thread a function over all elements of a matrix?
This piece of code works, but I doubt its the way i am supposed to do
this

mat=Table[i+j,{i,0,2},{j,0,2}]

Map[Map[f[#]&,#]&,mat]

I tried

Map[f[#]&,mat,2]
Apply[f[#]&,mat,2]
Thread[f[mat]]

but they give weird results.

Cheers
Ben


  • Prev by Date: Program to calculate division of continued fractions
  • Next by Date: Re: How to remove just the outermost braces of a list?
  • Previous by thread: Re: Thread function over matrix elements?
  • Next by thread: simple question revisited