Mercurial > hg > octave-jordi
annotate doc/interpreter/diagperm.txi @ 19595:0e1f5a750d00
maint: Periodic merge of gui-release to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 20 Jan 2015 10:24:46 -0500 |
parents | 9e5b64b3c1fe 446c46af4b42 |
children | 4197fc428c7d |
rev | line source |
---|---|
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17152
diff
changeset
|
1 @c Copyright (C) 2009-2013 Jaroslav Hajek |
8839
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. |
19592
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
9 @c |
8839
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. |
19592
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
14 @c |
8839
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 |
17152
f2a8592b8fbd
doc: Shorten some long subsection names in Manual.
Rik <rik@octave.org>
parents:
17097
diff
changeset
|
19 @node Diagonal and Permutation Matrices |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
20 @chapter Diagonal and Permutation Matrices |
18329
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
21 @cindex diagonal and permutation matrices |
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
22 @cindex matrices, diagonal and permutation |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
23 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
24 @menu |
17152
f2a8592b8fbd
doc: Shorten some long subsection names in Manual.
Rik <rik@octave.org>
parents:
17097
diff
changeset
|
25 * Basic Usage:: Creation and Manipulation of Diagonal/Permutation Matrices |
f2a8592b8fbd
doc: Shorten some long subsection names in Manual.
Rik <rik@octave.org>
parents:
17097
diff
changeset
|
26 * Matrix Algebra:: Linear Algebra with Diagonal/Permutation Matrices |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
27 * Function Support:: Functions That Are Aware of These Matrices |
17152
f2a8592b8fbd
doc: Shorten some long subsection names in Manual.
Rik <rik@octave.org>
parents:
17097
diff
changeset
|
28 * Example Code:: Examples of Usage |
f2a8592b8fbd
doc: Shorten some long subsection names in Manual.
Rik <rik@octave.org>
parents:
17097
diff
changeset
|
29 * Zeros Treatment:: Differences in Treatment of Zero Elements |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
30 @end menu |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
31 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
32 @node Basic Usage |
17152
f2a8592b8fbd
doc: Shorten some long subsection names in Manual.
Rik <rik@octave.org>
parents:
17097
diff
changeset
|
33 @section Creating and Manipulating Diagonal/Permutation Matrices |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
34 |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
35 A diagonal matrix is defined as a matrix that has zero entries outside the main |
19592
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
36 diagonal; that is, |
8917 | 37 @tex |
8851
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
38 $D_{ij} = 0$ if $i \neq j$ |
8917 | 39 @end tex |
8851
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
40 @ifnottex |
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
41 @code{D(i,j) == 0} if @code{i != j}. |
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
42 @end ifnottex |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
43 Most often, square diagonal matrices are considered; however, the definition can |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
44 equally be applied to non-square matrices, in which case we usually speak of a |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
45 rectangular diagonal matrix. |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
46 |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
47 A permutation matrix is defined as a square matrix that has a single element |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
48 equal to unity in each row and each column; all other elements are zero. That |
19592
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
49 is, there exists a permutation (vector) |
8917 | 50 @tex |
8851
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
51 $p$ such that $P_{ij}=1$ if $j = p_i$ and |
19592
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
52 $P_{ij}=0$ otherwise. |
8917 | 53 @end tex |
8851
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
54 @ifnottex |
19592
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
55 @code{p} such that @code{P(i,j) == 1} if @code{j == p(i)} and |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
56 @code{P(i,j) == 0} otherwise. |
8851
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
57 @end ifnottex |
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
58 |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
59 Octave provides special treatment of real and complex rectangular diagonal |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
60 matrices, as well as permutation matrices. They are stored as special objects, |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
61 using efficient storage and algorithms, facilitating writing both readable and |
19397
9e5b64b3c1fe
Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents:
19390
diff
changeset
|
62 efficient matrix algebra expressions in the Octave language. The special |
9e5b64b3c1fe
Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents:
19390
diff
changeset
|
63 treatment may be disabled by using the functions @dfn{disable_diagonal_matrix} |
9e5b64b3c1fe
Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents:
19390
diff
changeset
|
64 and @dfn{disable_permutation_matrix}. |
9e5b64b3c1fe
Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents:
19390
diff
changeset
|
65 |
9e5b64b3c1fe
Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents:
19390
diff
changeset
|
66 @DOCSTRING(disable_diagonal_matrix) |
19390
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
19039
diff
changeset
|
67 |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
19039
diff
changeset
|
68 @DOCSTRING(disable_permutation_matrix) |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
19039
diff
changeset
|
69 |
19397
9e5b64b3c1fe
Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents:
19390
diff
changeset
|
70 The space savings are significant as demonstrated by the following code. |
9e5b64b3c1fe
Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents:
19390
diff
changeset
|
71 |
9e5b64b3c1fe
Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents:
19390
diff
changeset
|
72 @example |
9e5b64b3c1fe
Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents:
19390
diff
changeset
|
73 @group |
9e5b64b3c1fe
Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents:
19390
diff
changeset
|
74 x = diag (rand (10, 1)); |
9e5b64b3c1fe
Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents:
19390
diff
changeset
|
75 xf = full (x); |
9e5b64b3c1fe
Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents:
19390
diff
changeset
|
76 sizeof (x) |
9e5b64b3c1fe
Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents:
19390
diff
changeset
|
77 @result{} 80 |
9e5b64b3c1fe
Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents:
19390
diff
changeset
|
78 sizeof (xf) |
9e5b64b3c1fe
Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents:
19390
diff
changeset
|
79 @result{} 800 |
9e5b64b3c1fe
Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents:
19390
diff
changeset
|
80 @end group |
9e5b64b3c1fe
Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents:
19390
diff
changeset
|
81 @end example |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
82 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
83 @menu |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
84 * Creating Diagonal Matrices:: |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
85 * Creating Permutation Matrices:: |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
86 * Explicit and Implicit Conversions:: |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
87 @end menu |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
88 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
89 @node Creating Diagonal Matrices |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
90 @subsection Creating Diagonal Matrices |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
91 |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
92 The most common and easiest way to create a diagonal matrix is using the |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
93 built-in function @dfn{diag}. The expression @code{diag (v)}, with @var{v} a |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
94 vector, will create a square diagonal matrix with elements on the main diagonal |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
95 given by the elements of @var{v}, and size equal to the length of @var{v}. |
8917 | 96 @code{diag (v, m, n)} can be used to construct a rectangular diagonal matrix. |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
97 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
|
98 than a general matrix object. |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
99 |
8917 | 100 Diagonal matrix with unit elements can be created using @dfn{eye}. |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
101 Some other built-in functions can also return diagonal matrices. Examples |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
102 include |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
103 @dfn{balance} or @dfn{inv}. |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
104 |
8917 | 105 Example: |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
106 |
8917 | 107 @example |
108 diag (1:4) | |
109 @result{} | |
110 Diagonal Matrix | |
111 | |
112 1 0 0 0 | |
113 0 2 0 0 | |
114 0 0 3 0 | |
115 0 0 0 4 | |
116 | |
14856
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14853
diff
changeset
|
117 diag (1:3,5,3) |
8917 | 118 |
119 @result{} | |
120 Diagonal Matrix | |
121 | |
122 1 0 0 | |
123 0 2 0 | |
124 0 0 3 | |
125 0 0 0 | |
126 0 0 0 | |
19592
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
127 @end example |
8917 | 128 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
129 @node Creating Permutation Matrices |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
130 @subsection Creating Permutation Matrices |
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 For creating permutation matrices, Octave does not introduce a new function, but |
8851
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
133 rather overrides an existing syntax: permutation matrices can be conveniently |
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
134 created by indexing an identity matrix by permutation vectors. |
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
135 That is, if @var{q} is a permutation vector of length @var{n}, the expression |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
136 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
137 @example |
8917 | 138 P = eye (n) (:, q); |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
139 @end example |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
140 |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10828
diff
changeset
|
141 @noindent |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
142 will create a permutation matrix - a special matrix object. |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
143 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
144 @example |
19592
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
145 eye (n) (q, :) |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
146 @end example |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
147 |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10828
diff
changeset
|
148 @noindent |
19592
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
149 will also work (and create a row permutation matrix), as well as |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
150 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
151 @example |
8917 | 152 eye (n) (q1, q2). |
153 @end example | |
154 | |
155 For example: | |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
156 |
8917 | 157 @example |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
158 @group |
8917 | 159 eye (4) ([1,3,2,4],:) |
160 @result{} | |
161 Permutation Matrix | |
162 | |
163 1 0 0 0 | |
164 0 0 1 0 | |
165 0 1 0 0 | |
166 0 0 0 1 | |
167 | |
168 eye (4) (:,[1,3,2,4]) | |
169 @result{} | |
170 Permutation Matrix | |
171 | |
172 1 0 0 0 | |
173 0 0 1 0 | |
174 0 1 0 0 | |
175 0 0 0 1 | |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
176 @end group |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
177 @end example |
8851
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
178 |
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
179 Mathematically, an identity matrix is both diagonal and permutation matrix. |
8917 | 180 In Octave, @code{eye (n)} returns a diagonal matrix, because a matrix |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
181 can only have one class. You can convert this diagonal matrix to a permutation |
8917 | 182 matrix by indexing it by an identity permutation, as shown below. |
8851
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
183 This is a special property of the identity matrix; indexing other diagonal |
8917 | 184 matrices generally produces a full matrix. |
185 | |
186 @example | |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
187 @group |
8917 | 188 eye (3) |
189 @result{} | |
190 Diagonal Matrix | |
191 | |
192 1 0 0 | |
193 0 1 0 | |
194 0 0 1 | |
195 | |
196 eye(3)(1:3,:) | |
197 @result{} | |
198 Permutation Matrix | |
199 | |
200 1 0 0 | |
201 0 1 0 | |
202 0 0 1 | |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
203 @end group |
8917 | 204 @end example |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
205 |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
206 Some other built-in functions can also return permutation matrices. Examples |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
207 include |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
208 @dfn{inv} or @dfn{lu}. |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
209 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
210 @node Explicit and Implicit Conversions |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
211 @subsection Explicit and Implicit Conversions |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
212 |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
213 The diagonal and permutation matrices are special objects in their own right. A |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
214 number of operations and built-in functions are defined for these matrices to |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
215 use special, more efficient code than would be used for a full matrix in the |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
216 same place. Examples are given in further sections. |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
217 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
218 To facilitate smooth mixing with full matrices, backward compatibility, and |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
219 compatibility with @sc{matlab}, the diagonal and permutation matrices should |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
220 allow any operation that works on full matrices, and will either treat it |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
221 specially, or implicitly convert themselves to full matrices. |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
222 |
8917 | 223 Instances include matrix indexing, except for extracting a single element or |
224 a leading submatrix, indexed assignment, or applying most mapper functions, | |
225 such as @dfn{exp}. | |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
226 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
227 An explicit conversion to a full matrix can be requested using the built-in |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
228 function @dfn{full}. It should also be noted that the diagonal and permutation |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
229 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
|
230 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
|
231 be very cheap. |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
232 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
233 @node Matrix Algebra |
17152
f2a8592b8fbd
doc: Shorten some long subsection names in Manual.
Rik <rik@octave.org>
parents:
17097
diff
changeset
|
234 @section Linear Algebra with Diagonal/Permutation Matrices |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
235 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
236 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
|
237 possible to use efficient algorithms while preserving natural linear |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
238 algebra syntax. This section describes in detail the operations that |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
239 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
|
240 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
241 @menu |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
242 * Expressions Involving Diagonal Matrices:: |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
243 * Expressions Involving Permutation Matrices:: |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
244 @end menu |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
245 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
246 @node Expressions Involving Diagonal Matrices |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
247 @subsection Expressions Involving Diagonal Matrices |
18329
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
248 @cindex diagonal matrix expressions |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
249 |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
250 Assume @var{D} is a diagonal matrix. If @var{M} is a full matrix, |
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
251 then @code{D*M} will scale the rows of @var{M}. That means, |
8917 | 252 if @code{S = D*M}, then for each pair of indices |
19592
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
253 i,j it holds |
8917 | 254 @tex |
8851
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
255 $$S_{ij} = D_{ii} M_{ij}$$ |
8917 | 256 @end tex |
8851
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
257 @ifnottex |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
258 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
259 @example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
260 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
|
261 @end example |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
262 |
8851
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
263 @end ifnottex |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
264 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
|
265 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
266 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
|
267 If @code{m < n}, then the expression @code{D*M} is equivalent to |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
268 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
269 @example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
270 D(:,1:m) * M(1:m,:), |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
271 @end example |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
272 |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10828
diff
changeset
|
273 @noindent |
19592
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
274 i.e., trailing @code{n-m} rows of @var{M} are ignored. If @code{m > n}, |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
275 then @code{D*M} is equivalent to |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
276 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
277 @example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
278 [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
|
279 @end example |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
280 |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10828
diff
changeset
|
281 @noindent |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
282 i.e., null rows are appended to the result. |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
283 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
|
284 |
18329
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
285 @cindex pseudoinverse |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
286 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
|
287 They are equivalent to solving a diagonal (or rectangular diagonal) |
10791
3140cb7a05a1
Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
9209
diff
changeset
|
288 in a least-squares minimum-norm sense. In exact arithmetic, this is |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
289 equivalent to multiplying by a pseudoinverse. The pseudoinverse of |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
290 a rectangular diagonal matrix is again a rectangular diagonal matrix |
8917 | 291 with swapped dimensions, where each nonzero diagonal element is replaced |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
292 by its reciprocal. |
19592
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
293 The matrix division algorithms do, in fact, use division rather than |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
294 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
|
295 honor the above definition. Note that a diagonal matrix is never truncated due |
18329
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
296 to ill-conditioning; otherwise, it would not be of much use for scaling. This |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
297 is typically consistent with linear algebra needs. A full matrix that only |
18329
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
298 happens to be diagonal (and is thus not a special object) is of course treated |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
299 normally. |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
300 |
18329
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
301 Multiplication and division by diagonal matrices work efficiently also when |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
302 combined with sparse matrices, i.e., @code{D*S}, where @var{D} is a diagonal |
9047 | 303 matrix and @var{S} is a sparse matrix scales the rows of the sparse matrix and |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
304 returns a sparse matrix. The expressions @code{S*D}, @code{D\S}, @code{S/D} |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
305 work analogically. |
9047 | 306 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
307 If @var{D1} and @var{D2} are both diagonal matrices, then the expressions |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
308 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
309 @example |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
310 @group |
8917 | 311 D1 + D2 |
19592
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
312 D1 - D2 |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
313 D1 * D2 |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
314 D1 / D2 |
8917 | 315 D1 \ D2 |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
316 @end group |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
317 @end example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
318 |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10828
diff
changeset
|
319 @noindent |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
320 again produce diagonal matrices, provided that normal |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
321 dimension matching rules are obeyed. The relations used are same as described |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
322 above. |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
323 |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
324 Also, a diagonal matrix @var{D} can be multiplied or divided by a scalar, or |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
325 raised to a scalar power if it is square, producing diagonal matrix result in |
19592
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
326 all cases. |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
327 |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
328 A diagonal matrix can also be transposed or conjugate-transposed, giving the |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
329 expected result. Extracting a leading submatrix of a diagonal matrix, i.e., |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
330 @code{D(1:m,1:n)}, will produce a diagonal matrix, other indexing expressions |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
331 will implicitly convert to full matrix. |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
332 |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
333 Adding a diagonal matrix to a full matrix only operates on the diagonal |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
334 elements. Thus, |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
335 |
8917 | 336 @example |
337 A = A + eps * eye (n) | |
338 @end example | |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
339 |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10828
diff
changeset
|
340 @noindent |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
341 is an efficient method of augmenting the diagonal of a matrix. Subtraction |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
342 works analogically. |
8917 | 343 |
344 When involved in expressions with other element-by-element operators, @code{.*}, | |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
345 @code{./}, @code{.\} or @code{.^}, an implicit conversion to full matrix will |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
346 take place. This is not always strictly necessary but chosen to facilitate |
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
347 better consistency with @sc{matlab}. |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
348 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
349 @node Expressions Involving Permutation Matrices |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
350 @subsection Expressions Involving Permutation Matrices |
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 If @var{P} is a permutation matrix and @var{M} a matrix, the expression |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
353 @code{P*M} will permute the rows of @var{M}. Similarly, @code{M*P} will |
19592
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
354 yield a column permutation. |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
355 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
|
356 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
357 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
|
358 help an user to understand the connection between a permutation matrix and |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
359 a permuting vector. Namely, the following holds, where @code{I = eye (n)} |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
360 is an identity matrix: |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
361 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
362 @example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
363 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
|
364 @end example |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
365 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
366 Similarly, |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
367 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
368 @example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
369 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
|
370 @end example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
371 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
372 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
|
373 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
374 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
|
375 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
|
376 permutation, or equivalently, turning a row-permutation matrix into a |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
377 column-permutation one. For permutation matrices, transpose is equivalent to |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
378 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
|
379 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
|
380 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
|
381 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
|
382 |
9047 | 383 Multiplication and division by permutation matrices works efficiently also when |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
384 combined with sparse matrices, i.e., @code{P*S}, where @var{P} is a permutation |
9047 | 385 matrix and @var{S} is a sparse matrix permutes the rows of the sparse matrix and |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
386 returns a sparse matrix. The expressions @code{S*P}, @code{P\S}, @code{S/P} |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
387 work analogically. |
9047 | 388 |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
389 Two permutation matrices can be multiplied or divided (if their sizes match), |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
390 performing a composition of permutations. Also a permutation matrix can be |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
391 indexed by a permutation vector (or two vectors), giving again a permutation |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
392 matrix. Any other operations do not generally yield a permutation matrix and |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
393 will thus trigger the implicit conversion. |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
394 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
395 @node Function Support |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
396 @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
|
397 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
398 This section lists the built-in functions that are aware of diagonal and |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
399 permutation matrices on input, or can return them as output. Passed to other |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
400 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
|
401 (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
|
402 diagonal or permutation matrices). |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
403 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
404 @menu |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
405 * Diagonal Matrix Functions:: |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
406 * Permutation Matrix Functions:: |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
407 @end menu |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
408 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
409 @node Diagonal Matrix Functions |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
410 @subsection Diagonal Matrix Functions |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
411 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
412 @dfn{inv} and @dfn{pinv} can be applied to a diagonal matrix, yielding again |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
413 a diagonal matrix. @dfn{det} will use an efficient straightforward calculation |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
414 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
|
415 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
|
416 without converting it to a full one: |
19592
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
417 @dfn{abs}, @dfn{real}, @dfn{imag}, @dfn{conj}, @dfn{sqrt}. |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
418 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
|
419 and @dfn{svd} functions. |
9047 | 420 The @dfn{sparse} function will convert a diagonal matrix efficiently to a |
421 sparse matrix. | |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
422 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
423 @node Permutation Matrix Functions |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
424 @subsection Permutation Matrix Functions |
18329
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
425 @cindex matrix, permutation functions |
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
426 @cindex permutation matrix functions |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
427 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
428 @dfn{inv} and @dfn{pinv} will invert a permutation matrix, preserving its |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
429 specialness. @dfn{det} can be applied to a permutation matrix, efficiently |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
430 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
|
431 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
432 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
|
433 @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
|
434 |
9047 | 435 The @dfn{sparse} function will convert a permutation matrix efficiently to a |
436 sparse matrix. | |
437 The @dfn{find} function will also work efficiently with a permutation matrix, | |
438 making it possible to conveniently obtain the permutation indices. | |
439 | |
14421
0ec73cf71556
doc: Source code is a mass noun (no "source codes")
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14420
diff
changeset
|
440 @node Example Code |
17152
f2a8592b8fbd
doc: Shorten some long subsection names in Manual.
Rik <rik@octave.org>
parents:
17097
diff
changeset
|
441 @section Examples of Usage |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
442 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
443 The following can be used to solve a linear system @code{A*x = b} |
11593
1577c6f80926
Use non-breaking spaces between certain adjectives and their nouns in docstrings.
Rik <octave@nomad.inbox5.com>
parents:
11573
diff
changeset
|
444 using the pivoted LU@tie{}factorization: |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
445 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
446 @example |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
447 @group |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
448 [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
|
449 x = U \ L \ P*b; |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
450 @end group |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
451 @end example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
452 |
8917 | 453 @noindent |
14420
dfb33a5723d2
doc: Fix incorrect diagonal matrix division (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
454 This is one way to normalize columns of a matrix @var{X} to unit norm: |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
455 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
456 @example |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
457 @group |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
458 s = norm (X, "columns"); |
14423
62cb605af1af
doc: Further fixes diagperm (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14421
diff
changeset
|
459 X /= diag (s); |
14420
dfb33a5723d2
doc: Fix incorrect diagonal matrix division (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
460 @end group |
dfb33a5723d2
doc: Fix incorrect diagonal matrix division (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
461 @end example |
dfb33a5723d2
doc: Fix incorrect diagonal matrix division (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
462 |
14423
62cb605af1af
doc: Further fixes diagperm (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14421
diff
changeset
|
463 @noindent |
17097
e7a059a9a644
doc: Use XREF as anchor prefix in documentation for clearer results in Info viewer.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
464 The same can also be accomplished with broadcasting (@pxref{Broadcasting}): |
14420
dfb33a5723d2
doc: Fix incorrect diagonal matrix division (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
465 |
dfb33a5723d2
doc: Fix incorrect diagonal matrix division (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
466 @example |
dfb33a5723d2
doc: Fix incorrect diagonal matrix division (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
467 @group |
dfb33a5723d2
doc: Fix incorrect diagonal matrix division (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
468 s = norm (X, "columns"); |
dfb33a5723d2
doc: Fix incorrect diagonal matrix division (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
469 X ./= s; |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
470 @end group |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
471 @end example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
472 |
8917 | 473 @noindent |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
474 The following expression is a way to efficiently calculate the sign of a |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
475 permutation, given by a permutation vector @var{p}. It will also work |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
476 in earlier versions of Octave, but slowly. |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
477 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
478 @example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
479 det (eye (length (p))(p, :)) |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
480 @end example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
481 |
8917 | 482 @noindent |
18329
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
483 Finally, here's how to solve a linear system @code{A*x = b} |
19039
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
18816
diff
changeset
|
484 with @nospell{Tikhonov} regularization (ridge regression) using SVD (a skeleton |
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
18816
diff
changeset
|
485 only): |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
486 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
487 @example |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
488 @group |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
489 m = rows (A); n = columns (A); |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
490 [U, S, V] = svd (A); |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
491 ## determine the regularization factor alpha |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
492 ## alpha = @dots{} |
8851
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
493 ## transform to orthogonal basis |
8917 | 494 b = U'*b; |
495 ## Use the standard formula, replacing A with S. | |
496 ## S is diagonal, so the following will be very fast and accurate. | |
497 x = (S'*S + alpha^2 * eye (n)) \ (S' * b); | |
8851
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
498 ## transform to solution basis |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
499 x = V*x; |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
500 @end group |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
501 @end example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
502 |
8917 | 503 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
504 @node Zeros Treatment |
17152
f2a8592b8fbd
doc: Shorten some long subsection names in Manual.
Rik <rik@octave.org>
parents:
17097
diff
changeset
|
505 @section Differences in Treatment of Zero Elements |
18329
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
506 @cindex matrix, zero elements |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
507 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
508 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
|
509 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
|
510 implies, as a side effect, small differences in treating zeros. |
18329
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
511 The contents of this section apply also to sparse matrices, discussed in |
18816
9ac2357f19bc
doc: Replace "non-zero" with "nonzero" to match existing usage.
Rik <rik@octave.org>
parents:
18329
diff
changeset
|
512 the following chapter. (@pxref{Sparse Matrices}) |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
513 |
18816
9ac2357f19bc
doc: Replace "non-zero" with "nonzero" to match existing usage.
Rik <rik@octave.org>
parents:
18329
diff
changeset
|
514 The IEEE floating point standard defines the result of the expressions |
9ac2357f19bc
doc: Replace "non-zero" with "nonzero" to match existing usage.
Rik <rik@octave.org>
parents:
18329
diff
changeset
|
515 @code{0*Inf} and @code{0*NaN} as @code{NaN}. This is widely agreed to be a |
9ac2357f19bc
doc: Replace "non-zero" with "nonzero" to match existing usage.
Rik <rik@octave.org>
parents:
18329
diff
changeset
|
516 good compromise. Numerical software dealing with structured and sparse matrices |
9ac2357f19bc
doc: Replace "non-zero" with "nonzero" to match existing usage.
Rik <rik@octave.org>
parents:
18329
diff
changeset
|
517 (including Octave) however, almost always makes a distinction between a |
9ac2357f19bc
doc: Replace "non-zero" with "nonzero" to match existing usage.
Rik <rik@octave.org>
parents:
18329
diff
changeset
|
518 "numerical zero" and an "assumed zero". A "numerical zero" is a zero value |
9ac2357f19bc
doc: Replace "non-zero" with "nonzero" to match existing usage.
Rik <rik@octave.org>
parents:
18329
diff
changeset
|
519 occurring in a place where any floating-point value could occur. It is |
9ac2357f19bc
doc: Replace "non-zero" with "nonzero" to match existing usage.
Rik <rik@octave.org>
parents:
18329
diff
changeset
|
520 normally stored somewhere in memory as an explicit value. An "assumed zero", on |
9ac2357f19bc
doc: Replace "non-zero" with "nonzero" to match existing usage.
Rik <rik@octave.org>
parents:
18329
diff
changeset
|
521 the contrary, is a zero matrix element implied by the matrix structure |
9ac2357f19bc
doc: Replace "non-zero" with "nonzero" to match existing usage.
Rik <rik@octave.org>
parents:
18329
diff
changeset
|
522 (diagonal, triangular) or a sparsity pattern; its value is usually not stored |
9ac2357f19bc
doc: Replace "non-zero" with "nonzero" to match existing usage.
Rik <rik@octave.org>
parents:
18329
diff
changeset
|
523 explicitly anywhere, but is implied by the underlying data structure. |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
524 |
19592
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18329
diff
changeset
|
525 The primary distinction is that an assumed zero, when multiplied |
8917 | 526 by any number, or divided by any nonzero number, |
527 yields *always* a zero, even when, e.g., multiplied by @code{Inf} | |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
528 or divided by @code{NaN}. |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
529 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
|
530 actually performed anywhere by the underlying algorithm; the result is |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
531 just assumed to be zero. Equivalently, one can say that the part of the |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
532 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
|
533 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
534 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
|
535 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
|
536 like: |
14853
72b8b39e12be
doc: Periodic grammarcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
14423
diff
changeset
|
537 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
538 @itemize |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
539 @item scalar * diagonal matrix is a diagonal matrix |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
540 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
541 @item sparse matrix / scalar preserves the sparsity pattern |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
542 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
543 @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
|
544 @end itemize |
16816
12005245b645
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
14856
diff
changeset
|
545 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
546 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
|
547 assumed zeros as numerical ones. |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
548 |
11573
6f8ffe2c6f76
Grammarcheck txi files for 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
549 Note that @sc{matlab} does not strictly follow this principle and converts |
11479
746609dd54fd
Remove Matlab euphemisms in docs and use @file macro for filenames
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
550 assumed zeros to numerical zeros in certain cases, while not doing so in |
11573
6f8ffe2c6f76
Grammarcheck txi files for 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
551 other cases. As of today, there are no intentions to mimic such behavior |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
552 in Octave. |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
553 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
554 Examples of effects of assumed zeros vs. numerical zeros: |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
555 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
556 @example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
557 Inf * eye (3) |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
558 @result{} |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
559 Inf 0 0 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
560 0 Inf 0 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
561 0 0 Inf |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
562 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
563 Inf * speye (3) |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
564 @result{} |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
565 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
|
566 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
567 (1, 1) -> Inf |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
568 (2, 2) -> Inf |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
569 (3, 3) -> Inf |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
570 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
571 Inf * full (eye (3)) |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
572 @result{} |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
573 Inf NaN NaN |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
574 NaN Inf NaN |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
575 NaN NaN Inf |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
576 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
577 @end example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
578 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
579 @example |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
580 @group |
14856
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14853
diff
changeset
|
581 diag (1:3) * [NaN; 1; 1] |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
582 @result{} |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
583 NaN |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
584 2 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
585 3 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
586 |
14856
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14853
diff
changeset
|
587 sparse (1:3,1:3,1:3) * [NaN; 1; 1] |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
588 @result{} |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
589 NaN |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
590 2 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
591 3 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
592 [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
|
593 @result{} |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
594 NaN |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
595 NaN |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
596 NaN |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
597 @end group |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
598 @end example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
599 |