Thread function over matrix elements?
- To: mathgroup at smc.vnet.net
- Subject: [mg69865] Thread function over matrix elements?
- From: "ben" <benjamin.friedrich at gmail.com>
- Date: Tue, 26 Sep 2006 00:59:24 -0400 (EDT)
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
- Follow-Ups:
- Re: Thread function over matrix elements?
- From: Murray Eisenberg <murray@math.umass.edu>
- Re: Thread function over matrix elements?
- From: Adriano Pascoletti <pascolet@dimi.uniud.it>
- Re: Thread function over matrix elements?