a very good algorithm for inplace matrix operation.
constant memory space is used.