annotate general/numerical/scalar/safe_exp2.m @ 61:eff6bddf82e3
tip
Finally implemented perceptual brightness thing.
author |
samer |
date |
Sun, 11 Oct 2015 10:20:42 +0100 |
parents |
cb249ba61e9e |
children |
|
rev |
line source |
samer@17
|
1 function [y,k]=safe_exp2(x,l)
|
samer@17
|
2 % safe_exp2 - high dynamic range exponential
|
samer@17
|
3 %
|
samer@17
|
4 % safe_exp2 :: X:[[N,M]], L:real -> [[N,M]], [[1,M]].
|
samer@17
|
5 %
|
samer@17
|
6 % returns y and k such that exp(X) = y * exp(k) and
|
samer@17
|
7 % maximum value in y is exp(L).
|
samer@17
|
8 % Maximum sensible value of L is log(realmax)=709.78.
|
samer@17
|
9
|
samer@17
|
10 k=max(x,[],1)-l;
|
samer@17
|
11 y=exp(x-repmat(k,size(x,1),1));
|