source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/operators/nnz_internal.m @ 37

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

Added original make3d

File size: 1.1 KB
Line 
1function F = nnz_internal(z,x,direction)
2
3switch direction
4    case 0
5        [nx,mx] = size(x);
6        if issymmetric(x)
7            d = binvar(nx,nx);  % d == 1 means x(i,j) can be non-zero
8        else
9            d = binvar(nx,mx,'full');
10        end
11        x = reshape(x,nx*mx,1);
12        d = reshape(d,nx*mx,1);
13        [M,m] = derivebounds(x);
14        F = set(m.*d <= x <= M.*d) + set(z == sum(sum(d)));
15        F = F + set(0 <=z <= nx*mx);
16     
17    case 1
18        [nx,mx] = size(x);
19        if issymmetric(x)
20            du = binvar(nx,nx);  % du == 1 means x(i,j) > 0
21            dd = binvar(nx,nx);  % dd == 1 means x(i,j) < 0
22        else
23            du = binvar(nx,mx,'full');
24            dd = binvar(nx,mx,'full');
25        end
26        x = reshape(x,nx*mx,1);
27        du = reshape(du,nx*mx,1);
28        dd = reshape(dd,nx*mx,1);
29        [M,m] = derivebounds(x);
30        F = set(m.*(du+dd) <= x <= M.*(du+dd)) + set(sum([du dd],2) <= 1);
31        F = F + set(z == ((sum(du) + sum(dd))));
32        F = F + set(x > 1+(-1+m).*(1-du));
33        F = F + set(x < -1+(1+M).*(1-dd));
34        F = F + set(0 <= z <=nx*mx);
35    otherwise
36end
37
Note: See TracBrowser for help on using the repository browser.