Reputation: 35
I'm preparing a strassen matrix algorithm using PHP. I've googled and found some similar projects in other languages like python, java ,...
Since in my opinion Java is most similar to PHP, I decided to turn the Java code to PHP.
I turned the whole java code to PHP except the following part. I don't understand the meaning of <
and >>
symbols and what they do in this code.
Any Idea?
public static int[][] strassen(ArrayList<ArrayList<Integer>> A,
ArrayList<ArrayList<Integer>> B) {
// Make the matrices bigger so that you can apply the strassen
// algorithm recursively without having to deal with odd
// matrix sizes
int n = A.size();
int m = nextPowerOfTwo(n);
int[][] APrep = new int[m][m];
int[][] BPrep = new int[m][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
APrep[i][j] = A.get(i).get(j);
BPrep[i][j] = B.get(i).get(j);
}
}
int[][] CPrep = strassenR(APrep, BPrep);
int[][] C = new int[n][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
C[i][j] = CPrep[i][j];
}
}
return C;
}
you can see the original code here
Upvotes: 0
Views: 2566
Reputation: 18763
These are ArrayList, and the closest PHP likeness to the ArrayList
class from Java is the ArrayObject class. The method names are different, but the functionality between the two is fairly close.
Upvotes: 1