Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Given two matrices, A_m*n (m rows and n columns), and B_n*k (n rows and k columns), now we want to compute matrix A acting on each row of matrix B, and expect (m*k)-dimensional matrix C, namely

C=A * (B_{0}) | ( A * (B_{1}) ) | ( A * (B_{1}) ) |...| ( A * (B_{k}) )

For example, let

 A=matrix{{a_00, a_01, a_02}, 
          {a_10, a_11, a_12}},
 B=matrix{{b_00, b_01, b_02, b_03}, 
          {b_10, b_11, b_12, b_13}, 
          {b_20, b_21, b_22, b_23}}

namely, m=2, n=3, k=4

 C=matrix{{a_00*b_00+a_01*b_10+a_02*b_20,  a_00*b_01+a_01*b_11+a_02*b_21,  a_00*b_02+a_01*b_12+a_02*b_22,  a_00*b_03+a_01*b_13+a_02*b_23},
          {a_10*b_00+a_11*b_10+a_12*b_20,  a_10*b_01+a_11*b_11+a_12*b_21,  a_10*b_02+a_11*b_12+a_12*b_22,  a_10*b_03+a_11*b_13+a_12*b_23} }

I could do a loop over k, and then concatenate column by column. But this is not efficient enough, when k is very large, say 10,000.

Any tips?

share|cite|improve this question
Use LAPACK. $ $ – Inquest Oct 28 '12 at 19:03
Well, this computation is just a subroutine. I need other functions of Macaulay2. – Osiris Xu Oct 28 '12 at 22:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.