MathGroup Archive 2010

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

Search the Archive

Re: Table of tables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113275] Re: Table of tables
  • From: Sebastian Schmitt <sschmitt at physi.uni-heidelberg.de>
  • Date: Thu, 21 Oct 2010 07:04:07 -0400 (EDT)

Dear all!

Luiz was looking for a general solution how to act only on the third
component of his vectors. I came up with this:

t = {{{-1, -1, -2}, {-1, -1, -3}}, {{-1, -1, -4}, {-1, -1, -5}}};

Map[Apply[Function[{x, y, z}, {x, y, z + a}], #] &, t, {2}]

{{{-1, -1, -2 + a}, {-1, -1, -3 + a}}, {{-1, -1, -4 +
    a}, {-1, -1, -5 + a}}}

Here you see that I work only on the third component adding "a".

What do you think?

Cheers,

Sebastian

Luiz Melo 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
>>
> 
> 
> --



  • Prev by Date: Re: Locator Manipulate
  • Next by Date: Re: Why so slow and not getting faster
  • Previous by thread: Re: Table of tables
  • Next by thread: Re: Table of tables