source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/extras/@ncvar/exponents.m @ 37

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

Added original make3d

File size: 1.8 KB
Line 
1function [ML,list] = exponents(poly,x)
2%EXPONENTS Internal function to extract powers of nonlinear expression
3
4% Author Johan Löfberg
5% $Id: exponents.m,v 1.4 2006/08/30 14:11:14 joloef Exp $
6
7% HOrrible code for noncommuting change. Basically silly change of the
8% commuting case, should be written from scratch instead
9mt = yalmip('monomtable');
10nonCommutingTable = yalmip('nonCommutingTable');
11x_lin = getvariables(poly);
12
13x_var = getvariables(x);
14
15ML = 0*mt(x_lin,x_var);
16zero = 0;
17if any(full(poly.basis(:,1))) %any(ismember(1,poly))
18    ML = 0*[zeros(1,length(x));ML];
19    zero = 1;
20end
21
22list = [];
23for i = 1:length(x_lin)
24    variable = x_lin(i);
25    row = [];
26    if nnz(mt(variable,:)) == 0
27        % noncommuting term, start with the commuting scaling
28        if ~isnan(nonCommutingTable(variable,1))
29            scaling = nonCommutingTable(variable,1);
30            uses = find(mt(scaling,:));
31            for j = 1:length(uses)
32                if ismember(uses(j),x_var)
33                    row = [row repmat(uses(j),1,mt(scaling,uses(j)))];
34                end
35            end
36        end
37
38        row = [row nonCommutingTable(variable,2:end)];
39
40    else
41        uses = find(mt(variable,:));
42        for j = 1:length(uses)
43            if ismember(uses(j),x_var)
44                row = [row repmat(uses(j),1,mt(variable,uses(j)))];
45            end
46        end
47    end
48    if isempty(row)
49        row = 0;
50    end
51    row = row(find(row));
52    for j = 1:length(row)
53        if ismember(row(j),x_var)
54            row(j) = find(x_var == row(j));
55        else
56            row(j) = 0;
57        end
58    end
59    row = row(find(row));
60    list(end+1,1:length(row)) = row;
61end
62ML = zeros(size(list,1),length(x_var));
63for i = 1:size(list,1)
64    j = 1;
65    while j<= size(list,2) & list(i,j)
66        ML(i,list(i,j)) =  ML(i,list(i,j))+1;
67        j = j + 1;
68    end
69end
70
Note: See TracBrowser for help on using the repository browser.