annotate scripts/linear-algebra/logm.m @ 7017:a1dbe9d80eee

[project @ 2007-10-12 21:27:11 by jwe]
author jwe
date Fri, 12 Oct 2007 21:27:37 +0000
parents 93c65f2a5668
children cace99cb01ab
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
1 ## Copyright (C) 2003, 2005, 2006, 2007 John W. Eaton
4334
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
2 ##
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
4 ##
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
6 ## under the terms of the GNU General Public License as published by
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
8 ## your option) any later version.
4334
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
9 ##
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
14 ##
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
17 ## <http://www.gnu.org/licenses/>.
4334
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
18
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
20 ## @deftypefn {Function File} {} logm (@var{a})
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
21 ## Compute the matrix logarithm of the square matrix @var{a}. Note that
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
22 ## this is currently implemented in terms of an eigenvalue expansion and
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
23 ## needs to be improved to be more robust.
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
24 ## @end deftypefn
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
25
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
26 function B = logm (A)
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
27
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
28 if (nargin != 1)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5307
diff changeset
29 print_usage ();
4334
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
30 endif
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
31
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
32 [V, D] = eig (A);
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
33 B = V * diag (log (diag (D))) * inv (V);
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
34
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
35 endfunction