annotate scripts/linear-algebra/logm.m @ 5307:4c8a2e4e0717

[project @ 2005-04-26 19:24:27 by jwe]
author jwe
date Tue, 26 Apr 2005 19:24:47 +0000
parents 764229f9a5c8
children 34f96dd5441b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4334
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
1 ## Copyright (C) 2003 John W. Eaton
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 ##
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
6 ## it under the terms of the GNU General Public License as published by
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
7 ## the Free Software Foundation; either version 2, or (at your option)
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
8 ## any later version.
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
5307
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 4334
diff changeset
16 ## along with Octave; see the file COPYING. If not, write to the Free
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 4334
diff changeset
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 4334
diff changeset
18 ## 02110-1301, USA.
4334
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
19
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
20 ## -*- texinfo -*-
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
21 ## @deftypefn {Function File} {} logm (@var{a})
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
22 ## 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
23 ## 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
24 ## needs to be improved to be more robust.
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
25 ## @end deftypefn
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
26
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
27 function B = logm (A)
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
28
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
29 if (nargin != 1)
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
30 usage ("B = logm (A)");
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
31 endif
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
32
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
33 [V, D] = eig (A);
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
34 B = V * diag (log (diag (D))) * inv (V);
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
35
764229f9a5c8 [project @ 2003-02-19 06:24:02 by jwe]
jwe
parents:
diff changeset
36 endfunction