home *** CD-ROM | disk | FTP | other *** search
- //-----------------------------------------------------------------
- //
- // dlyap
- //
- // Syntax: x=dlyap(Ad,Cd)
- //
- // This routine solves the Discrete Lyapunov Equation. Calling
- // the routine as,
- //
- // X=dlyap(A,C)
- //
- // returns X, which is the solution to the following
- // discrete Lyapunov Equation.
- //
- // A*X*A' + C = X
- //
- // Copyright (C), by Jeffrey B. Layton, 1994
- // Version JBL 940918
- //-----------------------------------------------------------------
-
- rfile lyap
-
- dlyap = function(Ad,Cd)
- {
- local(nargs,n,Ac,Cc,X)
-
- // Count number of input arguments
- nargs=0;
- if (exist(Ad)) {nargs=nargs+1;}
- if (exist(Cd)) {nargs=nargs+1;}
-
- if (nargs < 2) {
- error("DLYAP: Wrong number of input arguments.");
- }
-
- // Define dimensions
- n=Ad.nr;
-
- // Convert discrete to continuous
- Ac=solve((Ad+eye(n,n)),(Ad-eye(n,n)));
- Cc=((eye(n,n)-Ad)*Cd*(eye(n,n)-Ad'))/2.0;
-
- // Call continuous lyapunov solver to solve problem.
- X=lyap(Ac,Cc);
-
- return X
- };
-