Note that there are some explanatory texts on larger screens.

plurals
  1. POMatrix Partition for Strassen Algorithm
    primarykey
    data
    text
    <p>Let's say I have a NxN matrix full of random integers in the range of one to ten. Now, I want to call <code>PROC(A(1:n/2, 1:n/2)+A(n/2+1:n, n/2+1:n)...</code> where n is the size of the matrix. In other words, I want to make a submatrix starting at the first row and column of A and going until half the size of A and then add that to a submatrix that starts at half the size of A plus one and goes until the end of A.</p> <p>The partition function that I am using is this:</p> <pre><code>public Matrix partition(int rowStart, int rowEnd, int colStart, int colEnd) { // int r = 0; // int c = 0; if (this.N%2 != 0) throw new RuntimeException("Illegal matrix dimensions."); Matrix C = new Matrix((this.N)/2); for (int i=rowStart-1; i&lt;rowEnd; i++) { for (int j=colStart-1; j&lt;colEnd; j++) { C.data[i][j] = this.data[i][j]; // C.data[r][c] = this.data[i][j]; c++; } r++; } return C; } </code></pre> <p>Now, this works for finding the submatrix at the top left (<code>Matrix C = m.partition(1, m.size()/2, 1, m.size()/2);</code>) of a given matrix. </p> <pre><code> 9.00 5.00 0.00 3.00 0.00 7.00 8.00 3.00 9.00 3.00 10.00 8.00 0.00 6.00 2.00 0.00 9.00 5.00 0.00 7.00 </code></pre> <p>But when I try to get another submatrix (<code>Matrix D = m.partition(m.size()/2+1, m.size(), m.size()/2+1, m.size());</code>) I get an <code>ArrayIndexOutOfBoundsException: 2</code>. I've tried adding separate row and column counters to my partition function, but it gave the same error. How can I modify my partition function to work with all input and still give the correct output?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload