lapack and clapack

昨天安装clapack未遂,原因为mingw的sys/times.h中没有struct tms,can't find the actual solution, so posted a help in mingw user mail list, hope to receive the answer soon.

---------------------------------------------------------------------------

Known solution (but in my opinion, not optimal)

see http://icl.cs.utk.edu/lapack-forum/viewtopic.php?f=2&t=657&p=2366

---------------------------------------------

But I could use the lapack in Fortran instead, which entails relative tedious declaration like 

extern "C" void dgeqrf_ (const int &m, const int &n, double da[], const int &lda, double dtau[], double dwork[], const int &ldwork, int &info)

The difference between Fortran and C is
1. The extern "C" directive
First of all, the extern "C" linkage specification must be used to declare any
modules that are not written in C++.
2. Case sensitivity
C++ is a case sensitive language, Fortran is not. The name of the Fortran routine
is mangled by the compiler. All references to Fortran symbols may be specified
in lowercase or in uppercase (depends on the compiler) in C++ calls.
3. The underscore (_)
In many Fortran compilers, an underscore (_) is appended by default at the end
of definitions and references to externally visible symbols (subroutines,
functions, etc.). This happens for Solaris and Digital UNIX f77 compilers,
for g77 compiler and for hepf77 compiler interface; on HP-UX the +ppu option
must be added to the f77 compiler to activate this feature; on AIX -qextname
must be added to the xlf compiler. The appended underscore is a standard for
HEP Fortran libraries (e.g. CERNLIB). In a C++ call the Fortran subroutines or
functions must be specified with an appended underscore.
4. Passing parameters
An important thing to remember is that C++ passes all parameters by value
(except arrays and structures). Fortran passes them by reference. It is
therefore necessary to specify in the C++ function prototypes that the Fortran
subroutines and functions expect call-by-reference arguments using the
address-of (&) operator.
5. Arrays
C++ stores arrays in row-major order, whereas Fortran stores arrays in
column-major order. The lower bound for C++ is 0, for Fortran is 1. This
mean that the Fortran array element myarray(1,1) corresponds to the C++ array
element myarray[0][0]; whereas myarray(6,8) corresponds to myarray[7][5];


---------------------------------------------

The second solution is that I could use VS to build instead of mingw, haven't tried that. This may be the last way to go.

use the CLAPACK build (LAPACK tranlated to C) under Visual Studio to build LAPACK library and link your program with it in Mingw.
The package is available at http://icl.cs.utk.edu/lapack-for-windows/

I've already downloaded that in my /science directory;

Another things is that, surprisingly, if you want to call a C program in C++ you have to also use extern declaration?

//因为程序是C++,而CLAPACK是C语言写的,所以在此处用extern关键字

extern "C"

{
  #include <clapack.h> 

}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值