0001 function slpwcomp_blks(X1, X2, ps, dstpath, compfunc, varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048 if nargin < 5
0049 raise_lackinput('slpwcomp_blks', 5);
0050 end
0051 if ~isnumeric(X1) || ndims(X1) ~= 2 || ~isnumeric(X2) || ndims(X2) ~= 2
0052 error('sltoolbox:invalidargs', ...
0053 'X1 and X2 should be 2D numeric matrices');
0054 end
0055 if ~isstruct(ps) || length(ps) ~= 2
0056 error('sltoolbox:invalidargs', ...
0057 'ps should be a struct array with 2 elements');
0058 end
0059
0060 n1 = size(X1, 2);
0061 n2 = size(X2, 2);
0062
0063 parstruct = ps;
0064 matsize = [n1, n2];
0065
0066 slignorevars(matsize);
0067
0068
0069
0070 blocks = slparblocks(parstruct);
0071 [nrows, ncols] = size(blocks);
0072 nblocks = nrows * ncols;
0073
0074
0075
0076 len1 = length(int2str(n1));
0077 len2 = length(int2str(n2));
0078
0079 dstcorepath = [dstpath, '.mat'];
0080 dstdir = slfilepart(dstpath, 'parent');
0081 dsttitle = slfilepart(dstpath, 'name');
0082 arrnamepat = sprintf('%s.c%%0%dd-%%0%dd.r%%0%dd-%%0%dd.arr', dsttitle, len1, len1, len2, len2);
0083
0084 data = cell(nrows, ncols);
0085 for i = 1 : nrows
0086 for j = 1 : ncols
0087 cb = blocks{i, j};
0088 data{i, j} = sprintf(arrnamepat, cb(1, 1), cb(2, 1), cb(1, 2), cb(2, 2));
0089 end
0090 end
0091
0092
0093
0094 if ~isempty(dstdir) && ~exist(dstdir, 'dir')
0095 mkdir(dstdir);
0096 end
0097
0098 for k = 1 : nblocks
0099 curblock = blocks{k};
0100 curpath = sladdpath(data{k}, dstdir);
0101
0102 curX1 = X1(:, curblock(1,1):curblock(2,1));
0103 curX2 = X2(:, curblock(1,2):curblock(2,2));
0104
0105 M = feval(compfunc, curX1, curX2, varargin{:});
0106
0107 slwritearray(M, curpath);
0108 end
0109
0110
0111 save(dstcorepath, 'parstruct', 'blocks', 'data', 'matsize', '-v6');
0112
0113