source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/@sdpvar/repmat.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 2.1 KB
Line 
1function Y=repmat(varargin)
2%REPMAT (overloaded)
3
4% Author Johan Löfberg
5% $Id: repmat.m,v 1.7 2006/07/26 20:17:58 joloef Exp $   
6
7try
8  X = varargin{1};
9  Y = X;
10  Y.basis = [];
11  n = Y.dim(1);
12  m = Y.dim(2);
13  for i = 1:length(Y.lmi_variables)+1
14    temp = repmatfixed(reshape(X.basis(:,i),n,m),varargin{2:end});
15    Y.basis(:,i) = temp(:);
16  end
17  Y.dim(1) = size(temp,1);
18  Y.dim(2) = size(temp,2);
19  % Reset info about conic terms
20  Y.conicinfo = [0 0];
21catch
22  error(lasterr)
23end
24
25
26
27function B = repmatfixed(A,M,N)
28
29if nargin < 2
30    error('MATLAB:repmat:NotEnoughInputs', 'Requires at least 2 inputs.')
31end
32
33if nargin == 2
34    if isscalar(M)
35        siz = [M M];
36    else
37        siz = M;
38    end
39else
40    siz = [M N];
41end
42
43if isscalar(A)
44    nelems = prod(siz);
45    if nelems>0
46        % Since B doesn't exist, the first statement creates a B with
47        % the right size and type.  Then use scalar expansion to
48        % fill the array. Finally reshape to the specified size.
49        B = spalloc(nelems,1,nnz(A));
50        B(nelems) = A;
51        if ~isequal(B(1), B(nelems)) | ~(isnumeric(A) | islogical(A))
52            % if B(1) is the same as B(nelems), then the default value filled in for
53            % B(1:end-1) is already A, so we don't need to waste time redoing
54            % this operation. (This optimizes the case that A is a scalar zero of
55            % some class.)
56            B(:) = A;
57        end
58        B = reshape(B,siz);
59    else
60        B = A(ones(siz));
61    end
62elseif ndims(A) == 2 & numel(siz) == 2
63    [m,n] = size(A);
64   
65    if (m == 1 & siz(2) == 1)
66        B = A(ones(siz(1), 1), :);
67    elseif (n == 1 & siz(1) == 1)
68        B = A(:, ones(siz(2), 1));
69    else
70        mind = (1:m)';
71        nind = (1:n)';
72        mind = mind(:,ones(1,siz(1)));
73        nind = nind(:,ones(1,siz(2)));
74        B = A(mind,nind);
75    end
76else
77    Asiz = size(A);
78    Asiz = [Asiz ones(1,length(siz)-length(Asiz))];
79    siz = [siz ones(1,length(Asiz)-length(siz))];
80    for i=length(Asiz):-1:1
81        ind = (1:Asiz(i))';
82        subs{i} = ind(:,ones(1,siz(i)));
83    end
84    B = A(subs{:});
85end
86
87function a = isscalar(b)
88[n,m] = size(b);
89a = (n*m == 1);
Note: See TracBrowser for help on using the repository browser.