# How do I translate multiples vectors with &/@?

Posted 9 years ago
9140 Views
|
6 Replies
|
1 Total Likes
|
 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
Sort By:
Posted 9 years ago
 Thank you!
Posted 9 years ago
  In:= Map[# + {x, y} &, {{{a, b}, {c, d}, {e, f}}, {{g, h}, {l, m}}}, {2}] Out= {{{a + x, b + y}, {c + x, d + y}, {e + x, f + y}}, {{g + x, h + y}, {l + x, m + y}}} 
Posted 9 years ago
 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 9 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 9 years ago
 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 9 years ago
 Hard to figure what you mean. Perhaps this? Plus[tt, #] & /@ Flatten[cpQ, 1]