Re: Table of tables
- To: mathgroup at smc.vnet.net
- Subject: [mg113285] Re: Table of tables
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Fri, 22 Oct 2010 01:35:05 -0400 (EDT)
t = {{{-1, -1, -2}, {-1, -1, -3}}, {{-1, -1, -4}, {-1, -1, -5}}}; t /. {x_, y_, z_?NumericQ} :> {x, y, Abs[z]} {{{-1, -1, 2}, {-1, -1, 3}}, {{-1, -1, 4}, {-1, -1, 5}}} or Map[MapAt[Abs, #, -1] &, t, {2}] {{{-1, -1, 2}, {-1, -1, 3}}, {{-1, -1, 4}, {-1, -1, 5}}} % == %% True Bob Hanlon ---- Luiz Melo <luiz.melo at polymtl.ca> wrote: ============= Thanks Sebastian and Valeri for the help. I'm actually looking for a function that operates only on the third row of each column-matrix terms(which happen to be complex in the example I gave), but leaves the other terms intact. Consider a different example: Let t = {{{-1, -1, -2}, {-1, -1, -3}}, {{-1, -1, -4}, {-1, -1, -5}}}; how can I get {{{-1, -1, 2}, {-1, -1, 3}}, {{-1, -1, 4}, {-1, -1, 5}}}; that is, in this case, I need a function that takes the Abs[] of the 3rd row of each sub-matrix and leaves the other terms intact. Regards, Luiz > Hi Luiz! > > Luiz Melo wrote: > > Given > > > > t = {{{-1, -1, -2+2I}, {-1, -1, 3-I}}, {{-1, -1, 4+I}, {-1, -1, -5-5I}}}; > > > > how can I extract the imaginary part of the complex elements to obtain > > > > {{{-1, -1, 2}, {-1, -1, -1}}, {{-1, -1, 1}, {-1, -1, -5}}}; > > What about: > > Function[{e}, If[Im[e] == 0, e, Im[e]], Listable][t] > > There seems to be no ComplexQ therefore I test with "Im[e] == 0" if it > is not a complex number. > > Cheers, > > Sebastian >