Jblas,DGEMM 中的参数 8 (LDA) 出错

Jblas, Error on argument 8 (LDA) in DGEMM

我正在计算协方差矩阵,没有任何问题,如下所示:

    DoubleMatrix W = new DoubleMatrix(w);
    DoubleMatrix ret = new DoubleMatrix(coReturns);
    DoubleMatrix meanRets = ret.columnMeans();
    DoubleMatrix demeanedReturns = ret.subRowVector(meanRets);
    DoubleMatrix S = demeanedReturns.transpose().mmul(demeanedReturns).div(varianceDataPoints - 1);

但是突然我抛出了这个异常:

Exception in thread "main" java.lang.IllegalArgumentException: XERBLA: Error on argument 8 (LDA) in DGEMM
    at org.jblas.NativeBlas.dgemm(Native Method)
    at org.jblas.SimpleBlas.gemm(SimpleBlas.java:247)
    at org.jblas.DoubleMatrix.mmuli(DoubleMatrix.java:1781)
    at org.jblas.DoubleMatrix.mmul(DoubleMatrix.java:3138)

我真的不知道这个异常想告诉我什么。而 google 也不知道。有人可以向我解释这里发生了什么以及我该如何解决这个问题吗?

你可以找到LDA的用途here:

 LDA is INTEGER
           On entry, LDA specifies the first dimension of A as declared
           in the calling (sub) program. When  TRANSA = 'N' or 'n' then
           LDA must be at least  max( 1, m ), otherwise  LDA must be at
           least  max( 1, k ).

有一个相关的SO post解释了它的意思。

jblas 的源代码是 here,因此您应该能够单步执行它并弄清楚发生了什么。 奇怪的是,在你得到异常 (SimpleNative:247) 的那一行,LDA 被设置为 0(而不是 1 到 k 之间的值)。我建议在 jblas issue tracker.

上打开一个问题