https://github.com/wncc/Hello-Foss-PyThread.cpp/blob/main/src/broadcast.cpp In this code snippet B is resized , but resizing b every time can change memory location of matrix B. Make the code effective such that it B matrix is in original location