C から LAPACK を使用して、MATLAB/Octave で rcond が行うことを正確に実行したいと考えています。
非常に単純なケース用の単純なテスト プログラムを作成しました。[1,1; 1,0] この入力の matlab と octave では、rcond と 1/cond(x,1) を使用すると 0.25 が得られますが、LAPACK を使用する場合、このサンプル プログラムは 0.0 を出力します。ID などのその他のケースでは、正しい値が出力されます。
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