1

我正在尝试使用矩形 A 矩阵解决 Xcode 中的 Ax = b,其中 A 和 b 的大小取决于我存储的不同数组的大小。我曾尝试使用 dgels,但由于某种原因,我收到此错误

** on entry to DGELS , parameter number 8 had an illegal value dgesv_ fails -8

这对应于工作双矩阵输入,我不知道为什么。

int numberOfPlays = (int)[playArray count]; int numberOfSignals = (int)[signalMappings 计数];

// now create A Matrix and b vector
double playElements[numberOfPlays][numberOfSignals];
for (int i = 0; i < numberOfPlays; i = i + 1) {
    for (int j = 0; j < numberOfSignals; j = j + 1) {
        playElements[i][j] = 0.0;
    }
}
double outputElements[numberOfPlays][1];
for (int i = 0; i < numberOfPlays; i = i + 1) {
    outputElements[i][0] = 0.0;
}

...update the elements of the matrices

// now solve the matrix
__CLPK_integer m = numberOfPlays;
__CLPK_integer n = numberOfSignals;
__CLPK_integer nrhs = 1;
__CLPK_integer info;
__CLPK_integer lda = n;
__CLPK_integer ldb = 1;
int min = n;
if (m < n) {
    min = m;
}
__CLPK_integer workSize = min * 2;
double *work = (double *)malloc(workSize*sizeof(double));
dgels_("N", &m, &n, &nrhs, *playElements, &lda, *outputElements, &ldb, work, &workSize, &info);
4

1 回答 1

0

参数号8对应ldb,应该是>= max(1, m, n)。所以在你的情况下,这应该是mn(以较大者为准)。

我也被这个咬了,一些文档对此还不清楚。我将错误追溯到Lapack C源代码,这很清楚。

于 2015-01-15T08:21:11.843 回答