LAPACK 与 gcc 启动指南

发布于 2024-12-25 14:07:35 字数 282 浏览 4 评论 0原文

我需要帮助在 Linux gcc 中设置 LAPACK。我是 LAPACK 的新手,不了解使用 Fortran 的知识。

我已经下载了lapack-3.4.0,并制作了库来获取 liblapack.a 和 librefblas.a。

之后,我将这些库链接到我的程序: -llapack -lrefblas

我想使用 LAPACK 函数,如 dpotrf、dgetrf、dgetri 等, 如何包含头文件以便编译器找到这些函数?我是否有必要使用 lapacke(LAPACK 的 C 接口)?

I need help to setup LAPACK in Linux gcc. I am new to LAPACK and have no knowledge in using Fortran.

I have downloaded lapack-3.4.0, and make the libraries to get
liblapack.a and librefblas.a.

Afterwards, i link these libraries to my program:
-llapack -lrefblas

I wanted to use the LAPACK functions like dpotrf, dgetrf, dgetri etc,
How do I include the header files in order for my compiler to find the functions? Is it neccessary for me to use lapacke, a C interface to LAPACK?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

喜爱皱眉﹌ 2025-01-01 14:07:35

将 LAPACK 与 C++ 结合使用的方法有多种。这就是我要做的(假设您使用的是 *nix 系统)。

  1. 确保您拥有正确的库并且了解正确的编译器/链接器选项集。由于这些是用 Fortran 编写的,所以我将从 Fortran 代码开始。就像这个。确保您可以使用 gfortran 编译它。可能的链接器选项可以是(取决于您的系统):-llapack-lblas 或这些的某些组合。

  2. 然后继续使用 C++ 界面。同样,有多种方法可以实现。我个人发现使用 clapack 接口是最简单的,您可以在其中声明 LAPACk 函数,如下所示:

所示: extern "C" void dsyev_( char *jobz, char *uplo, int &n, double *a, int &lda, double *w, double *work, int &lwork, int &info);

正确的链接器选项集再次取决于您的系统,并且可以是某些东西像这样:-llapack -lf77blas -latlas(这个集合适用于我的 Ubuntu,其中 LAPACK 来自 atlas 包)。

There are several ways of using LAPACK with c++. Here's what I'd do (assuming you are on some *nix system).

  1. Make sure you have the right libraries and you know the right set of compiler/linker options. Since these are written in Fortran, I'd start with a Fortran code. Like this one. Make sure you can compile it using gfortran. Possible linker options can be (depending on your system): -llapack, -lblas or some combinations of these.

  2. Then move onto using C++ interface. Again, there are multiple ways of doing. I personally find it the easiest to use the clapack interface, where you are declaring the LAPACk functions like this:

extern "C" void dsyev_( char *jobz, char *uplo, int &n, double *a, int &lda, double *w, double *work, int &lwork, int &info);

The right set of linker options again depends on your system and can be something like this: -llapack -lf77blas -latlas (this set works on my Ubuntu where LAPACK comes from the atlas package).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文