Subj : Re: Matrix Operation To : borland.public.cpp.borlandcpp From : Bob Gonder Date : Tue Apr 19 2005 10:29 am Mohsen wrote: > Matrix multiplication using loops, when the dimensions are >considerably large takes a long time. Is it possible to replace >the loops that use indexes in order to access elements of matrix >with loops that increment pointers to elements and speed things >up? Yes. > Is there any efficient way to do so (a better one than using >pointers)? Not better, but in addition to it.... Small loops are very inefficient because the CPU must flush and refill it's execution pipeline so often. You will see speed improvments if you calculate 2, 4, 8 or even 16 cells per loop. for( x=0; x<32; ++x ) { for( y=0; y<32; y+=n) { inline_calc using x, y inline_calc using x, y+1 . . . . inline_calc using x, y+n-1 } } .