annotate doc/interpreter/diagperm.txi @ 8839:fcba62cc4549

add chapter about diagonal and permutation matrices to manual
author Jaroslav Hajek <highegg@gmail.com>
date Mon, 23 Feb 2009 13:55:44 +0100
parents
children d6de39523f03
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8839
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
1 @c Copyright (C) 2009 Jaroslav Hajek
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
2 @c
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
3 @c This file is part of Octave.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
4 @c
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
5 @c Octave is free software; you can redistribute it and/or modify it
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
6 @c under the terms of the GNU General Public License as published by the
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
7 @c Free Software Foundation; either version 3 of the License, or (at
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
8 @c your option) any later version.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
9 @c
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
10 @c Octave is distributed in the hope that it will be useful, but WITHOUT
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
11 @c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
12 @c FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
13 @c for more details.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
14 @c
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
15 @c You should have received a copy of the GNU General Public License
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
16 @c along with Octave; see the file COPYING. If not, see
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
17 @c <http://www.gnu.org/licenses/>.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
18
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
19 @ifhtml
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
20 @set htmltex
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
21 @end ifhtml
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
22 @iftex
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
23 @set htmltex
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
24 @end iftex
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
25
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
26 @node Diagonal and Permutation Matrices
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
27 @chapter Diagonal and Permutation Matrices
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
28
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
29 @menu
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
30 * Basic Usage:: Creation and Manipulation of Diagonal and Permutation Matrices
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
31 * Matrix Algebra:: Linear Algebra with Diagonal and Permutation Matrices
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
32 * Function Support:: Functions That Are Aware of These Matrices
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
33 * Example Codes:: Some Examples of Usage
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
34 * Zeros Treatment:: The Differences in Treatment of Zero Elements
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
35 @end menu
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
36
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
37 @node Basic Usage
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
38 @section The Creation and Manipulation of Diagonal and Permutation Matrices
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
39
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
40 A diagonal matrix is defined as a matrix that has zero entries outside the main diagonal;
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
41 that is, @code{D(i,j) == 0} if @code{i != j}.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
42 Most often, square diagonal matrices are considered; however, the definition can equally
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
43 be applied to nonsquare matrices, in which case we usually speak of a rectangular diagonal
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
44 matrix. For more information, see @url{http://en.wikipedia.org/wiki/Diagonal_matrix}.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
45
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
46 A permutation matrix is defined as a square matrix that has a single element equal to unity
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
47 in each row and each column; all other elements are zero. That is, there exists a
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
48 permutation (vector) @code{p} such that @code{P(i,j) == 1} if @code{j == p(i)} and
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
49 @code{P(i,j) == 0} otherwise. For more information, see
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
50 @url{http://en.wikipedia.org/wiki/Permutation_matrix}.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
51
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
52 Octave provides special treatment of real and complex rectangular diagonal matrices,
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
53 as well as permutation matrices. They are stored as special objects, using efficient
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
54 storage and algorithms, facilitating writing both readable and efficient matrix algebra
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
55 expressions in the Octave language.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
56
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
57 @menu
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
58 * Creating Diagonal Matrices::
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
59 * Creating Permutation Matrices::
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
60 * Explicit and Implicit Conversions::
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
61 @end menu
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
62
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
63 @node Creating Diagonal Matrices
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
64 @subsection Creating Diagonal Matrices
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
65
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
66 The most common and easiest way to create a diagonal matrix is using the built-in
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
67 function @dfn{diag}. The expression @code{diag (@var{v})}, with @var{v} a vector,
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
68 will create a square diagonal matrix with elements on the main diagonal given
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
69 by the elements of @var{v}, and size equal to the length of @var{v}.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
70 @code{diag (@var{v}, m, n)} can be used to construct a rectangular diagonal matrix.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
71 The result of these expressions will be a special diagonal matrix object, rather
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
72 than a general matrix object.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
73
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
74 Some other built-in functions can also return diagonal matrices. Examples include
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
75 @dfn{balance} or @dfn{inv}.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
76
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
77 @DOCSTRING(diag)
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
78
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
79 @node Creating Permutation Matrices
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
80 @subsection Creating Permutation Matrices
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
81
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
82 For creating permutation matrices, Octave does not introduce a new function, but
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
83 rather overrides an existing syntax. That is, if @var{q} is a permutation vector
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
84 of length @var{n}, the expression
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
85 @example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
86 @var{P} = eye (@var{n}) (:, @var{q});
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
87 @end example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
88 will create a permutation matrix - a special matrix object.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
89 @example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
90 eye (@var{n}) (@var{q}, :)
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
91 @end example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
92 will also work (a row permutation matrix), as well as
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
93 @example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
94 eye (@var{n}) (@var{q1}, @var{q2}).
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
95 @end example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
96 Note that the identity, @code{eye (@var{n})}, is a diagonal matrix by definition,
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
97 but should work in any place where a permutation matrix is requested.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
98
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
99 Some other built-in functions can also return permutation matrices. Examples include
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
100 @dfn{inv} or @dfn{lu}.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
101
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
102 @node Explicit and Implicit Conversions
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
103 @subsection Explicit and Implicit Conversions
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
104
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
105 The diagonal and permutation matrices are special objects in their own right. A number
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
106 of operations and built-in functions, are defined for these matrices to use special,
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
107 more efficient code than would be used for a full matrix in the same place. Examples
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
108 are given in further sections.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
109
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
110 To facilitate smooth mixing with full matrices, backward compatibility, and
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
111 compatibility with Matlab, the diagonal and permutation matrices should allow
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
112 any operation that works on full matrices, and will either treat is specially,
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
113 or implicitly convert themselves to full matrices.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
114
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
115 Instances include matrix indexing (except for extracting a single element),
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
116 indexed assignment, or applying most mapper functions, such as @dfn{exp}.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
117
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
118 An explicit conversion to a full matrix can be requested using the built-in
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
119 function @dfn{full}. It should also be noted that the diagonal and permutation
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
120 matrix objects will cache the result of the conversion after it is first
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
121 requested (explicitly or implicitly), so that subsequent conversions will
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
122 be very cheap.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
123
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
124 @node Matrix Algebra
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
125 @section Linear Algebra with Diagonal and Permutation Matrices
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
126
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
127 As has been already said, diagonal and permutation matrices make it
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
128 possible to use efficient algorithms while preserving natural linear
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
129 algebra syntax. This section describes in detail the operations that
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
130 are treated specially when performed on these special matrix objects.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
131
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
132 @menu
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
133 * Expressions Involving Diagonal Matrices::
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
134 * Expressions Involving Permutation Matrices::
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
135 @end menu
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
136
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
137 @node Expressions Involving Diagonal Matrices
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
138 @subsection Expressions Involving Diagonal Matrices
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
139
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
140 Assume @var{D} is a diagonal matrix. If @var{M} is a full matrix,
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
141 then @code{@var{D}*@var{M}} will scale the rows of @var{M}. That means,
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
142 if @code{@var{S} = @var{D}*@var{M}}, then for each pair of indices
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
143 i,j it holds
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
144 @example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
145 S(i,j) = D(i,i) * M(i,j).
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
146 @end example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
147 Similarly, @code{M*D} will do a column scaling.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
148
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
149 The matrix @var{D} may also be rectangular, m-by-n where @code{m != n}.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
150 If @code{m < n}, then the expression @code{D*M} is equivalent to
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
151 @example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
152 D(:,1:m) * M(1:m,:),
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
153 @end example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
154 i.e. trailing @code{n-m} rows of @var{M} are ignored. If @code{m > n},
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
155 then @code{D*M} is equivalent to
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
156 @example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
157 [D(1:n,n) * M; zeros(m-n, columns (M))],
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
158 @end example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
159 i.e. null rows are appended to the result.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
160 The situation for right-multiplication @code{M*D} is analogous.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
161
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
162 The expressions @code{D \ M} and @code{M / D} perform inverse scaling.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
163 They are equivalent to solving a diagonal (or rectangular diagonal)
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
164 in a least-squares minimum-norm sense. In exact arithmetics, this is
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
165 equivalent to multiplying by a pseudoinverse. The pseudoinverse of
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
166 a rectangular diagonal matrix is again a rectangular diagonal matrix
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
167 of the same dimensions, where each nonzero diagonal element is replaced
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
168 by its reciprocal.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
169 The matrix division algorithms do, in fact, use division rather than
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
170 multiplication by reciprocals for better numerical accuracy; otherwise, they
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
171 honor the above definition. Note that a diagonal matrix is never truncated due
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
172 to ill-conditioning; otherwise, it would not be much useful for scaling. This
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
173 is typically consistent with linear algebra needs. A full matrix that only
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
174 happens to be diagonal (an is thus not a special object) is of course treated
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
175 normally.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
176
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
177 If @var{D1} and @var{D2} are both diagonal matrices, then the expressions
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
178 @example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
179 @var{D1} + @var{D2}
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
180 @var{D1} - @var{D2}
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
181 @var{D1} * @var{D2}
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
182 @var{D1} / @var{D2}
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
183 @var{D1} \ @var{D2}
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
184 @end example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
185 again produce diagonal matrices, provided that normal
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
186 dimension matching rules are obeyed. The relations used are same as described above.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
187
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
188 Also, a diagonal matrix @var{D} can be multiplied or divided by a scalar, or raised
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
189 to a scalar power if it is square, producing diagonal matrix result in all cases.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
190
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
191 A diagonal matrix can also be transposed or conjugate-transposed, giving the expected
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
192 result. Extracting a leading submatrix of a diagonal matrix, i.e. @code{@var{D}(1:m,1:n)},
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
193 will produce a diagonal matrix, other indexing expressions will implicitly convert to
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
194 full matrix.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
195
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
196 When involved in expressions with the element-by-element operators @code{.*},
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
197 @code{./}, @code{.\} or @code{.^}, an implicit conversion to full matrix will
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
198 also take place. This is not always strictly necessary but chosen to facilitate
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
199 better consistency with Matlab.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
200
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
201 @node Expressions Involving Permutation Matrices
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
202 @subsection Expressions Involving Permutation Matrices
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
203
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
204 If @var{P} is a permutation matrix and @var{M} a matrix, the expression
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
205 @code{P*M} will permute the rows of @var{M}. Similarly, @code{M*P} will
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
206 yield a column permutation.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
207 Matrix division @code{P\M} and @code{M/P} can be used to do inverse permutation.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
208
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
209 The previously described syntax for creating permutation matrices can actually
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
210 help an user to understand the connection between a permutation matrix and
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
211 a permuting vector. Namely, the following holds, where @code{I = eye (n)}
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
212 is an identity matrix:
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
213 @example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
214 I(p,:) * M = (I*M) (p,:) = M(p,:)
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
215 @end example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
216 Similarly,
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
217 @example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
218 M * I(:,p) = (M*I) (:,p) = M(:,p)
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
219 @end example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
220
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
221 The expressions @code{I(p,:)} and @code{I(:,p)} are permutation matrices.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
222
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
223 A permutation matrix can be transposed (or conjugate-transposed, which is the
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
224 same, because a permutation matrix is never complex), inverting the
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
225 permutation, or equivalently, turning a row-permutation matrix into a
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
226 column-permutation one. For permutation matrices, transpose is equivalent to
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
227 inversion, thus @code{P\M} is equivalent to @code{P'*M}. Transpose of a
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
228 permutation matrix (or inverse) is a constant-time operation, flipping only a
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
229 flag internally, and thus the choice between the two above equivalent
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
230 expressions for inverse permuting is completely up to the user's taste.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
231
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
232 Two permutation matrices can be multiplied or divided (if their sizes match), performing
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
233 a composition of permutations. Also a permutation matrix can be indexed by a permutation
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
234 vector (or two vectors), giving again a permutation matrix.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
235 Any other operations do not generally yield a permutation matrix and will thus
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
236 trigger the implicit conversion.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
237
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
238 @node Function Support
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
239 @section Functions That Are Aware of These Matrices
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
240
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
241 This section lists the built-in functions that are aware of diagonal and
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
242 permutation matrices on input, or can return them as output. Passed to other
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
243 functions, these matrices will in general trigger an implicit conversion.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
244 (Of course, user-defined dynamically linked functions may also work with
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
245 diagonal or permutation matrices).
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
246
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
247 @menu
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
248 * Diagonal Matrix Functions::
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
249 * Permutation Matrix Functions::
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
250 @end menu
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
251
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
252 @node Diagonal Matrix Functions
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
253 @subsection Diagonal Matrix Functions
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
254
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
255 @dfn{inv} and @dfn{pinv} can be applied to a diagonal matrix, yielding again
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
256 a diagonal matrix. @dfn{det} will use an efficient straightforward calculation
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
257 when given a diagonal matrix, as well as @dfn{cond}.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
258 The following mapper functions can be applied to a diagonal matrix
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
259 without converting it to a full one:
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
260 @dfn{abs}, @dfn{real}, @dfn{imag}, @dfn{conj}, @dfn{sqrt}.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
261 A diagonal matrix can also be returned from the @dfn{balance}
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
262 and @dfn{svd} functions.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
263
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
264 @node Permutation Matrix Functions
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
265 @subsection Permutation Matrix Functions
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
266
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
267 @dfn{inv} and @dfn{pinv} will invert a permutation matrix, preserving its
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
268 specialness. @dfn{det} can be applied to a permutation matrix, efficiently
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
269 calculating the sign of the permutation (which is equal to the determinant).
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
270
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
271 A permutation matrix can also be returned from the built-in functions
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
272 @dfn{lu} and @dfn{qr}, if a pivoted factorization is requested.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
273
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
274 @node Example Codes
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
275 @section Some Examples of Usage
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
276
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
277 The following can be used to solve a linear system @code{A*x = b}
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
278 using the pivoted LU factorization:
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
279 @example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
280 [L, U, P] = lu (A); ## now L*U = P*A
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
281 x = U \ L \ P*b;
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
282 @end example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
283
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
284 This is how you normalize columns of a matrix @var{X} to unit norm:
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
285 @example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
286 s = norm (X, "columns");
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
287 X = diag (s) \ X;
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
288 @end example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
289
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
290 The following expression is a way to efficiently calculate the sign of a
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
291 permutation, given by a permutation vector @var{p}. It will also work
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
292 in earlier versions of Octave, but slowly.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
293 @example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
294 det (eye (length (p))(p, :))
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
295 @end example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
296
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
297 Finally, here's how you solve a linear system @code{A*x = b}
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
298 with Tikhonov regularization using SVD (a skeleton only):
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
299 @example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
300 m = rows (A); n = columns (A);
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
301 [U, S, V] = svd (A);
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
302 ## determine the regularization factor alpha
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
303 ## ...
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
304 ## and solve
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
305 x = U'*b;
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
306 x = (S + alpha*eye (m, n)) \ x; ## this will be very efficient
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
307 x = V*x;
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
308 @end example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
309
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
310 @node Zeros Treatment
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
311 @section The Differences in Treatment of Zero Elements
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
312
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
313 Making diagonal and permutation matrices special matrix objects in their own
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
314 right and the consequent usage of smarter algorithms for certain operations
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
315 implies, as a side effect, small differences in treating zeros.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
316 The contents of this section applies also to sparse matrices, discussed in
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
317 the following chapter.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
318
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
319 The IEEE standard defines the result of the expressions @code{0*Inf} and
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
320 @code{0*NaN} as @code{NaN}, as it has been generally agreed that this is the
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
321 best compromise.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
322 Numerical software dealing with structured and sparse matrices (including
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
323 Octave) however, almost always makes a distinction between a "numerical zero"
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
324 and an "assumed zero".
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
325 A "numerical zero" is a zero value occuring in a place where any floating-point
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
326 value could occur. It is normally stored somewhere in memory as an explicit
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
327 value.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
328 An "assumed zero", on the contrary, is a zero matrix element implied by the
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
329 matrix structure (diagonal, triangular) or a sparsity pattern; its value is
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
330 usually not stored explicitly anywhere, but is implied by the underlying
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
331 data structure.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
332
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
333 The primary distinction is that an assumed zero, when multiplied or divided
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
334 by any number, yields *always* a zero, even when, e.g., multiplied by @code{Inf}
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
335 or divided by @code{NaN}.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
336 The reason for this behavior is that the numerical multiplication is not
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
337 actually performed anywhere by the underlying algorithm; the result is
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
338 just assumed to be zero. Equivalently, one can say that the part of the
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
339 computation involving assumed zeros is performed symbolically, not numerically.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
340
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
341 This behavior not only facilitates the most straightforward and efficient
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
342 implementation of algorithms, but also preserves certain useful invariants,
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
343 like:
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
344 @itemize
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
345 @item scalar * diagonal matrix is a diagonal matrix
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
346 @item sparse matrix / scalar preserves the sparsity pattern
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
347 @item permutation matrix * matrix is equivalent to permuting rows
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
348 @end itemize
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
349 all of these natural mathematical truths would be invalidated by treating
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
350 assumed zeros as numerical ones.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
351
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
352 Note that certain competing software does not strictly follow this principle
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
353 and converts assumed zeros to numerical zeros in certain cases, while not doing
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
354 so in other cases. As of today, there are no intentions to mimick such behavior
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
355 in Octave.
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
356
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
357 Examples of effects of assumed zeros vs. numerical zeros:
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
358 @example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
359 Inf * eye (3)
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
360 @result{}
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
361 Inf 0 0
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
362 0 Inf 0
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
363 0 0 Inf
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
364
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
365 Inf * speye (3)
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
366 @result{}
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
367 Compressed Column Sparse (rows = 3, cols = 3, nnz = 3 [33%])
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
368
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
369 (1, 1) -> Inf
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
370 (2, 2) -> Inf
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
371 (3, 3) -> Inf
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
372
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
373 Inf * full (eye (3))
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
374 @result{}
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
375 Inf NaN NaN
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
376 NaN Inf NaN
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
377 NaN NaN Inf
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
378
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
379 @end example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
380
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
381 @example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
382 diag(1:3) * [NaN; 1; 1]
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
383 @result{}
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
384 NaN
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
385 2
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
386 3
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
387
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
388 sparse(1:3,1:3,1:3) * [NaN; 1; 1]
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
389 @result{}
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
390 NaN
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
391 2
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
392 3
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
393 [1,0,0;0,2,0;0,0,3] * [NaN; 1; 1]
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
394 @result{}
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
395 NaN
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
396 NaN
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
397 NaN
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
398 @end example
fcba62cc4549 add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
399