简体   繁体   中英

Java ArrayList equivalent for PHP

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM