Dear Maintainer,
The routine DGEMV (with TRANS = 'N') is supposed to perform the
operation
y ← beta * y + alpha * A * x
where the matrix A has dimensions M×N. In particular, if N=0 (and M >
0), A * x is the null vector (all elements are given by sums on an
empty set of indices). Consequently, if N = 0, the operation should
be
y ← beta * y
and NOT leave y untouched. For your convenience, I have attached a
program demonstrating the latter (wrong) behavior.
severity 694625 normal thanks Bonjour Christophe! 1.0000000000000000 2.0000000000000000 What should I get ? 2 & 2 ? Thanks Sylvestre
Christophe TROESTLER <Christophe.Troestler@umons.ac.be> writes: I have tested the three BLAS implementations available in Debian (netlib BLAS, ATLAS and OpenBLAS), and they all give the same result (bad from your point of view). So I am not sure this is a bug. Maybe this is on purpose. If one considers this operation to be invalid (as I do), then it makes sense to do nothing. Does the documentation clearly states that BLAS supports operations on objects with one dimension equal to zero?
Sylvestre Ledru <sylvestre@debian.org> writes: Christophe is expecting 2 & 4 (Y=[1,2] and beta=2 in his example)
Salut Sylvestre ! 2. 4. (beta=2 in the code).
If the operation is considered invalid, then it should return an error
instead of doing nothing silently.
However, I insist that the operation is perfectly valid from a
mathematical point of view. Indeed, in mathematics, ∑_{i ∈ ∅} a_i = 0.
Therefore, A * x = 0 when A has dimensions M×0. This corner case is
also useful in practice. For a problem I have, I needed to compute
t ↦ f(t₀ y + ∑ t_i a_i)
where a_i are vectors and t_i real numbers. It so happens that in
some circumstances, the sum may be empty leading to a constant
function instead of the correct t ↦ f(t₀ y). A very bad surprise
IMHO, incoherent with the semantics of the operation.
Not the man pages. To the contrary, for N, the man page clearly
includes the possibility that N = 0:
N - INTEGER.
On entry, N specifies the number of columns of the matrix A. N
must be at least zero. Unchanged on exit.
Christophe TROESTLER <Christophe.Troestler@umons.ac.be> writes: I understand your point, though one could argue that an object of dimension M×0 is not a matrix. Indeed, Octave for example handles well these corner cases. Yes indeed. However it does not tell what it does in that case, though I agree with you that doing y=beta*y would seem logical. Do you have examples of other BLAS functions which handle null-dimensions as you would expect?