# Defining product between table

For the given table, I want to make their dot product as follows.

My pseudocode is given as follows: In order to make the dot product, first the table size should be the same.

 A1=Table[a1[i,j],{i,1,n},{j,1,m}]
B1=Table[b1[i,j],{i,1,n},{j,1,m}]


Then what I want to make is $$A1.B1 = a1[1,1]*b1[1,1]+a1[1,2]*b1[1,2]+a1[1,3]+b1[1,3] + \cdots$$

To make it work, following I made some explicit exposure:

Simply let n=2, m=3.

  n=2;
m=3;
AB=List[Table[a1[i,j],{i,1,n},{j,1,m}],Table[b1[i,j],{i,1,n},{j,1,m}]]


Then what I want to make is AB[[1]][[1]].AB[[1]][[2]]+AB[[1]][[2]]AB[[2]][[2]]

  AB[[1]][[1]].AB[[2]][[1]] + AB[[1]][[2]].AB[[2]][[2]]


so that the results

  a1[1, 1] b1[1, 1] + a1[1, 2] b1[1, 2] + a1[1, 3]b1[1, 3] +  a1[2, 1] b1[2, 1] + a1[2, 2] b1[2, 2] + a1[2, 3] b1[2, 3]


Making Huge table as AB and defining the inner product explicitly I can compute the dot product between two tables with the same size, but is there any other way? Frankly speaking, I don't want to make a Huge List and define its component sum explicitly.

• Total[A1*B1, All]? Mar 3, 2023 at 10:01

Flatten[AB[[1]], 1] . Flatten[AB[[2]], 1]