annotate 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 |
|
rev |
line source |
samer@4
|
1 function [y,k]=safe_exp(x,l)
|
samer@4
|
2 % safe_exp - high dynamic range exponential
|
samer@4
|
3 %
|
samer@4
|
4 % safe_exp :: X:[[N,M]] -> [[N,M]], [[1,M]].
|
samer@4
|
5 %
|
samer@4
|
6 % returns y and k such that exp(X) = y * exp(k) and
|
samer@4
|
7 % maximum value in y is 1.
|
samer@4
|
8
|
samer@4
|
9 k=max(x,[],1);
|
samer@4
|
10 y=exp(x-repmat(k,size(x,1),1));
|
samer@4
|
11
|