view general/numerical/safe_exp.m @ 4:e44f49929e56

Adding reorganised general toolbox, now in several subdirectories.
author samer
date Sat, 12 Jan 2013 19:21:22 +0000
parents
children
line wrap: on
line source
function [y,k]=safe_exp(x,l)
% safe_exp - high dynamic range exponential
%
% safe_exp :: X:[[N,M]] -> [[N,M]], [[1,M]].
%
% returns y and k such that exp(X) = y * exp(k) and
% maximum value in y is 1.

k=max(x,[],1);
y=exp(x-repmat(k,size(x,1),1));