0

I am calculating a covariance matrix without any problems like so:

    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);

But suddenly I get this Exception thrown:

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)

I really have no idea what this exception is trying to tell me. And google does not know either. Can someone explain me what is going on here and how I could fix this?

KIC
  • 5,887
  • 7
  • 58
  • 98

1 Answers1

0

You can find the purpose of 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 ).

There is a related SO post which explains its meaning.

The source code for jblas is here so you should be able to step through it and figure out what is going on. Seems odd that on the line you get the exception (SimpleNative:247), LDA is set to 0 (as opposed to a value between 1 and k). I would recommend to open an issue on the jblas issue tracker.

Community
  • 1
  • 1
paul-g
  • 3,797
  • 2
  • 21
  • 36