source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/@sdpvar/det.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 d = det(X)
2%DET (overloaded)
3
4% Author Johan Löfberg
5% $Id: det.m,v 1.4 2006/07/26 20:17:57 joloef Exp $ 
6
7n = X.dim(1);
8m = X.dim(2);
9
10if n~=m
11    error('Matrix must be square.');
12else
13    switch n
14        case 1
15            d = X;
16        case 2
17            % Freakin overloading on multiplication doesn't work. Probalby
18            % stupid code...
19            Y1.type = '()';
20            Y2.type = '()';
21            Y3.type = '()';
22            Y4.type = '()';
23            Y1.subs = {1,1};
24            Y2.subs = {2,2};
25            Y3.subs = {1,2};
26            Y4.subs = {2,1};
27            d = subsref(X,Y1)*subsref(X,Y2)-subsref(X,Y3)*subsref(X,Y4);
28        otherwise
29            d = 0;
30            Y.type = '()';
31            for i = 1:n   
32                Y.subs = {i,1};
33                xi = subsref(X,Y);
34                if ~isequal(xi,0)
35                    Y.subs = {[1:1:i-1 i+1:1:n],2:n};
36                    subX = subsref(X,Y);
37                    d = d + (-1)^(i+1)*xi*det(subX);
38                end
39            end
40    end
41end
42% Reset info about conic terms
43d.conicinfo = [0 0];
Note: See TracBrowser for help on using the repository browser.