## ColumnMajor or RowMajor order for efficiency

Post here if you have a question about LAPACK or ScaLAPACK algorithm or data format

### ColumnMajor or RowMajor order for efficiency

Hi,

I know that Lapack, because of its historical link to Fortran, was written to handle matrices in column major order. It can also handle matrices in row major order through the LAPACKE interface. But I have realized that many algorithms (LU decomposition for instance) transpose the matrix when given in row major order and then call the code written for column major order. As a consequence, the same algorithm can be up to 30% slower when the matrix is given in row major order.

Here are my questions:
- Is there any LAPACK algorithm that can't be coded as efficiently in both of the ordering?
- Do you plan to implement efficient algorithm for row ordered matrix so the transposition could be avoided?

Best regards,
François
InsideLoop

Posts: 1
Joined: Sun Jan 17, 2016 1:40 pm

### Re: ColumnMajor or RowMajor order for efficiency

Hi , This is not a reply to your specific question you asked, but it's about the row-major and col-major. I'm confused about their definition, do you mind helping me resolving them? basically I have three questions:

1) Is my understanding correct that if A = [1,2,3,4,5,6] with dimensions 2*3 then the lapack_row_major results in [ [1,2,3],[4,5,6] ], while lapack_col_major results in [ [1,3,5],[2,4,6] ] ?

2) does it matter which one of row_major or col_major I choose when I want to pass A to a function?

3) how are lapack_row_major and lda (leading dimension of array) related? Is it true that if I want to pass a m*n matrix A in lapack_row_major format to a function, then its lda is n ? and if I pass A as lapack_col_major then its lda is m ?

Thanks
ghashami

Posts: 1
Joined: Mon Jan 18, 2016 1:07 pm