Example of using Outer

Question: http://www.zhihu.com/question/37358109

Symbolic example

m0={{c11,c12},{c21,c22},{c31,c32}};
Total@Sinh@Flatten[Table[Outer[Times,Sin[m0[[i]]],Cos[m0[[i+1;;]]]],{i,2}]]

Example

m=100;n=10;
mat=RandomReal[1,{m,n}];
mengTiming[a=0;
Do[a=a+Sinh[Sin[mat[[i1,j1]]]*Cos[mat[[i2,j2]]]],{i1,m-1},{i2,i1+1,m},{j1,n},{j2,n}];]
a

m=100;n=10;
mat=RandomReal[1,{m,n}];
Total@Sinh@Flatten[Table[Outer[Times,Sin[mat[[i]]],Cos[mat[[i+1;;]]]],{i,m-1}]]//AbsoluteTiming
a=0;
Do[a=a+Sinh[Sin[mat[[i1,j1]]]*Cos[mat[[i2,j2]]]],{i1,m-1},{i2,i1+1,m},{j1,n},{j2,n}];//AbsoluteTiming
a

Total@Sinh@Flatten[Table[Outer[Sum[##]/Subtract[##]&,Sin[mat[[i]]],Cos[mat[[i+1;;]]]],{i,m-1}]]//mengTiming