Skip to content
Snippets Groups Projects
Verified Commit ec904edb authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

The log method no longer errors out on non-positive values

For a zero, it returns -Inf.
For a negative number, it returns NaN.

This is not exactly the same behavior as MATLAB's log function, because we want
to enforce type stability (i.e. never return a complex).
parent b3fc74a2
No related branches found
No related tags found
No related merge requests found
......@@ -25,10 +25,6 @@ function o = log(o) % --*-- Unitary tests --*--
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if any(o.data<eps)
error('dseries:WrongInputArguments', 'Variables in %s have be strictly positive!', inputname(1))
end
o = copy(o);
o.log_;
......
......@@ -25,9 +25,8 @@ function o = log_(o) % --*-- Unitary tests --*--
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if any(o.data<eps)
error('dseries:WrongInputArguments', 'Variables in %s have be strictly positive!', inputname(1))
end
% Ensure that we never return a complex number (rather return a NaN)
o.data(find(o.data < 0)) = NaN;
o.data = log(o.data);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment