Rev | Line | |
---|
[37] | 1 | function s = logmulexp(a,b)
|
---|
| 2 | %LOGMULEXP Matrix multiply in the log domain.
|
---|
| 3 | % logmulexp(a,b) returns log(exp(a)*exp(b)) while avoiding numerical underflow.
|
---|
| 4 | % The * is matrix multiplication.
|
---|
| 5 |
|
---|
| 6 | % Written by Tom Minka
|
---|
| 7 | % (c) Microsoft Corporation. All rights reserved.
|
---|
| 8 |
|
---|
| 9 | s = repmat(a,cols(b),1) + kron(b',ones(rows(a),1));
|
---|
| 10 | s = reshape(logsumexp(s,2),rows(a),cols(b));
|
---|
| 11 |
|
---|
| 12 | %s = kron(a',ones(1,cols(b))) + repmat(b,1,rows(a));
|
---|
| 13 | %s = reshape(logsumexp(s),cols(b),rows(a))';
|
---|
Note: See
TracBrowser
for help on using the repository browser.