home *** CD-ROM | disk | FTP | other *** search
- %SEE Pictures of a matrix and its (pseudo-) inverse.
- % SEE(A) displays MESH(A), MESH(PINV(A)), SEMILOGY(SVD(A),'o'),
- % and (if A is square) FV(A) in four subplot windows.
- % SEE(A, 1) plots an approximation to the pseudospectrum in the
- % third window instead of the singular values.
- % SEE(A, -1) plots only the eigenvalues in the fourth window,
- % which is much quicker than plotting the field of values.
- % If A is complex, only real parts are used for the mesh plots.
- % If A is sparse, just SPY(A) is shown.
-
- require pinv fv ps rot90
-
- see = function ( A, k )
- {
- local (A, k)
-
- if (!exist (k)) { k = 0; }
- m = A.nr; n = A.nc;
- square = (m == n);
-
- B = pinv (A);
- s = svd (A).sigma.';
- zs = find (s == zeros (size (s)));
- if (any( zs ))
- {
- % Remove zero singular values for semilogy plot.
- s = s [complement (zs, 1:s.n)];
- }
-
- if (length (ptmp = getplot ()) == 0)
- {
- pstart (2,2);
- else if (ptmp.nplot < 4) {
- error ("Create plot window with at least 4 sub-windows (pstart(2,2)).");
- } }
-
- plaxis (); plimits (); plegend ();
- Atmp = rot90 (A, -1);
- plmesh (<< x=1:Atmp.nr; y=1:Atmp.nc; z=real (Atmp) >>); # sub-plot 1
-
- plaxis (); plimits (); plegend ();
- Btmp = rot90 (B, -1);
- plmesh (<< x=1:Btmp.nr; y=1:Btmp.nc; z=real (Btmp) >>); # sub-plot 2
-
- clear (Atmp, Btmp);
-
- if (k <= 0)
- {
- plgrid ("bcnst", "bcnstlv");
- plstyle ("line-point");
- plegend ();
- plot (s); # sub-plot 3
-
- else if (k == 1) {
-
- ps (A); # sub-plot 3
-
- } }
-
- if (square)
- {
- if (k == -1)
- {
- ps (A, 0); # sub-plot 4
- else
- fv (A); # sub-plot 4
- }
- else
- printf ("Matrix not square.\n");
- }
-
- };
-