Message Boards Message Boards

0
|
1120 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Multiplication of an array/set of matrices

Posted 1 year ago

Hi,
I need to multiply an array/set of (functions as) matrices.
As an example

p = 1; T[r[[p + 1]], r[[p]], x[[p + 1]] - x[[p]], 10]
p = 2; T[r[[p + 1]], r[[p]], x[[p + 1]] - x[[p]], 10]

(r and x are long arrays, and the matrices are functions of z: T[r[[p + 1]], r[[p]], x[[p + 1]] - x[[p]], z) that gives

{{1., 0. + 544.088 I}, {0. + 5.80148*10^-11 I, 1.}
{{1., 0. + 2267.61 I}, {0. + 1.92875*10^-11 I, 1.}}

Obviously the Dot Product

Dot[T[r[[1 + 1]], r[[1]], x[[1 + 1]] - x[[1]], 10], 
 T[r[[2 + 1]], r[[2]], x[[2 + 1]] - x[[2]], 10]]

gives the correct result

{{1. + 0. I, 0. + 2811.7 I}, {0. + 7.73022*10^-11 I, 1. + 0. I}}

While the

Product[T[r[[p + 1]], r[[p]], x[[p + 1]] - x[[p]], 10], {p, 1, 2}]

gives a fancy result

{{1., -1.23378*10^6 + 0. I}, {-1.11896*10^-21 + 0. I, 1.}}

Notice that the arrays are usually quite large so something similar to "Product" would be desirable.
Thanks

Found!

BHJ = Table[
  T[r[[p + 1]], r[[p]], x[[p + 1]] - x[[p]], 10], {p, 1, 2}]
Apply[Dot, BHJ] // MatrixForm

Thanks

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