Add warning about max() and NaN authored by Sébastien Villemot's avatar Sébastien Villemot
......@@ -69,6 +69,10 @@ You should add the following notice in your files, just after the help text, but
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
```
## Computation of infinite norm
Contrary to most operators, `max` does not propagate NaN (*e.g.* `max([1 2 NaN])` returns `2`). As a consequence, using `max(abs(…))` to compute the infinite norm of a vector can lead to unexpected results and subtle bugs. The use of `norm(…, 'Inf')` should be preferred for that reason. Similarly, `max(max(abs(A)))` can be replaced by `norm(vec(A), 'Inf')`.
## Short-circuit versus Element-wise logical AND/OR
The Short-circuit logical AND/OR (*i.e.* `&&`, `||`), returns `true` or `false`, depending on whether an entire expression evaluates to true or false. It returns this value as soon as it is known. On the other hand, the Element-wise AND/OR (*i.e.* `&`, `|`) returns a logical array of the compared values. Even though MATLAB and Octave substitutes in short-circuit functionality when an element-wise AND/OR is encountered in an `if` or `while` statement, Octave issues a warning every time this situation is encountered. Hence, in Dynare, all conditional statements should make use of the short-circuit logical AND and OR.
......
......