Changeset 356 for trunk/src/tps_eval.m


Ignore:
Timestamp:
Jan 3, 2012, 12:58:52 AM (12 years ago)
Author:
sommeria
Message:

civ updated with new functions for opening files, consistently with uvmat
Bugs to be expected (use previous version then)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tps_eval.m

    r273 r356  
    1 %   EM:     MxN matrix whose i,j position contains the Euclidean
    2 %              distance between the i-th data site and j-th center
    3   function EM = tps_eval(dsites,ctrs)
    4   [M,s] = size(dsites); [N,s] = size(ctrs);
    5   EM = zeros(M,N);
    6  
    7   % calculate distance matrix: accumulate sum of squares of coordinate differences
    8   % The ndgrid command produces two MxN matrices:
    9   %   Dsite, consisting of N identical columns (each containing
    10   %       the d-th coordinate of the M data sites)
    11   %   Ctrs, consisting of M identical rows (each containing
    12   %       the d-th coordinate of the N centers)
    13   for d=1:s
    14      [Dsites,Ctrs] = ndgrid(dsites(:,d),ctrs(:,d));
    15      EM = EM + (Dsites-Ctrs).^2;%EM=square of distance matrices
    16   end
     1%'tps_eval': calculate the thin plate spline (tps) interpolation at a set of points
     2% see tps_ceff for more information
     3%------------------------------------------------------------------------
     4% function EM = tps_eval(dsites,ctrs)
     5%------------------------------------------------------------------------
     6% OUPUT:
     7% EM:  Mx(N+s) matrix representing the contributions at the M sites
     8%   from unit sources located at each of the N centers, + (s+1) columns
     9%   representing the contribution of the linear gradient part.
     10%
     11%INPUT:
     12%dsites:  Nxs matrix representing the postions of the N 'observation' sites, with s the space dimension
     13%ctrs: Mxs matrix  representing the postions of the M centers, sources of the tps,
     14%
     15% related functions:
     16% tps_coeff, tps_eval_dxy
    1717
    18   % calculate tps
    19   np=find(EM~=0);
    20   EM(np) = EM(np).*log(EM(np))/2;%= tps formula r^2 log(r) (EM=r^2)
    21  
    22   % add linear gradient part:
    23   EM = [EM ones(M,1) dsites];
     18function EM = tps_eval(dsites,ctrs)
     19[M,s] = size(dsites); [N,s] = size(ctrs);
     20EM = zeros(M,N);
     21
     22% calculate distance matrix: accumulate sum of squares of coordinate differences
     23% The ndgrid command produces two MxN matrices:
     24%   Dsite, consisting of N identical columns (each containing
     25%       the d-th coordinate of the M data sites)
     26%   Ctrs, consisting of M identical rows (each containing
     27%       the d-th coordinate of the N centers)
     28for d=1:s
     29 [Dsites,Ctrs] = ndgrid(dsites(:,d),ctrs(:,d));
     30 EM = EM + (Dsites-Ctrs).^2;%EM=square of distance matrices
     31end
     32
     33% calculate tps
     34np=find(EM~=0);
     35EM(np) = EM(np).*log(EM(np))/2;%= tps formula r^2 log(r) (EM=r^2)
     36
     37% add linear gradient part:
     38EM = [EM ones(M,1) dsites];
Note: See TracChangeset for help on using the changeset viewer.