New implementation of col_wise and row_wise based on block_wise