Problem 60753. 2x2 binning of a large sparse matrix

Consider the 20000 x 20000 sparse matrix,
A=round(sprand(2e4,2e4,1/1e4*100)*1000);
The task is to divide this matrix into 2x2 tiles and to form the reduced 10000 x 10000 matrix B such that B(i,j) is the sum over the elements of (i,j)-th tile of A. For example,
B(1,1) = A(1,1)+A(2,1)+A(1,2)+A(2,2)
B(2,1) = A(3,1)+A(4,1)+A(3,2)+A(4,2)
etc...
Your solution must execute in less than 0.3 sec.

Solution Stats

75.0% Correct | 25.0% Incorrect
Last Solution submitted on Jan 01, 2026

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers5

Suggested Problems

More from this Author4

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!