📄 tiling_get.m
字号:
function [v, i, j] = tiling_get(xdata, wdata, tdim, x, i)
% TILING_GET Computes value of input x in tiling with given prefix
% [V, I] = TILING_GET(XDATA, WDATA, TDIM, X)
% Parameters:
% xdata - tile grid data
% wdata - tiling weight data
% tdim - tiling dimensionality info
% x - the input vector. I can contain only the continuous components, in
% which case the values of all the discrete inputs are returned in an array. It can
% contain the complete input, in which case the value of the given discrete input are
% returned in a scalar.
% i - (optional) indices of tiles which fire for x.
% If these indices are already available, supply them for speed. If these indices are
% supplied, the value of the continuous inputs is ignored.
% Returns:
% v - the value of the complete input x, or the values of all discrete input
% combinations for the continuous input part x, depending on how x is specified
% i - flat indices of the tiles fired by the input
% j - flat indices of discrete input components which were retrieved. 1 if no
% discrete components exist.
if nargin < 5,
% construct d+1 dimensional indices for the tiles in the c = tdim(1) tilings
ii = zeros(tdim.c, tdim.cdim + 1);
ii(:, 1) = 1:tdim.c; % 1:c on the first column
% for each input component,
for di = 1:tdim.cdim,
% compute the indices of fired tiles in its tilings
ii(:, di+1) = sum(xdata{di} <= x(di), 2);
end;
i = ndi2lin(ii, tdim.tsize);
end;
if isempty(tdim.dsize), % efficient return if no discrete comp
v = sum(wdata(i)) / tdim.c;
return;
end;
xd = x(tdim.cdim + 1:end); % discrete inputs (identified with indices), if any
if isempty(xd), % return for all discrete combinations
v = sum(wdata(i, :));
if tdim.ddim > 1, v = reshape(v, tdim.dsize); end;
else % return for discrete input only
j = ndi2lin(xd, tdim.dsize);
v = sum(wdata(i, j));
end;
v = v / tdim.c;
% === END tiling_get, RETURNING v, i, j ======================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -