c - Difference between xxxxx_(), LAPACK_xxxxx() and LAPACKE_xxxxx() functions -
let's want use lapack solve system of linear equations in c (gcc). set problem follows:
/* want solve ax=b */ int n = ...; // size double *a = ...; // nxn matrix double *b = ...; // length-n vector int m = 1; // number of columns in b (needs in variable) double *pivot; // records pivoting int info; // return value
now seems can use 1 of 3 functions solve problem. first 1 this:
dgesv_( &n, &m, a, &n, pivot, b, &n, &info );
i surprised see did not require #include
s, seems... weird.
the second function has same signature, except prefix lapack_
think causes less ambiguity , possibly less error-prone:
#include <lapack/lapacke.h> lapack_dgesv( &n, &m, a, &n, pivot, b, &n, &info );
note requires me include lapacke.h
.
the third function changes signature returning info
, not taking arguments pointers:
#include <lapack/lapacke.h> info = lapacke_dgesv( lapack_col_major, n, m, a, n, pivot, b, n);
again, function requires lapacke.h
. requires linking library -llapacke
. 3 functions need -llapack
.
i'm trying figure out differences between these functions. did snooping around , found following macros in lapacke.h
, related header files:
#define lapack_global(name,name) name##_ #define lapack_dgesv lapack_global(dgesv,dgesv)
so seems lapack_dgesv()
, dgesv_()
different names exact same function. however, appears lapacke_dgesv()
else possibly different implementation, considering fact needs library.
so question is: differences between these 2 functions? documentation says lapacke c interface lapack, function dgesv_()
? can use without needing lapacke , without compiling in fortran, how different?
thanks.
update
curiously, function dgemm_()
(matrix multiplication) not have lapack_dgemm()
equivalent. what's going on?
notice
lapacke_dgesv()
features additional flag canlapack_col_major
(usual fortran order) orlapack_row_major
(usual c order). in case oflapack_col_major
, callslapack_dgesv()
directly. in case oflapack_row_major
,lapacke_dgesv()
transpose matrix before callinglapack_dgesv()
. not new implementation ofdgesv_()
. take @ lapack-3.5.0/lapacke/src/dgesv_work.c in file, there minor additional changes error handling.lapack_dgesv()
defined in header lapacke.hlapack_global(dgesv,dgesv)
. macrolapack_global
defined in lapacke_mangling.h : wrapsdgesv_
, cares naming convention if other conventions used.
so, basically, function lapack_dgesv()
requires headers of lapacke. compared dgesv_
, problems related naming conventions in libraries may avoided. lapack_dgesv()
same dgesv_()
. function lapacke_dgesv()
enlarges scope of lapack_dgesv()
handle usual c matrix.but still calls dgesv_
in end.
the function dgemm()
part of blas library. wrapped c version cblas_dgemm()
can found in cblas . again, additionnal flag cblas_order
required, possible values cblasrowmajor
, cblascolmajor
.
Comments
Post a Comment