Message Boards Message Boards

0
|
9797 Views
|
6 Replies
|
1 Total Likes
View groups...
Share
Share this post:

How do I translate multiples vectors with &/@?

Hi,

I have

cpQ = {{{a,b},{c,d},{e,f}},{{g,h},{l,m }}}

and

tt = {x,y}

I would sum each cpQ couple to tt. In fact I want translate cpQ. But if I write

cpQ = Plus [ #,tt]  &/@ cpQ

It doesn't work. Which is the solution? Where is the miscalculation?

Thank for your help Margherita

6 Replies

Thank you!

 In[2]:= Map[# + {x, y} &, {{{a, b}, {c, d}, {e, f}}, {{g, h}, {l, m}}}, {2}]

 Out[2]= {{{a + x, b + y}, {c + x, d + y}, {e + x, f + y}}, {{g + x, h + y}, {l + x, m + y}}}
POSTED BY: Ilian Gachevski

Thank you, but it isn't the same. I search this

CpQ = { { {a+x, b+y},{c+x,d+y},{ e+x , f+y} } , { {g + x ,h+y },{l+x ,m+y } } }

with tt ={x,y}, but your result code is

CpQ = { { {a+x, b+x},{c+x,d+x},{ e+x , f+x} } , { {g + y ,h+y },{l+y ,m+y } } }

We are near the correct form, but it isn't the final yet.

Attachments:
Posted 10 years ago

The CpQ shape seems unbalanced:

cpQ // TableForm

I am not sure if this is a typo.

I guess you could wrap brackets around my previous code:

{Plus[tt, #] & /@ Flatten[cpQ, 1]}
POSTED BY: Priyan Fernando

Thank you for your suggestion.

I'd like obtain:

CpQ = { { {a+x, b+y},{c+x,d+y},{ e+x , f+y} } , { {g + x ,h+y },{l+x ,m+y } } }

If I use your command I have

CpQ = {{a+x, b+y},{c+x,d+y} , { e+x , f+y} , {g + x ,h+y },{l+x ,m+y } }

It isn't the same because I lost the parenthesis.

Posted 10 years ago

Hard to figure what you mean. Perhaps this?

Plus[tt, #] & /@ Flatten[cpQ, 1]
POSTED BY: Priyan Fernando
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract