我一直在探索需要在矩阵上做一些工作的算法,并且我已经得到了一些在我的 Linux 机器上运行的简单代码。这是一段摘录:
extern "C" {
// link w/ LAPACK
extern void dpptrf_(const char *uplo, const int *n, double *ap, int *info);
extern void dpptri_(const char *uplo, const int *n, double *ap, int *info);
// BLAS todo: get sse2 up in here (ATLAS?)
extern void dgemm_(const char *transa, const char *transb, const int *m,
const int *n, const int *k, const double *alpha, const double *a,
const int *lda, const double *b, const int *ldb, const double *beta,
double *c, const int *ldc);
}
// in-place: be sure that (N*(N+1)/2) doubles have been initialized
inline void invert_mat_sym_packed(double *vd, int n) {
int out = 0;
dpptrf_("U",&n,vd,&out);
ASSERT(!out);
dpptri_("U",&n,vd,&out);
ASSERT(!out);
}
// use with col-major ordering!!!
inline void mult_cm(double *a, double *b, double alpha, int m, int k, int n, double *c) {
int lda = m, ldb = k, ldc = m; double beta = 1.0;
dgemm_("N","N",&m,&n,&k,&alpha,a,&lda,b,&ldb,&beta,c,&ldc);
}
我所要做的就是sudo apt-get install liblapack
,链接到图书馆。
我现在正在尝试使用此处的 32 位 dll 从 MinGW 获取此代码,但我看到了段错误和无效输出。我将继续使用 gdb 来确定错误的位置,但我怀疑有更好、更清洁、更便携的方法来完成这项工作。
我为使其编译所做的工作是为 mingw ( mingw-get install fortran
) 安装 fortran 并从之前的链接链接到 32 位 BLAS 和 LAPACK dll。
我不确定我在这里错过了多少......当使用 gcc for win32 进行编码时,其他人是如何获得他们的 LAPACK 的?
我正在寻找的是一个易于使用的 C 接口。我不想到处都是包装类。
我试图找到英特尔 MKL 的下载...甚至不是免费软件!?