Message Boards Message Boards

0
|
6018 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

to SUM tensor with array

Hi, I have

B = {a, b} and

geom1Q = {{{0., -0.0975248}, {0., -0.666667}, {0.,-0.75}, {0., -0.833333}, {0., -0.916667}, {0., -1.}}, {{0., -0.0995336}, {0., -0.199067}} }

I'd sum automatically B[[1]] with geom1Q[[1,All,2]] and B[[2]] with geom1Q[[2,All,2]] to have

QQ = {{{0., -0.0975248+a}, {0., -0.666667+a}, {0.,-0.75+a}, {0., -0.833333+a}, {0., -0.916667+a}, {0., -1+a.}}, {{0., -0.0995336+b}, {0., -0.199067+b}} }

So I have written this

QQ = Table[Map[# + B[[i]] &, geom1Q[[i,All]] ] , {i, 1, Length[B]}]

but my result is

QQ = {{{0.+a, -0.0975248+a}, {0.+a, -0.666667+a}, {0.+a,-0.75+a}, {0.+a, -0.833333+a}, {0.+a, -0.916667+a}, {0.+a, -1+a.}}, {{0.+b, -0.0995336+b}, {0.+b, -0.199067+b}} }

I need your help. Thank you Margherita

2 Replies

Thank you

Not particularly elegant, but gives the result:

MapThread[Transpose[{#1, #2}] &, {geom1Q[[All, All, 1]], geom1Q[[All, All, 2]] + B}]

Cheers,

M.

POSTED BY: Marco Thiel
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