gonum/lapack

cgo: Dormqr comment not in sync with reality

vladimir-ch opened this issue · 5 comments

The comment says:

// ... lwork == -1 will not run Dormqr but will instead write the minimum
// work necessary to work[0]. If len(work) < lwork, Dormqr will panic.

The code does:

        if lwork == -1 {
                 if left {
                         work[0] = float64(m)
                         return
                 }
                 work[0] = float64(n)
                 return
         }

         if left {
                 if lwork < n {
                         panic(badWork)
                 }
         } else {
                 if lwork < m {
                         panic(badWork)
                 }
         }

That is,

  1. Values put into work[0] and checked values of lwork seem to be swapped.
  2. len(work) < lwork is not checked.
  1. I can't see where this is happening. The code I have in front of me assigns a f(n) to work[0] when left and a f(m) to work[0] otherwise.
  2. This happens in subordinate calls AFAICS, but it might be worth hoisting it higher up the call chain.

I'm referring to cgo.

Sorry.

This happens in subordinate calls AFAICS, but it might be worth hoisting it higher up the call chain.

I think it would be worth it.

I'll send a PR in a sec that addresses both of these things.