Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gemv with empty vector #37

Closed
nilsbecker opened this issue Dec 14, 2017 · 2 comments
Closed

gemv with empty vector #37

nilsbecker opened this issue Dec 14, 2017 · 2 comments

Comments

@nilsbecker
Copy link

nilsbecker commented Dec 14, 2017

this is similar to the last issue but i think it may be an actual bug so opened a new issue:

let a = Mat.create 2 0
let v = Vec.create 0
let w = gemv a v
let d = Vec.dim w

here, i get 2, and w is a vector with uninitialized entries. this seems wrong?

i would argue that actually a vector 0. 0. would be the mathematically correct result. each entry of the result vector w is the scalar product of the corresponding row vector of the input matrix aand the input vector v. since these have length 0, the scalar product is an empty sum and should be 0.

alternatively one may argue that empty inputs are pathological. then it would make sense to raise an exception, similar to what gemv already does.

right now, it's not ideal that a nonsensical result is actually returned, in my opinion. if this is what lapack does, maybe one should protect the user from lapack here?

(edit: nonsense removal)

@nilsbecker
Copy link
Author

i guess the lapack logic is "empty scalar product => we do nothing to the allocated output memory". from a CS perspective that kind of makes sense. still i find it a bit of a trap.

@mmottl
Copy link
Owner

mmottl commented Dec 14, 2017

This is related to #22. BLAS/LAPACK sadly does not handle such corner cases in a mathematically appealing way. It would seem excessive to try to work around these issues, which are probably frequent in BLAS/LAPACK. Users should avoid passing values with degenerate dimensionality or zero operation sizes to BLAS/LAPACK to avoid triggering unexpected behavior. User code should check for degenerate conditions and either raise exceptions or provide explicit workarounds for these cases.

@mmottl mmottl closed this as completed Dec 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants