1% Product between a Gaussian covariance matrix and a vector. 2% 3% p = mtimescorr(xi,len,b) 4% 5% Compute the product between a Gaussian covariance with a length scale len and 6% grid points located in xi and the vector b. The covariance matrix has a unit 7% variance. 8 9function p = mtimescorr(xi,len,b) 10 11%'mat' 12m = size(xi,1); 13p = zeros(size(b)); 14 15% for j=1:m 16% for i=1:m 17% d2 = sum( (self.xi(i,:) - self.xi(j,:)).^2 ); 18% p(i) = p(i) + exp(-d2 / self.len^2) * b(j); 19% end 20% end 21% 22 23 24for i=1:m 25 X = repmat(xi(i,:),[m 1]); 26 d2 = sum( (X - xi).^2, 2) ; 27 ed = exp(-d2 / len^2); 28 p(i,:) = ed' * b; 29end 30 31% LocalWords: mtimescorr len 32 33% Copyright (C) 2014 Alexander Barth <a.barth@ulg.ac.be> 34% 35% This program is free software; you can redistribute it and/or modify it under 36% the terms of the GNU General Public License as published by the Free Software 37% Foundation; either version 2 of the License, or (at your option) any later 38% version. 39% 40% This program is distributed in the hope that it will be useful, but WITHOUT 41% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 42% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 43% details. 44% 45% You should have received a copy of the GNU General Public License along with 46% this program; if not, see <http://www.gnu.org/licenses/>. 47