Rev | Line | |
---|
[37] | 1 | function plin = linearize(p) |
---|
| 2 | % LINEARIZE Linearize SDPVAR object |
---|
| 3 | % |
---|
| 4 | % h = LINEARIZE(p) |
---|
| 5 | % |
---|
| 6 | % Returns linearization p(double(x)) + dp(double(x))*(x-double(x)) |
---|
| 7 | % where x is the SDPVAR variables defining the polynomial p(x) |
---|
| 8 | % |
---|
| 9 | % See also SDPVAR, JACOBIAN |
---|
| 10 | |
---|
| 11 | % Author Johan Löfberg |
---|
| 12 | % $Id: linearize.m,v 1.2 2004/07/02 08:17:31 johanl Exp $ |
---|
| 13 | |
---|
| 14 | if isa(p,'double') |
---|
| 15 | plin = zeros(size(p)); |
---|
| 16 | return |
---|
| 17 | end |
---|
| 18 | |
---|
| 19 | if is(p,'linear') |
---|
| 20 | plin = p; |
---|
| 21 | return |
---|
| 22 | end |
---|
| 23 | |
---|
| 24 | x = recover(depends(p)); |
---|
| 25 | x0 = double(x); |
---|
| 26 | p0 = double(p); |
---|
| 27 | |
---|
| 28 | n = size(p,1); |
---|
| 29 | m = size(p,2); |
---|
| 30 | |
---|
| 31 | if min(n,m)>1 |
---|
| 32 | plin = []; |
---|
| 33 | for i = 1:m |
---|
| 34 | plin = [plin p0(:,i)+double(jacobian(p(:,i),x))*(x-x0)]; |
---|
| 35 | end |
---|
| 36 | else |
---|
| 37 | plin = p0+double(jacobian(p,x))*(x-x0); |
---|
| 38 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.