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
ArrayList<ArrayList<Integer>>simply says that an ArrayList will hold an ArrayList that holds integers. PHP only supports type hints for arrays and object so I think you can use array as type hint in the method's signature. And keeps in mind that that code is nothing but a 2D array with kind of types hint in PHP.