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

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

Added original make3d

File size: 921 bytes
Line 
1function Z=clean(X,tol)
2%CLEAN Remove terms with small coefficients
3%
4% Z = clean(X,tol) removes all variables with a coefficient smaller than tol
5%
6%
7
8% Author Johan Löfberg
9% $Id: clean.m,v 1.9 2006/07/26 20:17:57 joloef Exp $ 
10
11if nargin==1
12    temp = any(X.basis,1);
13    temp = temp(2:end);
14    index = find(temp);
15else
16    X.basis(abs(X.basis)<tol)=0;
17    index = find(any(abs(X.basis(:,2:end))>tol,1));
18end
19if ~isempty(index)
20    Z = X;
21    if length(index)~=length(Z.lmi_variables)
22        Z.basis = Z.basis(:,[1 1+index]);
23        Z.lmi_variables = Z.lmi_variables(index);
24    end
25    if ~isreal(Z.basis) & nargin==2
26        basis_real = real(Z.basis);
27        basis_imag = imag(Z.basis);
28        basis_real(abs(basis_real)<tol) = 0;
29        basis_imag(abs(basis_imag)<tol) = 0;
30        Z.basis = basis_real + sqrt(-1)*basis_imag;
31    end       
32else
33    Z = full(reshape(X.basis(:,1),X.dim(1),X.dim(2)));
34end
Note: See TracBrowser for help on using the repository browser.