title: C++ nested for loops - inner product - marix multiplication
body: <p>I have a matrix A with 4 rows and 3 columns and a matrix B with 8 rows and 4 columns. The coefficiants in the first column of B should denote those rows of A that I want to take for the inner product with the rows of B.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;iomanip&gt;
  using namespace std;
  
  int main()
  {
  int ik, il, im;
  //A Matrix
  vector&lt;vector&lt;int&gt;&gt; A(4, vector&lt;int&gt;(3));
  A={ {0, 0, 0}, {1, 1, 0}, {0, 0, 1}, {1, 1, 1} };
  
  //B Matrix
  vector&lt;vector&lt;int&gt;&gt; B(8, vector&lt;int&gt;(4));
  B={ {1, 0, 0, 0}, {2, 1, 0, 0}, {2, 0, 1, 0}, {2, 1, 1, 0} ,{3, 0, 0, 1}, {4, 1, 0, 1}, {4, 0, 1, 1}, {4, 1, 1, 1} };
  
  vector&lt;int&gt; BZI; 
  BZI={{1},{2},{2},{2},{3},{4},{4},{4}};
  
  //calculate inner products
  vector&lt;vector&lt;int&gt;&gt; SKP_AB(4, vector&lt;int&gt;(8));
  int skp_temp;
  for(ik=0; ik&lt;4; ik++)
  {
    for(im=0; im&lt;8; im++)
    {
      for(il=0; il&lt;3; il++)
      {
      skp_temp=A[BZI[ik]][il]*B[im][il+1];
      SKP_AB[ik][im]+=skp_temp;
      }
    }
  }
  //Ausgabe von SKP_AB
  cout &lt;&lt; "\n" &lt;&lt; "#SKP_AB" &lt;&lt; "\n";
  for(ik=0; ik&lt;4; ++ik)
  {
   for(il=0; il&lt;8; ++il)
   {
   cout &lt;&lt; setw(2) &lt;&lt; SKP_AB[ik][il];
   }
  cout &lt;&lt; "\n";
  }
  
  return 0;
  }
  </code></pre>