我希望使用 C 中的 LAPACK 在 MATLAB/Octave 中完成 rcond 所做的事情。MATLAB 手册告诉我使用了 dgecon,即使用基于 1 的规范。
我为一个极其简单的案例编写了一个简单的测试程序;[1,1; 1,0] 对于这个输入,matlab 和 octave 使用 rcond 和 1/cond(x,1) 给我 0.25,但在使用 LAPACK 的情况下,这个示例程序打印 0.0。对于其他情况,例如身份,它会打印正确的值。
由于假设 MATLAB 实际上成功地使用了这个例程,我做错了什么?我试图破译 Octave 的功能,但收效甚微,因为它被包裹在
#include <stdio.h>
extern void dgecon_(const char *norm, const int *n, const double *a,
const int *lda, const double *anorm, double *rcond, double *work,
int *iwork, int *info, int len_norm);
int main()
{
int i, info, n, lda;
double anorm, rcond;
double w[8] = { 0,0,0,0,0,0,0,0 };
int iw[2] = { 0,0 };
double x[4] = { 1, 1, 1, 0 };
anorm = 2.0; /* maximum column sum, computed manually */
n = 2;
lda = 2;
dgecon_("1", &n, x, &lda, &anorm, &rcond, w, iw, &info, 1);
if (info != 0) fprintf(stderr, "failure with error %d\n", info);
printf("%.5e\n", rcond);
return 0;
}
用 cc testdgecon.c -o testdgecon -llapack 编译;./testdgecon