Subdividing a matrix into smaller submatrices for multithreading

I would like to perform a multi-threaded operation on a matrix. It makes most sense to subdivide this matrix into smaller submatrices, one for each thread. How do I divide a rectangular matrix into a possible arbitrary number of sub-blocks?

This question is quite unspecific so I’ll give you a rather generic answer: You could use views:

matrix = rand(10,100)
part1 = @view matrix[1:5,1:50]
part2 = @view matrix[1:5,50:100]
part3 = @view matrix[5:10,1:50]
part4 = @view matrix[5:10,50:100]
1 Like