title: Matrix Multiplication Java
body: <p>I need help, I am trying to make use of Lattice Multiplication in java for use in a BigInt class I am having to write for a class. </p>
  
  <p>Right now I have the code storing the digits needed for the adding part of the algorithm in a 2 dimensional array. From there though I am at a lose as to how to make a loop to go through the array and add the numbers in what would be a diagonal. </p>
  
  <p>For instance here is the test numbers etc:</p>
  
  <p>200
  *311
  = 62200</p>
  
  <p>The array is holding:</p>
  
  <p>6  0  0   </p>
  
  <p>2  0  0</p>
  
  <p>2  0  0</p>
  
  <p>6 is (2,2) in the array and the bottom right is (0,0)</p>
  
  <p>I need to add in a diagonal, such as (1,0) + (0,1) = 0</p>
  
  <p>The issue is how do I do this, since not only is it moving up and left in different ways, but it goes from 1 element to 2 elements to 3 elements, then back the other way, and of course this will get bigger the longer the number is. </p>
  
  <p>This is the code that I have:</p>
  
  <pre><code>public int multiply(BigInt val){
          int[] bigger;
          int[] smaller;
          int[] dStore;
  
          int lengthMax = (val.getSize()+this.getSize()) - 1;
          int first = 0;
          int second = 0;
  
          int[][] tempResult;
  
  
          //Checks to see which is bigger and then adds that to bigger
          if(val.getSize() &gt;= this.getSize()){
              bigger = val.getData();
              smaller = this.getData();
              dStore = new int[val.getSize()+this.getSize()];
          }else{
              bigger = this.getData();
              smaller = val.getData();
              dStore = new int[val.getSize()+this.getSize()];
          }
  
          tempResult = new int[smaller.length][bigger.length];
  
          for(int i=0;i &lt; smaller.length;i++){
              for(int j = 0;j &lt; bigger.length;j++){
                  tempResult[i][j] = smaller[i] * bigger[j];
              }
          }
  </code></pre>
  
  <p>** there is the return statement etc below</p>
  
  <p>This might help as to explain lattice multi better: <a href="http://www.youtube.com/watch?v=VoXJA-9WzNI" rel="nofollow">Lattice Multi Video</a></p>