On Monday, 17 February 2020 at 14:34:44 UTC, Simen Kjærås wrote:
On Monday, 17 February 2020 at 14:04:34 UTC, Adnan wrote:
//

All in all, I end up with this code:

module strassens_matmul
package {
    T[][] mulIterative(T)(const T[][] mat1, const T[][] mat2) {
auto result = createMatrix!T(getRowSize!T(mat1), getColumnSize!T(mat2));
        foreach (row; 0 .. mat1.getRowSize()) {
            foreach (column; 0 .. mat2.getColumnSize()) {
                T value;
                foreach (i; 0 .. mat1.getRowSize()) {
value += mat1.getPointCopy(row, i) * mat2.getPointCopy(i, column);
                }
                *result.getPointPtr(row, column) = value;
            }
        }
        return result;
    }
}

Aren’t these passing by values? That’s why I used ref. Plus since I don’t want to change the arrays in the function scope I used const scope.


Reply via email to