Thu 30 Oct 2014 03:21:29 PM UTC, comment #4:
The division by zero warning is the title and focus of the bug report. This warning is only emitted for division by a scalar zero. Division by a vector or matrix that contains zero does not produce a warning, so there is no code change required.
The existing isfinite code catches any 0/0 divisions in a vector/matrix combination because this operation will produce NaN which is not finite.
For why scalar division produces a warning and vector does not you could ask on the Octave maintainers list. I suspect the answer is that checking a single scalar for being equal to zero is cheap, but checking an NxN matrix would require N^2 operations which would quickly grow cumbersome. Octave also probably just forwards on to BLAS any matrix/matrix or matrix/vector operations and BLAS does not emit a warning for division by zero since the result is defined as either Inf (value != 0) or NaN (0 / 0).
If you want to solve the different problem of actually preventing a division by zero entirely, you could search the y vector for non-zeros and then perform the Newton correction only on those entries. Benchmarking would be required to make sure this isn't slower.
As to why (2^12)^(1/6) does not equal exactly 4, that is probably running into precision issues because the numbers are so different in size. You can use eps() to see the machine precision for each number, and they differ by about 3 orders of magnitude.
On the other hand, when calculating 2^(log2(2^12)/6), you are dealing with the numbers 12 and 6 for which the machine precision is just about the same.
|