Some of the reduction functions have inconsistent handling of empty matrices. They also differ slightly to how Matlab handles it. The function I have looked at are sum, sumsq, prod and dot but it might hold true for other reduction functions as well.
Both sum and prod have the convention that the empty matrix returns the unit, i.e.
But this does not hold true for dot
I think it would be more natural for dot to also return 0 here. This is also how Matlab does it
Further I noticed that Matlab and Octave handles the empty matrix differently when a dimension is specified. In Octave we have
Looking at the code for Octaves reduction function we in fact have a explicit conversion from [] to a matrix of size 1x0 (commented as an inconsistency). In Matlab we instead have
When no dimension is specified it handles the empty matrix in a special way. But when a dimension is specified it handles it like any other matrix.
|