Intel(R) - Computational and Systems Biology at MIT
Intel(R) - Computational and Systems Biology at MIT
Intel(R) - Computational and Systems Biology at MIT
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Language-specific Usage Options 7Figure 7-1Column-major order vs. row-major orderFor example, if a two-dimensional m<strong>at</strong>rix A of size m x n is stored densely in aone-dimensional array B, you can access a m<strong>at</strong>rix element like this:A[i][j] = B[i*n+j] in C(i=0, ... , m-1, j=0, ... , n-1)A(i,j) = B(j*m+i) in Fortran (i=1, ... , m, j=1, ... , n).When calling LAPACK routines from C, also mind th<strong>at</strong> LAPACK routine names can be bothupper-case or lower-case, with trailing underscore or not. For example, these names areequivalent: dgetrf, DGETRF, dgetrf_, DGETRF_.BLASBLAS routines are Fortran-style routines. If you call BLAS routines from a C-languageprogram, you must follow the Fortran-style calling conventions:• Pass variables by address as opposed to passing by value.• Store d<strong>at</strong>a Fortran-style, th<strong>at</strong> is, in column-major r<strong>at</strong>her than row-major order.Refer to the LAPACK section for details of these conventions. See Example 7-1 on how tocall BLAS routines from C.When calling BLAS routines from C, also mind th<strong>at</strong> BLAS routine names can be bothupper-case <strong>and</strong> lower-case, with trailing underscore or not. For example, these names areequivalent: dgemm, DGEMM, dgemm_, DGEMM_.CBLASAn altern<strong>at</strong>ive for calling BLAS routines from a C-language program is to use the CBLASinterface.7-5