Mercurial > octave-nkf
annotate doc/interpreter/diagperm.txi @ 19627:446c46af4b42 stable
strip trailing whitespace from most source files
* Makefile.am, NEWS, build-aux/common.mk, configure.ac,
doc/Makefile.am, doc/doxyhtml/Makefile.am,
doc/interpreter/Makefile.am, doc/interpreter/arith.txi,
doc/interpreter/audio.txi, doc/interpreter/basics.txi,
doc/interpreter/bugs.txi, doc/interpreter/container.txi,
doc/interpreter/cp-idx.txi, doc/interpreter/data.txi,
doc/interpreter/debug.txi, doc/interpreter/diagperm.txi,
doc/interpreter/diffeq.txi, doc/interpreter/doccheck/README,
doc/interpreter/doccheck/spellcheck, doc/interpreter/emacs.txi,
doc/interpreter/errors.txi, doc/interpreter/eval.txi,
doc/interpreter/expr.txi, doc/interpreter/external.txi,
doc/interpreter/fn-idx.txi, doc/interpreter/func.txi,
doc/interpreter/geometry.txi, doc/interpreter/geometryimages.m,
doc/interpreter/gpl.txi, doc/interpreter/grammar.txi,
doc/interpreter/gui.txi, doc/interpreter/image.txi,
doc/interpreter/install.txi, doc/interpreter/interp.txi,
doc/interpreter/interpimages.m, doc/interpreter/intro.txi,
doc/interpreter/io.txi, doc/interpreter/java.txi,
doc/interpreter/linalg.txi, doc/interpreter/macros.texi,
doc/interpreter/matrix.txi, doc/interpreter/munge-texi.pl,
doc/interpreter/nonlin.txi, doc/interpreter/numbers.txi,
doc/interpreter/obsolete.txi, doc/interpreter/octave-config.1,
doc/interpreter/octave.texi, doc/interpreter/oop.txi,
doc/interpreter/op-idx.txi, doc/interpreter/optim.txi,
doc/interpreter/package.txi, doc/interpreter/plot.txi,
doc/interpreter/poly.txi, doc/interpreter/preface.txi,
doc/interpreter/quad.txi, doc/interpreter/set.txi,
doc/interpreter/signal.txi, doc/interpreter/sparse.txi,
doc/interpreter/sparseimages.m, doc/interpreter/splineimages.m,
doc/interpreter/stats.txi, doc/interpreter/stmt.txi,
doc/interpreter/strings.txi, doc/interpreter/system.txi,
doc/interpreter/testfun.txi, doc/interpreter/tips.txi,
doc/interpreter/var.txi, doc/interpreter/vectorize.txi,
doc/liboctave/Makefile.am, doc/liboctave/array.texi,
doc/liboctave/bugs.texi, doc/liboctave/cp-idx.texi,
doc/liboctave/dae.texi, doc/liboctave/diffeq.texi,
doc/liboctave/error.texi, doc/liboctave/factor.texi,
doc/liboctave/fn-idx.texi, doc/liboctave/gpl.texi,
doc/liboctave/install.texi, doc/liboctave/intro.texi,
doc/liboctave/liboctave.texi, doc/liboctave/matvec.texi,
doc/liboctave/nleqn.texi, doc/liboctave/nlfunc.texi,
doc/liboctave/ode.texi, doc/liboctave/optim.texi,
doc/liboctave/preface.texi, doc/liboctave/quad.texi,
doc/liboctave/range.texi, doc/refcard/Makefile.am,
doc/refcard/refcard.tex, etc/HACKING, etc/NEWS.1, etc/NEWS.2,
etc/NEWS.3, etc/OLD-ChangeLogs/ChangeLog,
etc/OLD-ChangeLogs/doc-ChangeLog,
etc/OLD-ChangeLogs/scripts-ChangeLog,
etc/OLD-ChangeLogs/src-ChangeLog, etc/OLD-ChangeLogs/test-ChangeLog,
etc/PROJECTS, etc/README.Cygwin, etc/README.MacOS, etc/README.MinGW,
etc/README.gnuplot, etc/gdbinit, etc/icons/Makefile.am,
examples/@polynomial/end.m, examples/@polynomial/subsasgn.m,
examples/Makefile.am, examples/standalonebuiltin.cc,
libgui/Makefile.am, libgui/qterminal/libqterminal/README,
libgui/qterminal/libqterminal/unix/BlockArray.cpp,
libgui/qterminal/libqterminal/unix/BlockArray.h,
libgui/qterminal/libqterminal/unix/Character.h,
libgui/qterminal/libqterminal/unix/CharacterColor.h,
libgui/qterminal/libqterminal/unix/Emulation.cpp,
libgui/qterminal/libqterminal/unix/Emulation.h,
libgui/qterminal/libqterminal/unix/Filter.cpp,
libgui/qterminal/libqterminal/unix/Filter.h,
libgui/qterminal/libqterminal/unix/History.cpp,
libgui/qterminal/libqterminal/unix/History.h,
libgui/qterminal/libqterminal/unix/KeyboardTranslator.cpp,
libgui/qterminal/libqterminal/unix/KeyboardTranslator.h,
libgui/qterminal/libqterminal/unix/LineFont.h,
libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp,
libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.h,
libgui/qterminal/libqterminal/unix/Screen.cpp,
libgui/qterminal/libqterminal/unix/Screen.h,
libgui/qterminal/libqterminal/unix/ScreenWindow.cpp,
libgui/qterminal/libqterminal/unix/ScreenWindow.h,
libgui/qterminal/libqterminal/unix/TerminalCharacterDecoder.cpp,
libgui/qterminal/libqterminal/unix/TerminalCharacterDecoder.h,
libgui/qterminal/libqterminal/unix/Vt102Emulation.h,
libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp,
libgui/qterminal/qterminal/main.cpp,
libgui/src/m-editor/file-editor-tab.cc, libgui/src/octave-gui.cc,
libgui/src/octave-qt-link.cc, libinterp/corefcn/data.cc,
libinterp/corefcn/defun-int.h, libinterp/corefcn/det.cc,
libinterp/corefcn/gl2ps-renderer.cc, libinterp/corefcn/graphics.cc,
libinterp/corefcn/graphics.in.h, libinterp/corefcn/ls-mat5.cc,
libinterp/corefcn/lu.cc, libinterp/corefcn/oct-tex-parser.yy,
libinterp/corefcn/oct-tex-symbols.in, libinterp/corefcn/quadcc.cc,
libinterp/corefcn/zfstream.cc, libinterp/dldfcn/__eigs__.cc,
libinterp/dldfcn/__voronoi__.cc, libinterp/gendoc.pl,
libinterp/genprops.awk, libinterp/mk-errno-list, libinterp/mk-pkg-add,
libinterp/mkbuiltins, libinterp/mkdefs, libinterp/mkdocs,
libinterp/mkops, libinterp/octave-value/ov-java.cc,
libinterp/parse-tree/lex.ll, libinterp/parse-tree/oct-parse.in.yy,
libinterp/parse-tree/octave.gperf, liboctave/Makefile.am,
liboctave/array/Array.cc, liboctave/array/module.mk,
liboctave/cruft/daspk/datv.f, liboctave/cruft/daspk/dcnst0.f,
liboctave/cruft/daspk/dcnstr.f, liboctave/cruft/daspk/ddasic.f,
liboctave/cruft/daspk/ddasid.f, liboctave/cruft/daspk/ddasik.f,
liboctave/cruft/daspk/ddaspk.f, liboctave/cruft/daspk/ddstp.f,
liboctave/cruft/daspk/ddwnrm.f, liboctave/cruft/daspk/dfnrmd.f,
liboctave/cruft/daspk/dfnrmk.f, liboctave/cruft/daspk/dhels.f,
liboctave/cruft/daspk/dheqr.f, liboctave/cruft/daspk/dinvwt.f,
liboctave/cruft/daspk/dlinsd.f, liboctave/cruft/daspk/dlinsk.f,
liboctave/cruft/daspk/dmatd.f, liboctave/cruft/daspk/dnedd.f,
liboctave/cruft/daspk/dnedk.f, liboctave/cruft/daspk/dnsd.f,
liboctave/cruft/daspk/dnsid.f, liboctave/cruft/daspk/dnsik.f,
liboctave/cruft/daspk/dnsk.f, liboctave/cruft/daspk/dorth.f,
liboctave/cruft/daspk/dslvd.f, liboctave/cruft/daspk/dslvk.f,
liboctave/cruft/daspk/dspigm.f, liboctave/cruft/daspk/dyypnw.f,
liboctave/cruft/dasrt/ddasrt.f, liboctave/cruft/dasrt/drchek.f,
liboctave/cruft/dassl/ddaslv.f, liboctave/cruft/dassl/ddassl.f,
liboctave/cruft/misc/blaswrap.c, liboctave/cruft/misc/module.mk,
liboctave/cruft/odepack/cfode.f, liboctave/cruft/odepack/dlsode.f,
liboctave/cruft/odepack/ewset.f, liboctave/cruft/odepack/intdy.f,
liboctave/cruft/odepack/prepj.f, liboctave/cruft/odepack/sintdy.f,
liboctave/cruft/odepack/slsode.f, liboctave/cruft/odepack/solsy.f,
liboctave/cruft/odepack/ssolsy.f, liboctave/cruft/odepack/stode.f,
liboctave/cruft/odepack/vnorm.f, liboctave/cruft/ranlib/Basegen.doc,
liboctave/cruft/ranlib/README, liboctave/cruft/ranlib/genbet.f,
liboctave/cruft/ranlib/genexp.f, liboctave/cruft/ranlib/gennch.f,
liboctave/cruft/ranlib/gennf.f, liboctave/cruft/ranlib/gennor.f,
liboctave/cruft/ranlib/getsd.f, liboctave/cruft/ranlib/initgn.f,
liboctave/cruft/ranlib/phrtsd.f, liboctave/cruft/ranlib/randlib.fdoc,
liboctave/cruft/ranlib/setsd.f, liboctave/cruft/ranlib/tstgmn.for,
liboctave/cruft/ranlib/tstmid.for, liboctave/cruft/slatec-fn/atanh.f,
liboctave/cruft/slatec-fn/datanh.f,
liboctave/cruft/slatec-fn/xgmainc.f,
liboctave/cruft/slatec-fn/xsgmainc.f, liboctave/numeric/module.mk,
liboctave/operators/mk-ops.awk, liboctave/operators/mx-ops,
liboctave/operators/sparse-mk-ops.awk,
liboctave/operators/sparse-mx-ops, liboctave/operators/vx-ops,
liboctave/util/module.mk, run-octave.in, scripts/@ftp/ftp.m,
scripts/audio/wavread.m, scripts/deprecated/java_convert_matrix.m,
scripts/deprecated/java_debug.m, scripts/deprecated/java_invoke.m,
scripts/deprecated/java_new.m,
scripts/deprecated/java_unsigned_conversion.m,
scripts/deprecated/javafields.m, scripts/deprecated/javamethods.m,
scripts/deprecated/shell_cmd.m, scripts/general/accumarray.m,
scripts/general/display.m, scripts/general/fieldnames.m,
scripts/general/interp1.m, scripts/general/interp2.m,
scripts/general/interp3.m, scripts/general/isa.m,
scripts/general/methods.m, scripts/general/sortrows.m,
scripts/geometry/convhull.m, scripts/geometry/delaunay.m,
scripts/geometry/delaunay3.m, scripts/geometry/delaunayn.m,
scripts/geometry/griddata.m, scripts/geometry/griddatan.m,
scripts/geometry/voronoi.m, scripts/geometry/voronoin.m,
scripts/gui/guihandles.m, scripts/gui/inputdlg.m,
scripts/gui/listdlg.m, scripts/gui/msgbox.m, scripts/gui/questdlg.m,
scripts/gui/uigetfile.m, scripts/gui/waitbar.m, scripts/gui/warndlg.m,
scripts/help/doc.m, scripts/help/help.m, scripts/help/type.m,
scripts/image/bone.m, scripts/image/cmpermute.m,
scripts/image/cmunique.m, scripts/image/colorcube.m,
scripts/image/colormap.m, scripts/image/contrast.m,
scripts/image/gray2ind.m, scripts/image/image.m,
scripts/image/imshow.m, scripts/image/ind2gray.m, scripts/image/jet.m,
scripts/image/rgb2ntsc.m, scripts/image/spinmap.m,
scripts/io/importdata.m, scripts/io/strread.m, scripts/io/textread.m,
scripts/io/textscan.m, scripts/java/java_get.m,
scripts/java/java_set.m, scripts/java/javaaddpath.m,
scripts/java/javaclasspath.m, scripts/java/javamem.m,
scripts/linear-algebra/linsolve.m, scripts/linear-algebra/qzhess.m,
scripts/miscellaneous/debug.m, scripts/miscellaneous/desktop.m,
scripts/miscellaneous/dir.m, scripts/miscellaneous/dos.m,
scripts/miscellaneous/edit.m, scripts/miscellaneous/fact.m,
scripts/miscellaneous/getappdata.m, scripts/miscellaneous/inputname.m,
scripts/miscellaneous/license.m, scripts/miscellaneous/ls_command.m,
scripts/miscellaneous/run.m, scripts/miscellaneous/setfield.m,
scripts/miscellaneous/unix.m, scripts/miscellaneous/ver.m,
scripts/mk-pkg-add, scripts/mkdoc.pl,
scripts/optimization/fminsearch.m, scripts/optimization/optimset.m,
scripts/optimization/sqp.m, scripts/pkg/pkg.m,
scripts/pkg/private/create_pkgadddel.m,
scripts/pkg/private/fix_depends.m, scripts/pkg/private/install.m,
scripts/plot/appearance/axis.m, scripts/plot/appearance/box.m,
scripts/plot/appearance/clabel.m, scripts/plot/appearance/daspect.m,
scripts/plot/appearance/datetick.m, scripts/plot/appearance/grid.m,
scripts/plot/appearance/legend.m, scripts/plot/appearance/orient.m,
scripts/plot/appearance/shading.m, scripts/plot/appearance/text.m,
scripts/plot/appearance/title.m, scripts/plot/appearance/xlabel.m,
scripts/plot/appearance/ylabel.m, scripts/plot/appearance/zlabel.m,
scripts/plot/draw/area.m, scripts/plot/draw/bar.m,
scripts/plot/draw/barh.m, scripts/plot/draw/colorbar.m,
scripts/plot/draw/contour.m, scripts/plot/draw/contour3.m,
scripts/plot/draw/contourf.m, scripts/plot/draw/ellipsoid.m,
scripts/plot/draw/errorbar.m, scripts/plot/draw/ezcontour.m,
scripts/plot/draw/ezcontourf.m, scripts/plot/draw/ezmesh.m,
scripts/plot/draw/ezpolar.m, scripts/plot/draw/fill.m,
scripts/plot/draw/fplot.m, scripts/plot/draw/hist.m,
scripts/plot/draw/meshc.m, scripts/plot/draw/meshz.m,
scripts/plot/draw/pareto.m, scripts/plot/draw/patch.m,
scripts/plot/draw/peaks.m, scripts/plot/draw/pie.m,
scripts/plot/draw/pie3.m, scripts/plot/draw/plot.m,
scripts/plot/draw/plotyy.m, scripts/plot/draw/private/__bar__.m,
scripts/plot/draw/private/__contour__.m,
scripts/plot/draw/private/__errplot__.m,
scripts/plot/draw/private/__ezplot__.m,
scripts/plot/draw/private/__patch__.m,
scripts/plot/draw/private/__stem__.m, scripts/plot/draw/rectangle.m,
scripts/plot/draw/ribbon.m, scripts/plot/draw/rose.m,
scripts/plot/draw/scatter.m, scripts/plot/draw/scatter3.m,
scripts/plot/draw/semilogx.m, scripts/plot/draw/shrinkfaces.m,
scripts/plot/draw/sombrero.m, scripts/plot/draw/sphere.m,
scripts/plot/draw/stairs.m, scripts/plot/draw/stem.m,
scripts/plot/draw/stemleaf.m, scripts/plot/draw/surf.m,
scripts/plot/draw/surface.m, scripts/plot/draw/surfc.m,
scripts/plot/draw/surfl.m, scripts/plot/draw/surfnorm.m,
scripts/plot/draw/tetramesh.m, scripts/plot/draw/trimesh.m,
scripts/plot/draw/triplot.m, scripts/plot/draw/trisurf.m,
scripts/plot/util/__gnuplot_drawnow__.m,
scripts/plot/util/__plt_get_axis_arg__.m, scripts/plot/util/axes.m,
scripts/plot/util/clf.m, scripts/plot/util/copyobj.m,
scripts/plot/util/figure.m, scripts/plot/util/gcbo.m,
scripts/plot/util/graphics_toolkit.m, scripts/plot/util/hggroup.m,
scripts/plot/util/meshgrid.m, scripts/plot/util/newplot.m,
scripts/plot/util/print.m,
scripts/plot/util/private/__add_default_menu__.m,
scripts/plot/util/private/__fltk_print__.m,
scripts/plot/util/private/__gnuplot_print__.m,
scripts/plot/util/private/__print_parse_opts__.m,
scripts/plot/util/refreshdata.m, scripts/plot/util/subplot.m,
scripts/polynomial/conv.m, scripts/polynomial/poly.m,
scripts/polynomial/polyeig.m, scripts/polynomial/polyfit.m,
scripts/polynomial/polyval.m,
scripts/polynomial/private/__splinefit__.m,
scripts/polynomial/spline.m, scripts/prefs/prefdir.m,
scripts/prefs/preferences.m, scripts/prefs/private/prefsfile.m,
scripts/prefs/rmpref.m, scripts/signal/freqz.m,
scripts/signal/module.mk, scripts/sparse/eigs.m, scripts/sparse/pcg.m,
scripts/sparse/private/__sprand_impl__.m, scripts/sparse/sprand.m,
scripts/sparse/sprandn.m, scripts/sparse/spy.m, scripts/sparse/svds.m,
scripts/specfun/expint.m, scripts/specfun/factor.m,
scripts/special-matrix/gallery.m, scripts/special-matrix/hankel.m,
scripts/special-matrix/toeplitz.m, scripts/startup/inputrc,
scripts/statistics/base/kurtosis.m, scripts/statistics/base/moment.m,
scripts/statistics/base/qqplot.m, scripts/statistics/base/var.m,
scripts/statistics/distributions/betarnd.m,
scripts/statistics/distributions/binoinv.m,
scripts/statistics/distributions/binopdf.m,
scripts/statistics/distributions/binornd.m,
scripts/statistics/distributions/cauchy_rnd.m,
scripts/statistics/distributions/chi2rnd.m,
scripts/statistics/distributions/discrete_pdf.m,
scripts/statistics/distributions/discrete_rnd.m,
scripts/statistics/distributions/empirical_rnd.m,
scripts/statistics/distributions/exprnd.m,
scripts/statistics/distributions/frnd.m,
scripts/statistics/distributions/gamrnd.m,
scripts/statistics/distributions/geornd.m,
scripts/statistics/distributions/hygernd.m,
scripts/statistics/distributions/kolmogorov_smirnov_cdf.m,
scripts/statistics/distributions/laplace_cdf.m,
scripts/statistics/distributions/laplace_pdf.m,
scripts/statistics/distributions/logistic_cdf.m,
scripts/statistics/distributions/logistic_pdf.m,
scripts/statistics/distributions/lognrnd.m,
scripts/statistics/distributions/nbincdf.m,
scripts/statistics/distributions/nbininv.m,
scripts/statistics/distributions/nbinpdf.m,
scripts/statistics/distributions/nbinrnd.m,
scripts/statistics/distributions/normrnd.m,
scripts/statistics/distributions/poissinv.m,
scripts/statistics/distributions/poissrnd.m,
scripts/statistics/distributions/tinv.m,
scripts/statistics/distributions/trnd.m,
scripts/statistics/distributions/unidcdf.m,
scripts/statistics/distributions/unidpdf.m,
scripts/statistics/distributions/unidrnd.m,
scripts/statistics/distributions/unifrnd.m,
scripts/statistics/distributions/wblrnd.m,
scripts/statistics/models/module.mk,
scripts/statistics/tests/kruskal_wallis_test.m,
scripts/strings/base2dec.m, scripts/strings/deblank.m,
scripts/strings/dec2base.m, scripts/strings/dec2bin.m,
scripts/strings/dec2hex.m, scripts/strings/mat2str.m,
scripts/strings/ostrsplit.m, scripts/strings/regexptranslate.m,
scripts/strings/str2num.m, scripts/strings/strcat.m,
scripts/strings/strjoin.m, scripts/strings/strsplit.m,
scripts/strings/strtok.m, scripts/strings/strtrim.m,
scripts/strings/strtrunc.m, scripts/strings/substr.m,
scripts/testfun/__run_test_suite__.m, scripts/testfun/speed.m,
scripts/testfun/test.m, scripts/time/asctime.m,
scripts/time/datenum.m, scripts/time/datevec.m,
scripts/time/weekday.m, src/Makefile.am, test/Makefile.am,
test/build-bc-overload-tests.sh, test/build-sparse-tests.sh,
test/jit.tst, test/line-continue.tst: Strip trailing whitespace.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 20 Jan 2015 08:26:57 -0500 |
parents | 200851c87444 |
children | 0e1f5a750d00 |
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. |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
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. |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
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 |
18330
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 |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
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 |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
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 |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
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 |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
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:
18330
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 |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
62 efficient matrix algebra expressions in the Octave language. |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
63 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
64 @menu |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
65 * Creating Diagonal Matrices:: |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
66 * Creating Permutation Matrices:: |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
67 * Explicit and Implicit Conversions:: |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
68 @end menu |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
69 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
70 @node Creating Diagonal Matrices |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
71 @subsection Creating Diagonal Matrices |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
72 |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
73 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
|
74 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
|
75 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
|
76 given by the elements of @var{v}, and size equal to the length of @var{v}. |
8917 | 77 @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
|
78 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
|
79 than a general matrix object. |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
80 |
8917 | 81 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
|
82 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
|
83 include |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
84 @dfn{balance} or @dfn{inv}. |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
85 |
8917 | 86 Example: |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
87 |
8917 | 88 @example |
89 diag (1:4) | |
90 @result{} | |
91 Diagonal Matrix | |
92 | |
93 1 0 0 0 | |
94 0 2 0 0 | |
95 0 0 3 0 | |
96 0 0 0 4 | |
97 | |
14856
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14853
diff
changeset
|
98 diag (1:3,5,3) |
8917 | 99 |
100 @result{} | |
101 Diagonal Matrix | |
102 | |
103 1 0 0 | |
104 0 2 0 | |
105 0 0 3 | |
106 0 0 0 | |
107 0 0 0 | |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
diff
changeset
|
108 @end example |
8917 | 109 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
110 @node Creating Permutation Matrices |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
111 @subsection Creating Permutation Matrices |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
112 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
113 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
|
114 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
|
115 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
|
116 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
|
117 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
118 @example |
8917 | 119 P = eye (n) (:, q); |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
120 @end example |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
121 |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10828
diff
changeset
|
122 @noindent |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
123 will create a permutation matrix - a special matrix object. |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
124 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
125 @example |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
diff
changeset
|
126 eye (n) (q, :) |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
127 @end example |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
128 |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10828
diff
changeset
|
129 @noindent |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
diff
changeset
|
130 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
|
131 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
132 @example |
8917 | 133 eye (n) (q1, q2). |
134 @end example | |
135 | |
136 For example: | |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
137 |
8917 | 138 @example |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
139 @group |
8917 | 140 eye (4) ([1,3,2,4],:) |
141 @result{} | |
142 Permutation Matrix | |
143 | |
144 1 0 0 0 | |
145 0 0 1 0 | |
146 0 1 0 0 | |
147 0 0 0 1 | |
148 | |
149 eye (4) (:,[1,3,2,4]) | |
150 @result{} | |
151 Permutation Matrix | |
152 | |
153 1 0 0 0 | |
154 0 0 1 0 | |
155 0 1 0 0 | |
156 0 0 0 1 | |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
157 @end group |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
158 @end example |
8851
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
159 |
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
160 Mathematically, an identity matrix is both diagonal and permutation matrix. |
8917 | 161 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
|
162 can only have one class. You can convert this diagonal matrix to a permutation |
8917 | 163 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
|
164 This is a special property of the identity matrix; indexing other diagonal |
8917 | 165 matrices generally produces a full matrix. |
166 | |
167 @example | |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
168 @group |
8917 | 169 eye (3) |
170 @result{} | |
171 Diagonal Matrix | |
172 | |
173 1 0 0 | |
174 0 1 0 | |
175 0 0 1 | |
176 | |
177 eye(3)(1:3,:) | |
178 @result{} | |
179 Permutation Matrix | |
180 | |
181 1 0 0 | |
182 0 1 0 | |
183 0 0 1 | |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
184 @end group |
8917 | 185 @end example |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
186 |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
187 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
|
188 include |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
189 @dfn{inv} or @dfn{lu}. |
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 @node Explicit and Implicit Conversions |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
192 @subsection Explicit and Implicit Conversions |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
193 |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
194 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
|
195 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
|
196 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
|
197 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
|
198 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
199 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
|
200 compatibility with @sc{matlab}, the diagonal and permutation matrices should |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
201 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
|
202 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
|
203 |
8917 | 204 Instances include matrix indexing, except for extracting a single element or |
205 a leading submatrix, indexed assignment, or applying most mapper functions, | |
206 such as @dfn{exp}. | |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
207 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
208 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
|
209 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
|
210 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
|
211 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
|
212 be very cheap. |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
213 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
214 @node Matrix Algebra |
17152
f2a8592b8fbd
doc: Shorten some long subsection names in Manual.
Rik <rik@octave.org>
parents:
17097
diff
changeset
|
215 @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
|
216 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
217 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
|
218 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
|
219 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
|
220 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
|
221 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
222 @menu |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
223 * Expressions Involving Diagonal Matrices:: |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
224 * Expressions Involving Permutation Matrices:: |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
225 @end menu |
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 @node Expressions Involving Diagonal Matrices |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
228 @subsection Expressions Involving Diagonal Matrices |
18330
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
229 @cindex diagonal matrix expressions |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
230 |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
231 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
|
232 then @code{D*M} will scale the rows of @var{M}. That means, |
8917 | 233 if @code{S = D*M}, then for each pair of indices |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
diff
changeset
|
234 i,j it holds |
8917 | 235 @tex |
8851
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
236 $$S_{ij} = D_{ii} M_{ij}$$ |
8917 | 237 @end tex |
8851
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
238 @ifnottex |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
239 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
240 @example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
241 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
|
242 @end example |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
243 |
8851
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
244 @end ifnottex |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
245 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
|
246 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
247 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
|
248 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
|
249 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
250 @example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
251 D(:,1:m) * M(1:m,:), |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
252 @end example |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
253 |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10828
diff
changeset
|
254 @noindent |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
diff
changeset
|
255 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:
18330
diff
changeset
|
256 then @code{D*M} is equivalent to |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
257 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
258 @example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
259 [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
|
260 @end example |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
261 |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10828
diff
changeset
|
262 @noindent |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
263 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
|
264 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
|
265 |
18330
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
266 @cindex pseudoinverse |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
267 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
|
268 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
|
269 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
|
270 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
|
271 a rectangular diagonal matrix is again a rectangular diagonal matrix |
8917 | 272 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
|
273 by its reciprocal. |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
diff
changeset
|
274 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
|
275 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
|
276 honor the above definition. Note that a diagonal matrix is never truncated due |
18330
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
277 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
|
278 is typically consistent with linear algebra needs. A full matrix that only |
18330
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
279 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
|
280 normally. |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
281 |
18330
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
282 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
|
283 combined with sparse matrices, i.e., @code{D*S}, where @var{D} is a diagonal |
9047 | 284 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
|
285 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
|
286 work analogically. |
9047 | 287 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
288 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
|
289 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
290 @example |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
291 @group |
8917 | 292 D1 + D2 |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
diff
changeset
|
293 D1 - D2 |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
diff
changeset
|
294 D1 * D2 |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
diff
changeset
|
295 D1 / D2 |
8917 | 296 D1 \ D2 |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
297 @end group |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
298 @end example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
299 |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10828
diff
changeset
|
300 @noindent |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
301 again produce diagonal matrices, provided that normal |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
302 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
|
303 above. |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
304 |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
305 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
|
306 raised to a scalar power if it is square, producing diagonal matrix result in |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
diff
changeset
|
307 all cases. |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
308 |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
309 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
|
310 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
|
311 @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
|
312 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
|
313 |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
314 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
|
315 elements. Thus, |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
316 |
8917 | 317 @example |
318 A = A + eps * eye (n) | |
319 @end example | |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
320 |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10828
diff
changeset
|
321 @noindent |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
322 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
|
323 works analogically. |
8917 | 324 |
325 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
|
326 @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
|
327 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
|
328 better consistency with @sc{matlab}. |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
329 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
330 @node Expressions Involving Permutation Matrices |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
331 @subsection Expressions Involving Permutation Matrices |
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 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
|
334 @code{P*M} will permute the rows of @var{M}. Similarly, @code{M*P} will |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
diff
changeset
|
335 yield a column permutation. |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
336 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
|
337 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
338 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
|
339 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
|
340 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
|
341 is an identity matrix: |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
342 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
343 @example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
344 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
|
345 @end example |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
346 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
347 Similarly, |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
348 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
349 @example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
350 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
|
351 @end example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
352 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
353 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
|
354 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
355 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
|
356 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
|
357 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
|
358 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
|
359 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
|
360 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
|
361 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
|
362 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
|
363 |
9047 | 364 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
|
365 combined with sparse matrices, i.e., @code{P*S}, where @var{P} is a permutation |
9047 | 366 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
|
367 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
|
368 work analogically. |
9047 | 369 |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
370 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
|
371 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
|
372 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
|
373 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
|
374 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
|
375 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
376 @node Function Support |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
377 @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
|
378 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
379 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
|
380 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
|
381 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
|
382 (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
|
383 diagonal or permutation matrices). |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
384 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
385 @menu |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
386 * Diagonal Matrix Functions:: |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
387 * Permutation Matrix Functions:: |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
388 @end menu |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
389 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
390 @node Diagonal Matrix Functions |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
391 @subsection Diagonal Matrix Functions |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
392 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
393 @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
|
394 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
|
395 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
|
396 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
|
397 without converting it to a full one: |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
diff
changeset
|
398 @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
|
399 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
|
400 and @dfn{svd} functions. |
9047 | 401 The @dfn{sparse} function will convert a diagonal matrix efficiently to a |
402 sparse matrix. | |
8839
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 @node Permutation Matrix Functions |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
405 @subsection Permutation Matrix Functions |
18330
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
406 @cindex matrix, permutation functions |
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
407 @cindex permutation matrix functions |
8839
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 @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
|
410 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
|
411 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
|
412 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
413 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
|
414 @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
|
415 |
9047 | 416 The @dfn{sparse} function will convert a permutation matrix efficiently to a |
417 sparse matrix. | |
418 The @dfn{find} function will also work efficiently with a permutation matrix, | |
419 making it possible to conveniently obtain the permutation indices. | |
420 | |
14421
0ec73cf71556
doc: Source code is a mass noun (no "source codes")
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14420
diff
changeset
|
421 @node Example Code |
17152
f2a8592b8fbd
doc: Shorten some long subsection names in Manual.
Rik <rik@octave.org>
parents:
17097
diff
changeset
|
422 @section Examples of Usage |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
423 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
424 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
|
425 using the pivoted LU@tie{}factorization: |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
426 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
427 @example |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
428 @group |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
429 [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
|
430 x = U \ L \ P*b; |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
431 @end group |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
432 @end example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
433 |
8917 | 434 @noindent |
14420
dfb33a5723d2
doc: Fix incorrect diagonal matrix division (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
435 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
|
436 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
437 @example |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
438 @group |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
439 s = norm (X, "columns"); |
14423
62cb605af1af
doc: Further fixes diagperm (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14421
diff
changeset
|
440 X /= diag (s); |
14420
dfb33a5723d2
doc: Fix incorrect diagonal matrix division (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
441 @end group |
dfb33a5723d2
doc: Fix incorrect diagonal matrix division (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
442 @end example |
dfb33a5723d2
doc: Fix incorrect diagonal matrix division (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
443 |
14423
62cb605af1af
doc: Further fixes diagperm (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14421
diff
changeset
|
444 @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
|
445 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
|
446 |
dfb33a5723d2
doc: Fix incorrect diagonal matrix division (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
447 @example |
dfb33a5723d2
doc: Fix incorrect diagonal matrix division (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
448 @group |
dfb33a5723d2
doc: Fix incorrect diagonal matrix division (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
449 s = norm (X, "columns"); |
dfb33a5723d2
doc: Fix incorrect diagonal matrix division (bug #35666)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
450 X ./= s; |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
451 @end group |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
452 @end example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
453 |
8917 | 454 @noindent |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
455 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
|
456 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
|
457 in earlier versions of Octave, but slowly. |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
458 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
459 @example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
460 det (eye (length (p))(p, :)) |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
461 @end example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
462 |
8917 | 463 @noindent |
18330
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
464 Finally, here's how to solve a linear system @code{A*x = b} |
8851
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
465 with Tikhonov regularization (ridge regression) using SVD (a skeleton only): |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
466 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
467 @example |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
468 @group |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
469 m = rows (A); n = columns (A); |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
470 [U, S, V] = svd (A); |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
471 ## determine the regularization factor alpha |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
472 ## alpha = @dots{} |
8851
d6de39523f03
improve the diag & perm matrices text
Jaroslav Hajek <highegg@gmail.com>
parents:
8839
diff
changeset
|
473 ## transform to orthogonal basis |
8917 | 474 b = U'*b; |
475 ## Use the standard formula, replacing A with S. | |
476 ## S is diagonal, so the following will be very fast and accurate. | |
477 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
|
478 ## transform to solution basis |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
479 x = V*x; |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
480 @end group |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
481 @end example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
482 |
8917 | 483 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
484 @node Zeros Treatment |
17152
f2a8592b8fbd
doc: Shorten some long subsection names in Manual.
Rik <rik@octave.org>
parents:
17097
diff
changeset
|
485 @section Differences in Treatment of Zero Elements |
18330
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
486 @cindex matrix, zero elements |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
487 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
488 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
|
489 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
|
490 implies, as a side effect, small differences in treating zeros. |
18330
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
491 The contents of this section apply also to sparse matrices, discussed in |
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
492 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
|
493 |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
diff
changeset
|
494 The IEEE floating point standard defines the result of the expressions @code{0*Inf} and |
18330
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
495 @code{0*NaN} as @code{NaN}. This is widely agreed to be a good |
200851c87444
Edits to Manual and indicies
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17744
diff
changeset
|
496 compromise. |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
497 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
|
498 Octave) however, almost always makes a distinction between a "numerical zero" |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
diff
changeset
|
499 and an "assumed zero". |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
500 A "numerical zero" is a zero value occurring in a place where any floating-point |
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
501 value could occur. It is normally stored somewhere in memory as an explicit |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
diff
changeset
|
502 value. |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
503 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
|
504 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
|
505 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
|
506 data structure. |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
507 |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18330
diff
changeset
|
508 The primary distinction is that an assumed zero, when multiplied |
8917 | 509 by any number, or divided by any nonzero number, |
510 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
|
511 or divided by @code{NaN}. |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
512 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
|
513 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
|
514 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
|
515 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
|
516 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
517 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
|
518 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
|
519 like: |
14853
72b8b39e12be
doc: Periodic grammarcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
14423
diff
changeset
|
520 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
521 @itemize |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
522 @item scalar * diagonal matrix is a diagonal matrix |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
523 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
524 @item sparse matrix / scalar preserves the sparsity pattern |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
525 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
526 @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
|
527 @end itemize |
16816
12005245b645
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
14856
diff
changeset
|
528 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
529 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
|
530 assumed zeros as numerical ones. |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
531 |
11573
6f8ffe2c6f76
Grammarcheck txi files for 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
532 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
|
533 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
|
534 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
|
535 in Octave. |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
536 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
537 Examples of effects of assumed zeros vs. numerical zeros: |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
538 |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
539 @example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
540 Inf * eye (3) |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
541 @result{} |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
542 Inf 0 0 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
543 0 Inf 0 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
544 0 0 Inf |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
545 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
546 Inf * speye (3) |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
547 @result{} |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
548 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
|
549 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
550 (1, 1) -> Inf |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
551 (2, 2) -> Inf |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
552 (3, 3) -> Inf |
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 Inf * full (eye (3)) |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
555 @result{} |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
556 Inf NaN NaN |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
557 NaN Inf NaN |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
558 NaN NaN Inf |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
559 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
560 @end example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
561 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
562 @example |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
563 @group |
14856
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14853
diff
changeset
|
564 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
|
565 @result{} |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
566 NaN |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
567 2 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
568 3 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
569 |
14856
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14853
diff
changeset
|
570 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
|
571 @result{} |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
572 NaN |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
573 2 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
574 3 |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
575 [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
|
576 @result{} |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
577 NaN |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
578 NaN |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
579 NaN |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9047
diff
changeset
|
580 @end group |
8839
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
581 @end example |
fcba62cc4549
add chapter about diagonal and permutation matrices to manual
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
582 |