Mercurial > octave
annotate scripts/special-matrix/gallery.m @ 24534:194eb4bd202b
maint: Update punctuation for GPL v3 license text.
* COPYING, Makefile.am, README,
bootstrap, bootstrap.conf, OctJavaQry.java, changelog.tmpl,
check-subst-vars.in.sh, find-defun-files.sh, find-files-with-tests.sh,
get-source-mtime.sh, mk-hg-id.sh, mk-octave-config-h.sh, mk-opts.pl,
stl_algo.h-fixed, subst-config-vals.in.sh, subst-cross-config-vals.in.sh,
subst-default-vals.in.sh, subst-script-vals.in.sh, configure.ac,
Doxyfile.in, arith.txi, audio.txi, basics.txi, bugs.txi, config-images.sh,
container.txi, cp-idx.txi, data.txi, debug.txi, diagperm.txi, diffeq.txi,
add_to_aspell_dict, mk_undocumented_list, spellcheck, errors.txi, eval.txi,
expr.txi, external.txi, fn-idx.txi, func.txi, genpropdoc.m, geometry.txi,
geometryimages.m, grammar.txi, gui.txi, image.txi, images.awk, install.txi,
interp.txi, interpimages.m, intro.txi, io.txi, linalg.txi, macros.texi,
matrix.txi, mk-doc-cache.pl, mkcontrib.awk, mkoctfile.1, munge-texi.pl,
nonlin.txi, numbers.txi, obsolete.txi, octave-cli.1, octave-config.1, octave.1,
octave.css, octave.texi, oop.txi, op-idx.txi, optim.txi, package.txi, plot.txi,
plotimages.m, poly.txi, preface.txi, quad.txi, set.txi, signal.txi, sparse.txi,
sparseimages.m, splineimages.m, stats.txi, stmt.txi, strings.txi, system.txi,
testfun.txi, var.txi, vectorize.txi, array.texi, bugs.texi, cp-idx.texi,
dae.texi, diffeq.texi, error.texi, factor.texi, fn-idx.texi, gpl.texi,
install.texi, intro.texi, liboctave.texi, matvec.texi, nleqn.texi, nlfunc.texi,
ode.texi, optim.texi, preface.texi, quad.texi, range.texi, refcard-a4.tex,
refcard-legal.tex, refcard-letter.tex, refcard.tex, HACKING.md,
octave.appdata.xml.in, Backend.cc, Backend.h, BaseControl.cc, BaseControl.h,
ButtonControl.cc, ButtonControl.h, ButtonGroup.cc, ButtonGroup.h, Canvas.cc,
Canvas.h, CheckBoxControl.cc, CheckBoxControl.h, Container.cc, Container.h,
ContextMenu.cc, ContextMenu.h, EditControl.cc, EditControl.h, Figure.cc,
Figure.h, FigureWindow.cc, FigureWindow.h, GLCanvas.cc, GLCanvas.h,
GenericEventNotify.h, KeyMap.cc, KeyMap.h, ListBoxControl.cc, ListBoxControl.h,
Logger.cc, Logger.h, Menu.cc, Menu.h, MenuContainer.h, MouseModeActionGroup.cc,
MouseModeActionGroup.h, Object.cc, Object.h, ObjectFactory.cc, ObjectFactory.h,
ObjectProxy.cc, ObjectProxy.h, Panel.cc, Panel.h, PopupMenuControl.cc,
PopupMenuControl.h, PushButtonControl.cc, PushButtonControl.h, PushTool.cc,
PushTool.h, QtHandlesUtils.cc, QtHandlesUtils.h, RadioButtonControl.cc,
RadioButtonControl.h, SliderControl.cc, SliderControl.h, TextControl.cc,
TextControl.h, TextEdit.cc, TextEdit.h, ToggleButtonControl.cc,
ToggleButtonControl.h, ToggleTool.cc, ToggleTool.h, ToolBar.cc, ToolBar.h,
ToolBarButton.cc, ToolBarButton.h, __init_qt__.cc, __init_qt__.h,
annotation-dialog.cc, annotation-dialog.h, gl-select.cc, gl-select.h,
liboctgui-build-info.h, liboctgui-build-info.in.cc,
mk-default-qt-settings.in.sh, QTerminal.cc, QTerminal.h, BlockArray.cpp,
BlockArray.h, Character.h, CharacterColor.h, Emulation.cpp, Emulation.h,
Filter.cpp, Filter.h, History.cpp, History.h, KeyboardTranslator.cpp,
KeyboardTranslator.h, QUnixTerminalImpl.cpp, QUnixTerminalImpl.h, Screen.cpp,
Screen.h, ScreenWindow.cpp, ScreenWindow.h, SelfListener.cpp, SelfListener.h,
TerminalCharacterDecoder.cpp, TerminalCharacterDecoder.h, TerminalModel.cpp,
TerminalModel.h, TerminalView.cpp, TerminalView.h, Vt102Emulation.cpp,
Vt102Emulation.h, kpty.cpp, kpty.h, kpty_p.h, QTerminalColors.cpp,
QTerminalColors.h, QWinTerminalImpl.cpp, QWinTerminalImpl.h, main.cpp,
color-picker.cc, color-picker.h, dialog.cc, dialog.h,
documentation-dock-widget.cc, documentation-dock-widget.h,
external-editor-interface.cc, external-editor-interface.h,
files-dock-widget.cc, files-dock-widget.h, find-files-dialog.cc,
find-files-dialog.h, find-files-model.cc, find-files-model.h,
history-dock-widget.cc, history-dock-widget.h, file-editor-interface.h,
file-editor-tab.cc, file-editor-tab.h, file-editor.cc, file-editor.h,
find-dialog.cc, find-dialog.h, marker.cc, marker.h, octave-qscintilla.cc,
octave-qscintilla.h, octave-txt-lexer.cc, octave-txt-lexer.h, main-window.cc,
main-window.h, octave-cmd.cc, octave-cmd.h, octave-dock-widget.cc,
octave-dock-widget.h, octave-gui.cc, octave-gui.h, octave-qt-link.cc,
octave-qt-link.h, octave-settings.h, texinfo-parser.cc, texinfo-parser.h,
webinfo.cc, webinfo.h, resource-manager.cc, resource-manager.h,
settings-dialog.cc, settings-dialog.h, shortcut-manager.cc, shortcut-manager.h,
terminal-dock-widget.cc, terminal-dock-widget.h, thread-manager.cc,
thread-manager.h, variable-editor-model.cc, variable-editor-model.h,
variable-editor.cc, variable-editor.h, welcome-wizard.cc, welcome-wizard.h,
workspace-model.cc, workspace-model.h, workspace-view.cc, workspace-view.h,
build-env.h, build-env.in.cc, builtins.h, Cell.cc, Cell.h, __contourc__.cc,
__dsearchn__.cc, __ichol__.cc, __ilu__.cc, __lin_interpn__.cc, __luinc__.cc,
__magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, balance.cc,
base-text-renderer.h, besselj.cc, betainc.cc, bitfcns.cc, bsxfun.cc,
c-file-ptr-stream.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h,
cdisplay.c, cdisplay.h, cellfun.cc, coct-hdf5-types.c, colloc.cc, conv2.cc,
daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc, default-defs.in.h,
defaults.cc, defaults.h, defun-dld.h, defun-int.h, defun.cc, defun.h, det.cc,
dirfns.cc, dirfns.h, display.cc, display.h, dlmread.cc, dot.cc, dynamic-ld.cc,
dynamic-ld.h, eig.cc, ellipj.cc, environment.cc, environment.h, error.cc,
error.h, errwarn.cc, errwarn.h, event-queue.cc, event-queue.h, fcn-info.cc,
fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, file-io.h, filter.cc,
find.cc, ft-text-renderer.cc, ft-text-renderer.h, gammainc.cc, gcd.cc,
genprops.awk, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc, gl-render.cc,
gl-render.h, gl2ps-print.cc, gl2ps-print.h, graphics-handle.h,
graphics-toolkit.cc, graphics-toolkit.h, graphics.cc, graphics.in.h, gripes.cc,
gripes.h, gsvd.cc, gtk-manager.cc, gtk-manager.h, hash.cc, help.cc, help.h,
hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h,
interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h,
inv.cc, kron.cc, load-path.cc, load-path.h, load-save.cc, load-save.h,
lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-hdf5.cc, ls-hdf5.h,
ls-mat-ascii.cc, ls-mat-ascii.h, ls-mat4.cc, ls-mat4.h, ls-mat5.cc, ls-mat5.h,
ls-oct-binary.cc, ls-oct-binary.h, ls-oct-text.cc, ls-oct-text.h, ls-utils.cc,
ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex.cc, mex.h,
mexproto.h, mgorth.cc, mk-errno-list.sh, mk-mxarray-h.in.sh, mxarray.in.h,
nproc.cc, oct-errno.h, oct-errno.in.cc, oct-fstrm.cc, oct-fstrm.h,
oct-handle.h, oct-hdf5-types.cc, oct-hdf5-types.h, oct-hdf5.h, oct-hist.cc,
oct-hist.h, oct-iostrm.cc, oct-iostrm.h, oct-map.cc, oct-map.h, oct-obj.h,
oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h,
oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.cc, oct-strstrm.h,
oct-tex-lexer.in.ll, oct-tex-parser.in.yy, oct.h, octave-default-image.h,
octave-link.cc, octave-link.h, ordschur.cc, pager.cc, pager.h, pinv.cc,
pr-output.cc, pr-output.h, procstream.cc, procstream.h, psi.cc, quad.cc,
quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, sighandlers.cc,
sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc, sparse-xpow.h,
sparse.cc, spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc,
sub2ind.cc, svd.cc, sylvester.cc, symrec.cc, symrec.h, symscope.cc, symscope.h,
symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h, text-renderer.cc,
text-renderer.h, time.cc, toplev.cc, toplev.h, tril.cc, tsearch.cc, txt-eng.cc,
txt-eng.h, typecast.cc, url-handle-manager.cc, url-handle-manager.h,
urlwrite.cc, utils.cc, utils.h, variables.cc, variables.h, workspace-element.h,
xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h, zfstream.cc, zfstream.h,
deprecated-config.h, __delaunayn__.cc, __eigs__.cc, __fltk_uigetfile__.cc,
__glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc,
__osmesa_print__.cc, __voronoi__.cc, amd.cc, audiodevinfo.cc, audioread.cc,
ccolamd.cc, chol.cc, colamd.cc, config-module.awk, config-module.sh,
convhulln.cc, dmperm.cc, fftw.cc, gzip.cc, oct-qhull.h, qr.cc, symbfact.cc,
symrcm.cc, liboctinterp-build-info.h, liboctinterp-build-info.in.cc,
mk-build-env-features.sh, mk-builtins.pl, mk-doc.pl, mk-pkg-add.sh,
mk-version-h.in.sh, ov-base-diag.cc, ov-base-diag.h, ov-base-int.cc,
ov-base-int.h, ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.cc,
ov-base-scalar.h, ov-base-sparse.cc, ov-base-sparse.h, ov-base.cc, ov-base.h,
ov-bool-mat.cc, ov-bool-mat.h, ov-bool-sparse.cc, ov-bool-sparse.h, ov-bool.cc,
ov-bool.h, ov-builtin.cc, ov-builtin.h, ov-cell.cc, ov-cell.h, ov-ch-mat.cc,
ov-ch-mat.h, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h,
ov-colon.cc, ov-colon.h, ov-complex.cc, ov-complex.h, ov-cs-list.cc,
ov-cs-list.h, ov-cx-diag.cc, ov-cx-diag.h, ov-cx-mat.cc, ov-cx-mat.h,
ov-cx-sparse.cc, ov-cx-sparse.h, ov-dld-fcn.cc, ov-dld-fcn.h, ov-fcn-handle.cc,
ov-fcn-handle.h, ov-fcn-inline.cc, ov-fcn-inline.h, ov-fcn.cc, ov-fcn.h,
ov-float.cc, ov-float.h, ov-flt-complex.cc, ov-flt-complex.h,
ov-flt-cx-diag.cc, ov-flt-cx-diag.h, ov-flt-cx-mat.cc, ov-flt-cx-mat.h,
ov-flt-re-diag.cc, ov-flt-re-diag.h, ov-flt-re-mat.cc, ov-flt-re-mat.h,
ov-int-traits.h, ov-int16.cc, ov-int16.h, ov-int32.cc, ov-int32.h, ov-int64.cc,
ov-int64.h, ov-int8.cc, ov-int8.h, ov-intx.h, ov-java.cc, ov-java.h,
ov-lazy-idx.cc, ov-lazy-idx.h, ov-mex-fcn.cc, ov-mex-fcn.h, ov-null-mat.cc,
ov-null-mat.h, ov-oncleanup.cc, ov-oncleanup.h, ov-perm.cc, ov-perm.h,
ov-range.cc, ov-range.h, ov-re-diag.cc, ov-re-diag.h, ov-re-mat.cc,
ov-re-mat.h, ov-re-sparse.cc, ov-re-sparse.h, ov-scalar.cc, ov-scalar.h,
ov-str-mat.cc, ov-str-mat.h, ov-struct.cc, ov-struct.h, ov-typeinfo.cc,
ov-typeinfo.h, ov-uint16.cc, ov-uint16.h, ov-uint32.cc, ov-uint32.h,
ov-uint64.cc, ov-uint64.h, ov-uint8.cc, ov-uint8.h, ov-usr-fcn.cc,
ov-usr-fcn.h, ov.cc, ov.h, ovl.cc, ovl.h, octave.cc, octave.h, op-kw-docs,
mk-ops.sh, op-b-b.cc, op-b-bm.cc, op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc,
op-bm-sbm.cc, op-cdm-cdm.cc, op-cdm-cm.cc, op-cdm-cs.cc, op-cdm-dm.cc,
op-cdm-m.cc, op-cdm-s.cc, op-cell.cc, op-chm.cc, op-class.cc, op-cm-cdm.cc,
op-cm-cm.cc, op-cm-cs.cc, op-cm-dm.cc, op-cm-m.cc, op-cm-pm.cc, op-cm-s.cc,
op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc,
op-cs-scm.cc, op-cs-sm.cc, op-dm-cdm.cc, op-dm-cm.cc, op-dm-cs.cc, op-dm-dm.cc,
op-dm-m.cc, op-dm-s.cc, op-dm-scm.cc, op-dm-sm.cc, op-dm-template.cc,
op-dms-template.cc, op-fcdm-fcdm.cc, op-fcdm-fcm.cc, op-fcdm-fcs.cc,
op-fcdm-fdm.cc, op-fcdm-fm.cc, op-fcdm-fs.cc, op-fcm-fcdm.cc, op-fcm-fcm.cc,
op-fcm-fcs.cc, op-fcm-fdm.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcm-pm.cc,
op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc,
op-fdm-fcdm.cc, op-fdm-fcm.cc, op-fdm-fcs.cc, op-fdm-fdm.cc, op-fdm-fm.cc,
op-fdm-fs.cc, op-fm-fcdm.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fdm.cc,
op-fm-fm.cc, op-fm-fs.cc, op-fm-pm.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc,
op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc,
op-int-concat.cc, op-int.h, op-m-cdm.cc, op-m-cm.cc, op-m-cs.cc, op-m-dm.cc,
op-m-m.cc, op-m-pm.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc, op-pm-cm.cc,
op-pm-fcm.cc, op-pm-fm.cc, op-pm-m.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc,
op-pm-template.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc,
op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc,
op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc,
op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc,
op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc,
op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, ops.h,
options-usage.h, bp-table.cc, bp-table.h, comment-list.cc, comment-list.h,
jit-ir.cc, jit-ir.h, jit-typeinfo.cc, jit-typeinfo.h, jit-util.cc, jit-util.h,
lex.h, lex.ll, oct-lvalue.cc, oct-lvalue.h, oct-parse.in.yy, octave.gperf,
parse.h, profiler.cc, profiler.h, pt-all.h, pt-arg-list.cc, pt-arg-list.h,
pt-array-list.cc, pt-array-list.h, pt-assign.cc, pt-assign.h, pt-binop.cc,
pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc, pt-cbinop.h, pt-cell.cc,
pt-cell.h, pt-check.cc, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.h,
pt-colon.cc, pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc, pt-decl.h,
pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h,
pt-fcn-handle.cc, pt-fcn-handle.h, pt-funcall.cc, pt-funcall.h, pt-id.cc,
pt-id.h, pt-idx.cc, pt-idx.h, pt-jit.cc, pt-jit.h, pt-jump.cc, pt-jump.h,
pt-loop.cc, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.cc, pt-misc.h,
pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-stmt.cc, pt-stmt.h,
pt-tm-const.cc, pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-walk.cc, pt-walk.h,
pt.cc, pt.h, token.cc, token.h, Array-jit.cc, Array-tc.cc, version.cc,
version.in.h, Array-C.cc, Array-b.cc, Array-ch.cc, Array-d.cc, Array-f.cc,
Array-fC.cc, Array-i.cc, Array-idx-vec.cc, Array-s.cc, Array-str.cc,
Array-util.cc, Array-util.h, Array-voidp.cc, Array.cc, Array.h, CColVector.cc,
CColVector.h, CDiagMatrix.cc, CDiagMatrix.h, CMatrix.cc, CMatrix.h,
CNDArray.cc, CNDArray.h, CRowVector.cc, CRowVector.h, CSparse.cc, CSparse.h,
DiagArray2.cc, DiagArray2.h, MArray-C.cc, MArray-d.cc, MArray-f.cc,
MArray-fC.cc, MArray-i.cc, MArray-s.cc, MArray.cc, MArray.h, MDiagArray2.cc,
MDiagArray2.h, MSparse-C.cc, MSparse-d.cc, MSparse.cc, MSparse.h, Matrix.h,
MatrixType.cc, MatrixType.h, PermMatrix.cc, PermMatrix.h, Range.cc, Range.h,
Sparse-C.cc, Sparse-b.cc, Sparse-d.cc, Sparse.cc, Sparse.h, boolMatrix.cc,
boolMatrix.h, boolNDArray.cc, boolNDArray.h, boolSparse.cc, boolSparse.h,
chMatrix.cc, chMatrix.h, chNDArray.cc, chNDArray.h, dColVector.cc,
dColVector.h, dDiagMatrix.cc, dDiagMatrix.h, dMatrix.cc, dMatrix.h,
dNDArray.cc, dNDArray.h, dRowVector.cc, dRowVector.h, dSparse.cc, dSparse.h,
dim-vector.cc, dim-vector.h, fCColVector.cc, fCColVector.h, fCDiagMatrix.cc,
fCDiagMatrix.h, fCMatrix.cc, fCMatrix.h, fCNDArray.cc, fCNDArray.h,
fCRowVector.cc, fCRowVector.h, fColVector.cc, fColVector.h, fDiagMatrix.cc,
fDiagMatrix.h, fMatrix.cc, fMatrix.h, fNDArray.cc, fNDArray.h, fRowVector.cc,
fRowVector.h, idx-vector.cc, idx-vector.h, int16NDArray.cc, int16NDArray.h,
int32NDArray.cc, int32NDArray.h, int64NDArray.cc, int64NDArray.h,
int8NDArray.cc, int8NDArray.h, intNDArray.cc, intNDArray.h, uint16NDArray.cc,
uint16NDArray.h, uint32NDArray.cc, uint32NDArray.h, uint64NDArray.cc,
uint64NDArray.h, uint8NDArray.cc, uint8NDArray.h, cconv2.f, cdotc3.f, cmatm3.f,
csconv2.f, dconv2.f, ddot3.f, dmatm3.f, sconv2.f, sdot3.f, smatm3.f, zconv2.f,
zdconv2.f, zdotc3.f, zmatm3.f, crsf2csf.f, zrsf2csf.f, mk-f77-def.in.sh,
liboctave-build-info.h, liboctave-build-info.in.cc, CollocWt.cc, CollocWt.h,
DAE.h, DAEFunc.h, DAERT.h, DAERTFunc.h, DASPK-opts.in, DASPK.cc, DASPK.h,
DASRT-opts.in, DASRT.cc, DASRT.h, DASSL-opts.in, DASSL.cc, DASSL.h, DET.h,
EIG.cc, EIG.h, LSODE-opts.in, LSODE.cc, LSODE.h, ODE.h, ODEFunc.h, ODES.cc,
ODES.h, ODESFunc.h, Quad-opts.in, Quad.cc, Quad.h, aepbalance.cc, aepbalance.h,
base-dae.h, base-de.h, base-min.h, bsxfun-decl.h, bsxfun-defs.cc, bsxfun.h,
chol.cc, chol.h, eigs-base.cc, eigs-base.h, fEIG.cc, fEIG.h, gepbalance.cc,
gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h, lo-amos-proto.h,
lo-arpack-proto.h, lo-blas-proto.h, lo-fftpack-proto.h, lo-lapack-proto.h,
lo-mappers.cc, lo-mappers.h, lo-qrupdate-proto.h, lo-ranlib-proto.h,
lo-slatec-proto.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h, oct-convn.cc,
oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h, oct-rand.cc,
oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc, qrp.h,
randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc,
randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h,
sparse-dmsolve.cc, sparse-dmsolve.h, sparse-lu.cc, sparse-lu.h, sparse-qr.cc,
sparse-qr.h, svd.cc, svd.h, Sparse-diag-op-defs.h, Sparse-op-decls.h,
Sparse-op-defs.h, Sparse-perm-op-defs.h, config-ops.sh, mk-ops.awk, mx-base.h,
mx-defs.h, mx-ext.h, mx-inlines.cc, mx-op-decl.h, mx-op-defs.h, mx-ops,
smx-ops, vx-ops, child-list.cc, child-list.h, cmach-info.c, cmach-info.h,
dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc, file-stat.h,
lo-sysdep.cc, lo-sysdep.h, mach-info.cc, mach-info.h, oct-env.cc, oct-env.h,
oct-group.cc, oct-group.h, oct-passwd.cc, oct-passwd.h, oct-syscalls.cc,
oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.cc, oct-uname.h,
action-container.h, base-list.h, blaswrap.c, byte-swap.h, caseless-str.h,
cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, cquit.c, data-conv.cc,
data-conv.h, f2c-main.c, f77-fcn.c, f77-fcn.h, file-info.cc, file-info.h,
functor.h, glob-match.cc, glob-match.h, kpse.cc, kpse.h, lo-array-errwarn.cc,
lo-array-errwarn.h, lo-array-gripes.cc, lo-array-gripes.h, lo-cutils.c,
lo-cutils.h, lo-error.c, lo-error.h, lo-hash.cc, lo-hash.h, lo-ieee.cc,
lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-traits.h, lo-utils.cc, lo-utils.h,
oct-base64.cc, oct-base64.h, oct-binmap.h, oct-cmplx.h, oct-glob.cc,
oct-glob.h, oct-inttypes-fwd.h, oct-inttypes.cc, oct-inttypes.h, oct-locbuf.h,
oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-rl-edit.c, oct-rl-edit.h,
oct-rl-hist.c, oct-rl-hist.h, oct-shlib.cc, oct-shlib.h, oct-sort.cc,
oct-sort.h, oct-sparse.cc, oct-sparse.h, oct-string.cc, oct-string.h,
octave-preserve-stream-state.h, pathsearch.cc, pathsearch.h, quit.cc, quit.h,
singleton-cleanup.cc, singleton-cleanup.h, sparse-sort.cc, sparse-sort.h,
sparse-util.cc, sparse-util.h, str-vec.cc, str-vec.h, sun-utils.h,
unwind-prot.cc, unwind-prot.h, url-transfer.cc, url-transfer.h,
areadlink-wrapper.c, areadlink-wrapper.h, async-system-wrapper.c,
async-system-wrapper.h, base64-wrappers.c, base64-wrappers.h,
canonicalize-file-name-wrapper.c, canonicalize-file-name-wrapper.h,
dirent-wrappers.c, dirent-wrappers.h, fcntl-wrappers.c, fcntl-wrappers.h,
filepos-wrappers.c, filepos-wrappers.h, fpucw-wrappers.c, fpucw-wrappers.h,
gen-tempname-wrapper.c, gen-tempname-wrapper.h, getopt-wrapper.c,
getopt-wrapper.h, glob-wrappers.c, glob-wrappers.h, hash-wrappers.c,
hash-wrappers.h, localcharset-wrapper.c, localcharset-wrapper.h,
math-wrappers.c, math-wrappers.h, mkostemp-wrapper.c, mkostemp-wrapper.h,
nanosleep-wrapper.c, nanosleep-wrapper.h, nproc-wrapper.c, nproc-wrapper.h,
octave-popen2.c, octave-popen2.h, putenv-wrapper.c, putenv-wrapper.h,
set-program-name-wrapper.c, set-program-name-wrapper.h, signal-wrappers.c,
signal-wrappers.h, stat-wrappers.c, stat-wrappers.h, strdup-wrapper.c,
strdup-wrapper.h, strftime-wrapper.c, strftime-wrapper.h, strmode-wrapper.c,
strmode-wrapper.h, strptime-wrapper.c, strptime-wrapper.h, time-wrappers.c,
time-wrappers.h, tmpfile-wrapper.c, tmpfile-wrapper.h, uname-wrapper.c,
uname-wrapper.h, uniconv-wrappers.c, uniconv-wrappers.h, unistd-wrappers.c,
unistd-wrappers.h, unsetenv-wrapper.c, unsetenv-wrapper.h, vasprintf-wrapper.c,
vasprintf-wrapper.h, wait-for-input.c, wait-for-input.h, wait-wrappers.c,
wait-wrappers.h, acinclude.m4, ax_blas.m4, ax_lapack.m4, ax_openmp.m4,
ax_pthread.m4, octave_blas_f77_func.m4, pkg.m4, oct-conf-post.in.h,
run-octave.in, Map.m, ascii.m, binary.m, cd.m, close.m, delete.m,
dir.m, disp.m, ftp.m, loadobj.m, mget.m, mkdir.m, mput.m, rename.m, rmdir.m,
saveobj.m, __get_properties__.m, audioplayer.m, disp.m, get.m, isplaying.m,
pause.m, play.m, playblocking.m, resume.m, set.m, stop.m, subsasgn.m,
subsref.m, __get_properties__.m, audiorecorder.m, disp.m, get.m,
getaudiodata.m, getplayer.m, isrecording.m, pause.m, play.m, record.m,
recordblocking.m, resume.m, set.m, stop.m, subsasgn.m, subsref.m, lin2mu.m,
mu2lin.m, record.m, sound.m, soundsc.m, bitmax.m, chop.m, comma.m, isstr.m,
mahalanobis.m, md5sum.m, octave_config_info.m, onenormest.m, paren.m,
semicolon.m, sleep.m, usleep.m, wavread.m, wavwrite.m, acosd.m, acot.m,
acotd.m, acoth.m, acsc.m, acscd.m, acsch.m, asec.m, asecd.m, asech.m, asind.m,
atan2d.m, atand.m, cosd.m, cot.m, cotd.m, coth.m, csc.m, cscd.m, csch.m, sec.m,
secd.m, sech.m, sind.m, tand.m, accumarray.m, accumdim.m, bincoeff.m, bitcmp.m,
bitget.m, bitset.m, blkdiag.m, cart2pol.m, cart2sph.m, cell2mat.m, celldisp.m,
circshift.m, common_size.m, cplxpair.m, cumtrapz.m, curl.m, dblquad.m, deal.m,
deg2rad.m, del2.m, divergence.m, flip.m, flipdim.m, fliplr.m, flipud.m,
gradient.m, idivide.m, int2str.m, integral.m, integral2.m, integral3.m,
interp1.m, interp2.m, interp3.m, interpft.m, interpn.m, isequal.m, isequaln.m,
logspace.m, nextpow2.m, num2str.m, pol2cart.m, polyarea.m, postpad.m, prepad.m,
__splinen__.m, quad2d.m, quadgk.m, quadl.m, quadv.m, rad2deg.m, randi.m, rat.m,
repelem.m, repmat.m, rot90.m, rotdim.m, shift.m, shiftdim.m, sortrows.m,
sph2cart.m, structfun.m, subsindex.m, trapz.m, triplequad.m, xor.m, convhull.m,
delaunay.m, delaunayn.m, dsearch.m, dsearchn.m, griddata.m, griddata3.m,
griddatan.m, inpolygon.m, rectint.m, tsearchn.m, voronoi.m, voronoin.m,
dialog.m, errordlg.m, getappdata.m, guidata.m, guihandles.m, helpdlg.m,
inputdlg.m, isappdata.m, listdlg.m, msgbox.m, __file_filter__.m,
__fltk_file_filter__.m, __get_funcname__.m, __is_function__.m,
__uigetdir_fltk__.m, __uigetfile_fltk__.m, __uiobject_split_args__.m,
__uiputfile_fltk__.m, questdlg.m, rmappdata.m, setappdata.m, uibuttongroup.m,
uicontextmenu.m, uicontrol.m, uigetdir.m, uigetfile.m, uimenu.m, uipanel.m,
uipushtool.m, uiputfile.m, uiresume.m, uitoggletool.m, uitoolbar.m, uiwait.m,
waitbar.m, waitforbuttonpress.m, warndlg.m, __gripe_missing_component__.m,
__makeinfo__.m, __unimplemented__.m, ans.m, debug.m, doc.m, doc_cache_create.m,
error_ids.m, get_first_help_sentence.m, help.m, lookfor.m, print_usage.m,
__additional_help_message__.m, __strip_html_tags__.m, slash.m, type.m,
warning_ids.m, which.m, autumn.m, bone.m, brighten.m, cmpermute.m, cmunique.m,
colorcube.m, colormap.m, contrast.m, cool.m, copper.m, cubehelix.m, flag.m,
frame2im.m, getframe.m, gray.m, gray2ind.m, hot.m, hsv.m, hsv2rgb.m,
im2double.m, im2frame.m, image.m, imagesc.m, imfinfo.m, imformats.m, imread.m,
imshow.m, imwrite.m, ind2gray.m, ind2rgb.m, iscolormap.m, jet.m, lines.m,
ntsc2rgb.m, ocean.m, pink.m, prism.m, __imfinfo__.m, __imread__.m,
__imwrite__.m, colorspace_conversion_input_check.m,
colorspace_conversion_revert.m, imageIO.m, imwrite_filename.m, ind2x.m,
rainbow.m, rgb2hsv.m, rgb2ind.m, rgb2ntsc.m, rgbplot.m, spinmap.m, spring.m,
summer.m, viridis.m, white.m, winter.m, beep.m, csvread.m, csvwrite.m,
dlmwrite.m, fileread.m, importdata.m, is_valid_file_id.m, strread.m,
textread.m, javaArray.m, java_get.m, java_set.m, javaaddpath.m, javachk.m,
javaclasspath.m, javamem.m, javarmpath.m, ClassHelper.java, Matrix.java,
OctClassLoader.java, Octave.java, OctaveReference.java, usejava.m, bandwidth.m,
commutation_matrix.m, cond.m, condeig.m, condest.m, cross.m,
duplication_matrix.m, expm.m, gls.m, housh.m, isbanded.m, isdefinite.m,
isdiag.m, ishermitian.m, issymmetric.m, istril.m, istriu.m, krylov.m,
linsolve.m, logm.m, lscov.m, normest.m, normest1.m, null.m, ols.m, orth.m,
planerot.m, qzhess.m, rank.m, rref.m, subspace.m, trace.m, vech.m, vecnorm.m,
bug_report.m, bunzip2.m, cast.m, citation.m, compare_versions.m, computer.m,
copyfile.m, delete.m, desktop.m, dir.m, dos.m, edit.m, fact.m, fieldnames.m,
fileattrib.m, fileparts.m, fullfile.m, genvarname.m, getfield.m, grabcode.m,
gunzip.m, info.m, inputParser.m, inputname.m, isdeployed.m, isdir.m, ismac.m,
ispc.m, isunix.m, license.m, list_primes.m, loadobj.m, ls.m, ls_command.m,
menu.m, methods.m, mex.m, mexext.m, mkdir.m, mkoctfile.m, movefile.m,
namelengthmax.m, nargchk.m, narginchk.m, nargoutchk.m, news.m, nthargout.m,
open.m, orderfields.m, pack.m, parseparams.m, perl.m,
__publish_html_output__.m, __publish_latex_output__.m, __w2mpth__.m,
display_info_file.m, publish.m, python.m, recycle.m, run.m, saveobj.m,
setfield.m, substruct.m, swapbytes.m, symvar.m, tar.m, tempdir.m, tmpnam.m,
unix.m, unpack.m, untar.m, unzip.m, validateattributes.m, ver.m, version.m,
what.m, zip.m, mk-doc.pl, mk-pkg-add.sh, decic.m, ode15i.m, ode15s.m, ode23.m,
ode45.m, odeget.m, odeplot.m, odeset.m, AbsRel_norm.m, check_default_input.m,
integrate_adaptive.m, kahan.m, ode_event_handler.m, odedefaults.m,
odemergeopts.m, runge_kutta_23.m, runge_kutta_45_dorpri.m,
runge_kutta_interpolate.m, starting_stepsize.m, __all_opts__.m, fminbnd.m,
fminsearch.m, fminunc.m, fsolve.m, fzero.m, glpk.m, humps.m, lsqnonneg.m,
optimget.m, optimset.m, pqpnonneg.m, __fdjac__.m, qp.m, sqp.m, import.m,
matlabroot.m, pathdef.m, getsavepath.m, savepath.m, pkg.m, build.m,
configure_make.m, default_prefix.m, describe.m, dirempty.m, get_description.m,
get_forge_download.m, get_forge_pkg.m, get_unsatisfied_deps.m, getarch.m,
getarchdir.m, install.m, installed_packages.m, list_forge_packages.m,
load_packages.m, load_packages_and_dependencies.m, rebuild.m, save_order.m,
uninstall.m, unload_packages.m, __clabel__.m, __getlegenddata__.m,
__rotate_around_axis__.m, annotation.m, axis.m, box.m, camlookat.m, camorbit.m,
campos.m, camroll.m, camtarget.m, camup.m, camva.m, camzoom.m, caxis.m,
clabel.m, daspect.m, datetick.m, diffuse.m, grid.m, gtext.m, hidden.m,
legend.m, lighting.m, material.m, orient.m, pbaspect.m, __axis_label__.m,
__axis_limits__.m, rticks.m, shading.m, specular.m, text.m, thetaticks.m,
title.m, view.m, whitebg.m, xlabel.m, xlim.m, xticklabels.m, xticks.m,
ylabel.m, ylim.m, yticklabels.m, yticks.m, zlabel.m, zlim.m, zticklabels.m,
zticks.m, area.m, bar.m, barh.m, camlight.m, colorbar.m, comet.m, comet3.m,
compass.m, contour.m, contour3.m, contourc.m, contourf.m, cylinder.m,
ellipsoid.m, errorbar.m, ezcontour.m, ezcontourf.m, ezmesh.m, ezmeshc.m,
ezplot.m, ezplot3.m, ezpolar.m, ezsurf.m, ezsurfc.m, feather.m, fill.m,
fplot.m, hist.m, isocaps.m, isocolors.m, isonormals.m, isosurface.m, light.m,
line.m, loglog.m, loglogerr.m, mesh.m, meshc.m, meshz.m, pareto.m, patch.m,
pcolor.m, peaks.m, pie.m, pie3.m, plot.m, plot3.m, plotmatrix.m, plotyy.m,
polar.m, __add_datasource__.m, __bar__.m, __calc_isovalue_from_data__.m,
__contour__.m, __errplot__.m, __ezplot__.m, __interp_cube__.m, __line__.m,
__marching_cube__.m, __patch__.m, __pie__.m, __plt__.m, __quiver__.m,
__scatter__.m, __stem__.m, __unite_shared_vertices__.m, quiver.m, quiver3.m,
rectangle.m, reducepatch.m, reducevolume.m, ribbon.m, rose.m, scatter.m,
scatter3.m, semilogx.m, semilogxerr.m, semilogy.m, semilogyerr.m,
shrinkfaces.m, slice.m, smooth3.m, sombrero.m, sphere.m, stairs.m, stem.m,
stem3.m, stemleaf.m, surf.m, surface.m, surfc.m, surfl.m, surfnorm.m,
tetramesh.m, trimesh.m, triplot.m, trisurf.m, waterfall.m,
__actual_axis_position__.m, __default_plot_options__.m, __gnuplot_drawnow__.m,
__next_line_color__.m, __next_line_style__.m, __opengl_info__.m,
__plt_get_axis_arg__.m, __pltopt__.m, allchild.m, ancestor.m, axes.m, cla.m,
clf.m, close.m, closereq.m, colstyle.m, copyobj.m, figure.m, findall.m,
findfigs.m, findobj.m, gca.m, gcbf.m, gcbo.m, gcf.m, gco.m, ginput.m,
gnuplot_binary.in.m, graphics_toolkit.m, groot.m, hdl2struct.m, hggroup.m,
hgload.m, hgsave.m, hgtransform.m, hold.m, isaxes.m, isfigure.m, isgraphics.m,
ishandle.m, ishold.m, isprop.m, linkaxes.m, linkprop.m, meshgrid.m, ndgrid.m,
newplot.m, pan.m, print.m, printd.m, __add_default_menu__.m, __ghostscript__.m,
__gnuplot_draw_axes__.m, __gnuplot_draw_figure__.m, __gnuplot_get_var__.m,
__gnuplot_ginput__.m, __gnuplot_has_feature__.m, __gnuplot_has_terminal__.m,
__gnuplot_open_stream__.m, __gnuplot_print__.m, __gnuplot_version__.m,
__opengl_print__.m, __print_parse_opts__.m, __set_default_mouse_modes__.m,
refresh.m, refreshdata.m, rotate.m, rotate3d.m, saveas.m, shg.m, struct2hdl.m,
subplot.m, zoom.m, compan.m, conv.m, deconv.m, mkpp.m, mpoles.m, padecoef.m,
pchip.m, poly.m, polyaffine.m, polyder.m, polyeig.m, polyfit.m, polygcd.m,
polyint.m, polyout.m, polyreduce.m, polyval.m, polyvalm.m, ppder.m, ppint.m,
ppjumps.m, ppval.m, residue.m, roots.m, spline.m, splinefit.m, unmkpp.m,
addpref.m, getpref.m, ispref.m, prefdir.m, preferences.m, loadprefs.m,
prefsfile.m, saveprefs.m, rmpref.m, setpref.m, style.css, profexplore.m,
profexport.m, profile.m, profshow.m, intersect.m, ismember.m, powerset.m,
validsetargs.m, setdiff.m, setxor.m, union.m, unique.m, arch_fit.m, arch_rnd.m,
arch_test.m, arma_rnd.m, autoreg_matrix.m, bartlett.m, blackman.m, detrend.m,
diffpara.m, durbinlevinson.m, fftconv.m, fftfilt.m, fftshift.m, filter2.m,
fractdiff.m, freqz.m, freqz_plot.m, hamming.m, hanning.m, hurst.m, ifftshift.m,
periodogram.m, rectangle_lw.m, rectangle_sw.m, triangle_lw.m, triangle_sw.m,
sinc.m, sinetone.m, sinewave.m, spectral_adf.m, spectral_xdf.m, spencer.m,
stft.m, synthesis.m, unwrap.m, yulewalker.m, bicg.m, bicgstab.m, cgs.m,
colperm.m, eigs.m, etreeplot.m, gmres.m, gplot.m, ichol.m, ilu.m, nonzeros.m,
pcg.m, pcr.m, __sprand__.m, qmr.m, spaugment.m, spconvert.m, spdiags.m,
speye.m, spfun.m, spones.m, sprand.m, sprandn.m, sprandsym.m, spstats.m, spy.m,
svds.m, treelayout.m, treeplot.m, bessel.m, beta.m, betaln.m, ellipke.m,
expint.m, factor.m, factorial.m, isprime.m, lcm.m, legendre.m, nchoosek.m,
nthroot.m, perms.m, pow2.m, primes.m, reallog.m, realpow.m, realsqrt.m,
gallery.m, hadamard.m, hankel.m, hilb.m, invhilb.m, magic.m, pascal.m,
rosser.m, toeplitz.m, vander.m, wilkinson.m, __finish__.m, center.m, cloglog.m,
corr.m, corrcoef.m, cov.m, crosstab.m, histc.m, iqr.m, kendall.m, kurtosis.m,
logit.m, mean.m, meansq.m, median.m, mode.m, moment.m, ppplot.m, prctile.m,
probit.m, qqplot.m, quantile.m, range.m, ranks.m, run_count.m, runlength.m,
skewness.m, spearman.m, statistics.m, std.m, var.m, zscore.m, betacdf.m,
betainv.m, betapdf.m, betarnd.m, binocdf.m, binoinv.m, binopdf.m, binornd.m,
cauchy_cdf.m, cauchy_inv.m, cauchy_pdf.m, cauchy_rnd.m, chi2cdf.m, chi2inv.m,
chi2pdf.m, chi2rnd.m, discrete_cdf.m, discrete_inv.m, discrete_pdf.m,
discrete_rnd.m, empirical_cdf.m, empirical_inv.m, empirical_pdf.m,
empirical_rnd.m, expcdf.m, expinv.m, exppdf.m, exprnd.m, fcdf.m, finv.m,
fpdf.m, frnd.m, gamcdf.m, gaminv.m, gampdf.m, gamrnd.m, geocdf.m, geoinv.m,
geopdf.m, geornd.m, hygecdf.m, hygeinv.m, hygepdf.m, hygernd.m,
kolmogorov_smirnov_cdf.m, laplace_cdf.m, laplace_inv.m, laplace_pdf.m,
laplace_rnd.m, logistic_cdf.m, logistic_inv.m, logistic_pdf.m, logistic_rnd.m,
logncdf.m, logninv.m, lognpdf.m, lognrnd.m, nbincdf.m, nbininv.m, nbinpdf.m,
nbinrnd.m, normcdf.m, norminv.m, normpdf.m, normrnd.m, poisscdf.m, poissinv.m,
poisspdf.m, poissrnd.m, stdnormal_cdf.m, stdnormal_inv.m, stdnormal_pdf.m,
stdnormal_rnd.m, tcdf.m, tinv.m, tpdf.m, trnd.m, unidcdf.m, unidinv.m,
unidpdf.m, unidrnd.m, unifcdf.m, unifinv.m, unifpdf.m, unifrnd.m, wblcdf.m,
wblinv.m, wblpdf.m, wblrnd.m, wienrnd.m, logistic_regression.m,
logistic_regression_derivatives.m, logistic_regression_likelihood.m, anova.m,
bartlett_test.m, chisquare_test_homogeneity.m, chisquare_test_independence.m,
cor_test.m, f_test_regression.m, hotelling_test.m, hotelling_test_2.m,
kolmogorov_smirnov_test.m, kolmogorov_smirnov_test_2.m, kruskal_wallis_test.m,
manova.m, mcnemar_test.m, prop_test_2.m, run_test.m, sign_test.m, t_test.m,
t_test_2.m, t_test_regression.m, u_test.m, var_test.m, welch_test.m,
wilcoxon_test.m, z_test.m, z_test_2.m, base2dec.m, bin2dec.m, blanks.m,
cstrcat.m, deblank.m, dec2base.m, dec2bin.m, dec2hex.m, erase.m, findstr.m,
hex2dec.m, index.m, isletter.m, isstring.m, isstrprop.m, mat2str.m,
native2unicode.m, ostrsplit.m, regexptranslate.m, rindex.m, str2num.m,
strcat.m, strchr.m, strjoin.m, strjust.m, strmatch.m, strsplit.m, strtok.m,
strtrim.m, strtrunc.m, substr.m, unicode2native.m, untabify.m,
validatestring.m, __have_feature__.m, __printf_assert__.m,
__prog_output_assert__.m, __run_test_suite__.m, assert.m, demo.m, example.m,
fail.m, compare_plot_demos.m, dump_demos.m, html_compare_plot_demos.m,
rundemos.m, runtests.m, speed.m, test.m, addtodate.m, asctime.m, calendar.m,
clock.m, ctime.m, date.m, datenum.m, datestr.m, datevec.m, eomday.m, etime.m,
is_leap_year.m, now.m, weekday.m, display-available.c, display-available.h,
main-cli.cc, main-gui.cc, main.in.cc, mkoctfile.in.cc, octave-build-info.h,
octave-build-info.in.cc, octave-config.in.cc, shared-fcns.h, args.tst,
bug-31371.tst, bug-35448.tst, bug-35881.tst, bug-36025.tst, bug-38236.tst,
bug-38565.tst, bug-38576.tst, bug-38691.tst, bug-41723.tst, bug-44940.tst,
bug-46330.tst, bug-46660.tst, bug-50014.tst, bug-50035.tst, bug-50716.tst,
bug-51192.tst, bug-51532.tst, bug-51534.tst, bug-51599.tst, bug-52075.tst,
class-concat.tst, classdef-multiple-inheritance.tst, classdef.tst, classes.tst,
colormaps.tst, command.tst, complex.tst, ctor-vs-method.tst,
deprecate-props.tst, diag-perm.tst, error.tst, eval-catch.tst,
fcn-handle-derived-resolution.tst, fntests.m, for.tst, func.tst, global.tst,
if.tst, index.tst, io.tst, jit.tst, leftdiv.tst, line-continue.tst,
logical-index.tst, mk-bc-overloads-tst.sh, mk-conv-tst.sh, mk-sparse-tst.sh,
nest.tst, null-assign.tst, parser.tst, prefer.tst, publish.tst, range.tst,
recursion.tst, return.tst, show-failures.awk, single-index.tst, slice.tst,
struct.tst, switch.tst, system.tst, transpose.tst, try.tst, unwind.tst,
while.tst:
Changed punctuation of GPL license text to match that suggested by FSF.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 06 Jan 2018 07:57:19 -0800 |
parents | d20b385d8c99 |
children | 2365c2661b3c |
rev | line source |
---|---|
16634 | 1 ## Copyright (C) 1989-1995 Nicholas .J. Higham |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
22021
diff
changeset
|
2 ## Copyright (C) 2013-2016 Carnë Draug |
16634 | 3 ## |
4 ## This file is part of Octave. | |
5 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23384
diff
changeset
|
6 ## Octave is free software: you can redistribute it and/or modify it |
16634 | 7 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23384
diff
changeset
|
8 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
9 ## (at your option) any later version. |
16634 | 10 ## |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
14 ## GNU General Public License for more details. |
16634 | 15 ## |
16 ## You should have received a copy of the GNU General Public License | |
17 ## along with Octave; see the file COPYING. If not, see | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23384
diff
changeset
|
18 ## <https://www.gnu.org/licenses/>. |
16634 | 19 |
20 ## -*- texinfo -*- | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
21 ## @deftypefn {} {} gallery (@var{name}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
22 ## @deftypefnx {} {} gallery (@var{name}, @var{args}) |
16634 | 23 ## Create interesting matrices for testing. |
24 ## | |
25 ## @end deftypefn | |
26 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
27 ## @deftypefn {} {@var{c} =} gallery ("cauchy", @var{x}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
28 ## @deftypefnx {} {@var{c} =} gallery ("cauchy", @var{x}, @var{y}) |
16634 | 29 ## Create a Cauchy matrix. |
30 ## | |
31 ## @end deftypefn | |
32 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
33 ## @deftypefn {} {@var{c} =} gallery ("chebspec", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
34 ## @deftypefnx {} {@var{c} =} gallery ("chebspec", @var{n}, @var{k}) |
16634 | 35 ## Create a Chebyshev spectral differentiation matrix. |
36 ## | |
37 ## @end deftypefn | |
38 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
39 ## @deftypefn {} {@var{c} =} gallery ("chebvand", @var{p}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
40 ## @deftypefnx {} {@var{c} =} gallery ("chebvand", @var{m}, @var{p}) |
16634 | 41 ## Create a Vandermonde-like matrix for the Chebyshev polynomials. |
42 ## | |
43 ## @end deftypefn | |
44 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
45 ## @deftypefn {} {@var{a} =} gallery ("chow", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
46 ## @deftypefnx {} {@var{a} =} gallery ("chow", @var{n}, @var{alpha}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
47 ## @deftypefnx {} {@var{a} =} gallery ("chow", @var{n}, @var{alpha}, @var{delta}) |
16634 | 48 ## Create a Chow matrix -- a singular Toeplitz lower Hessenberg matrix. |
49 ## | |
50 ## @end deftypefn | |
51 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
52 ## @deftypefn {} {@var{c} =} gallery ("circul", @var{v}) |
16634 | 53 ## Create a circulant matrix. |
54 ## | |
55 ## @end deftypefn | |
56 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
57 ## @deftypefn {} {@var{a} =} gallery ("clement", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
58 ## @deftypefnx {} {@var{a} =} gallery ("clement", @var{n}, @var{k}) |
16634 | 59 ## Create a tridiagonal matrix with zero diagonal entries. |
60 ## | |
61 ## @end deftypefn | |
62 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
63 ## @deftypefn {} {@var{c} =} gallery ("compar", @var{a}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
64 ## @deftypefnx {} {@var{c} =} gallery ("compar", @var{a}, @var{k}) |
16634 | 65 ## Create a comparison matrix. |
66 ## | |
67 ## @end deftypefn | |
68 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
69 ## @deftypefn {} {@var{a} =} gallery ("condex", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
70 ## @deftypefnx {} {@var{a} =} gallery ("condex", @var{n}, @var{k}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
71 ## @deftypefnx {} {@var{a} =} gallery ("condex", @var{n}, @var{k}, @var{theta}) |
16634 | 72 ## Create a `counterexample' matrix to a condition estimator. |
73 ## | |
74 ## @end deftypefn | |
75 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
76 ## @deftypefn {} {@var{a} =} gallery ("cycol", [@var{m} @var{n}]) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
77 ## @deftypefnx {} {@var{a} =} gallery ("cycol", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
78 ## @deftypefnx {} {@var{a} =} gallery (@dots{}, @var{k}) |
16634 | 79 ## Create a matrix whose columns repeat cyclically. |
80 ## | |
81 ## @end deftypefn | |
82 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
83 ## @deftypefn {} {[@var{c}, @var{d}, @var{e}] =} gallery ("dorr", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
84 ## @deftypefnx {} {[@var{c}, @var{d}, @var{e}] =} gallery ("dorr", @var{n}, @var{theta}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
85 ## @deftypefnx {} {@var{a} =} gallery ("dorr", @dots{}) |
19040
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
18846
diff
changeset
|
86 ## Create a diagonally dominant, ill-conditioned, tridiagonal matrix. |
16634 | 87 ## |
88 ## @end deftypefn | |
89 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
90 ## @deftypefn {} {@var{a} =} gallery ("dramadah", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
91 ## @deftypefnx {} {@var{a} =} gallery ("dramadah", @var{n}, @var{k}) |
16634 | 92 ## Create a (0, 1) matrix whose inverse has large integer entries. |
93 ## | |
94 ## @end deftypefn | |
95 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
96 ## @deftypefn {} {@var{a} =} gallery ("fiedler", @var{c}) |
19040
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
18846
diff
changeset
|
97 ## Create a symmetric @nospell{Fiedler} matrix. |
16634 | 98 ## |
99 ## @end deftypefn | |
100 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
101 ## @deftypefn {} {@var{a} =} gallery ("forsythe", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
102 ## @deftypefnx {} {@var{a} =} gallery ("forsythe", @var{n}, @var{alpha}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
103 ## @deftypefnx {} {@var{a} =} gallery ("forsythe", @var{n}, @var{alpha}, @var{lambda}) |
19040
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
18846
diff
changeset
|
104 ## Create a @nospell{Forsythe} matrix (a perturbed Jordan block). |
16634 | 105 ## |
106 ## @end deftypefn | |
107 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
108 ## @deftypefn {} {@var{f} =} gallery ("frank", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
109 ## @deftypefnx {} {@var{f} =} gallery ("frank", @var{n}, @var{k}) |
19040
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
18846
diff
changeset
|
110 ## Create a Frank matrix (ill-conditioned eigenvalues). |
16634 | 111 ## |
112 ## @end deftypefn | |
113 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
114 ## @deftypefn {} {@var{c} =} gallery ("gcdmat", @var{n}) |
16634 | 115 ## Create a greatest common divisor matrix. |
116 ## | |
117 ## @var{c} is an @var{n}-by-@var{n} matrix whose values correspond to the | |
118 ## greatest common divisor of its coordinate values, i.e., @var{c}(i,j) | |
119 ## correspond @code{gcd (i, j)}. | |
120 ## @end deftypefn | |
121 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
122 ## @deftypefn {} {@var{a} =} gallery ("gearmat", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
123 ## @deftypefnx {} {@var{a} =} gallery ("gearmat", @var{n}, @var{i}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
124 ## @deftypefnx {} {@var{a} =} gallery ("gearmat", @var{n}, @var{i}, @var{j}) |
16634 | 125 ## Create a Gear matrix. |
126 ## | |
127 ## @end deftypefn | |
128 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
129 ## @deftypefn {} {@var{g} =} gallery ("grcar", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
130 ## @deftypefnx {} {@var{g} =} gallery ("grcar", @var{n}, @var{k}) |
16634 | 131 ## Create a Toeplitz matrix with sensitive eigenvalues. |
132 ## | |
133 ## @end deftypefn | |
134 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
135 ## @deftypefn {} {@var{a} =} gallery ("hanowa", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
136 ## @deftypefnx {} {@var{a} =} gallery ("hanowa", @var{n}, @var{d}) |
16816
12005245b645
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
137 ## Create a matrix whose eigenvalues lie on a vertical line in the complex |
12005245b645
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
138 ## plane. |
16634 | 139 ## |
140 ## @end deftypefn | |
141 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
142 ## @deftypefn {} {@var{v} =} gallery ("house", @var{x}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
143 ## @deftypefnx {} {[@var{v}, @var{beta}] =} gallery ("house", @var{x}) |
16634 | 144 ## Create a householder matrix. |
145 ## | |
146 ## @end deftypefn | |
147 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
148 ## @deftypefn {} {@var{a} =} gallery ("integerdata", @var{imax}, [@var{M} @var{N} @dots{}], @var{j}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
149 ## @deftypefnx {} {@var{a} =} gallery ("integerdata", @var{imax}, @var{M}, @var{N}, @dots{}, @var{j}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
150 ## @deftypefnx {} {@var{a} =} gallery ("integerdata", [@var{imin}, @var{imax}], [@var{M} @var{N} @dots{}], @var{j}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
151 ## @deftypefnx {} {@var{a} =} gallery ("integerdata", [@var{imin}, @var{imax}], @var{M}, @var{N}, @dots{}, @var{j}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
152 ## @deftypefnx {} {@var{a} =} gallery ("integerdata", @dots{}, "@var{class}") |
16982
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
153 ## Create a matrix with random integers in the range [1, @var{imax}]. |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
154 ## If @var{imin} is given then the integers are in the range |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
155 ## [@var{imin}, @var{imax}]. |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
156 ## |
21546
f7f97d7e9294
doc: Wrap m-file docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents:
21385
diff
changeset
|
157 ## The second input is a matrix of dimensions describing the size of the |
f7f97d7e9294
doc: Wrap m-file docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents:
21385
diff
changeset
|
158 ## output. The dimensions can also be input as comma-separated arguments. |
16982
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
159 ## |
20162
2645f9ef8c88
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19944
diff
changeset
|
160 ## The input @var{j} is an integer index in the range [0, 2^32-1]. The values |
2645f9ef8c88
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19944
diff
changeset
|
161 ## of the output matrix are always exactly the same (reproducibility) for a |
2645f9ef8c88
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19944
diff
changeset
|
162 ## given size input and @var{j} index. |
16982
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
163 ## |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
164 ## The final optional argument determines the class of the resulting matrix. |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17199
diff
changeset
|
165 ## Possible values for @var{class}: @qcode{"uint8"}, @qcode{"uint16"}, |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17199
diff
changeset
|
166 ## @qcode{"uint32"}, @qcode{"int8"}, @qcode{"int16"}, int32", @qcode{"single"}, |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17199
diff
changeset
|
167 ## @qcode{"double"}. The default is @qcode{"double"}. |
16982
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
168 ## |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
169 ## @end deftypefn |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
170 ## |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
171 ## @deftypefn {} {@var{a} =} gallery ("invhess", @var{x}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
172 ## @deftypefnx {} {@var{a} =} gallery ("invhess", @var{x}, @var{y}) |
16634 | 173 ## Create the inverse of an upper Hessenberg matrix. |
174 ## | |
175 ## @end deftypefn | |
176 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
177 ## @deftypefn {} {@var{a} =} gallery ("invol", @var{n}) |
16634 | 178 ## Create an involutory matrix. |
179 ## | |
180 ## @end deftypefn | |
181 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
182 ## @deftypefn {} {@var{a} =} gallery ("ipjfact", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
183 ## @deftypefnx {} {@var{a} =} gallery ("ipjfact", @var{n}, @var{k}) |
20162
2645f9ef8c88
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19944
diff
changeset
|
184 ## Create a Hankel matrix with factorial elements. |
16634 | 185 ## |
186 ## @end deftypefn | |
187 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
188 ## @deftypefn {} {@var{a} =} gallery ("jordbloc", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
189 ## @deftypefnx {} {@var{a} =} gallery ("jordbloc", @var{n}, @var{lambda}) |
16634 | 190 ## Create a Jordan block. |
191 ## | |
192 ## @end deftypefn | |
193 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
194 ## @deftypefn {} {@var{u} =} gallery ("kahan", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
195 ## @deftypefnx {} {@var{u} =} gallery ("kahan", @var{n}, @var{theta}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
196 ## @deftypefnx {} {@var{u} =} gallery ("kahan", @var{n}, @var{theta}, @var{pert}) |
19040
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
18846
diff
changeset
|
197 ## Create a @nospell{Kahan} matrix (upper trapezoidal). |
16634 | 198 ## |
199 ## @end deftypefn | |
200 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
201 ## @deftypefn {} {@var{a} =} gallery ("kms", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
202 ## @deftypefnx {} {@var{a} =} gallery ("kms", @var{n}, @var{rho}) |
19040
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
18846
diff
changeset
|
203 ## Create a @nospell{Kac-Murdock-Szego} Toeplitz matrix. |
16634 | 204 ## |
205 ## @end deftypefn | |
206 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
207 ## @deftypefn {} {@var{b} =} gallery ("krylov", @var{a}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
208 ## @deftypefnx {} {@var{b} =} gallery ("krylov", @var{a}, @var{x}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
209 ## @deftypefnx {} {@var{b} =} gallery ("krylov", @var{a}, @var{x}, @var{j}) |
16634 | 210 ## Create a Krylov matrix. |
211 ## | |
212 ## @end deftypefn | |
213 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
214 ## @deftypefn {} {@var{a} =} gallery ("lauchli", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
215 ## @deftypefnx {} {@var{a} =} gallery ("lauchli", @var{n}, @var{mu}) |
19040
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
18846
diff
changeset
|
216 ## Create a @nospell{Lauchli} matrix (rectangular). |
16634 | 217 ## |
218 ## @end deftypefn | |
219 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
220 ## @deftypefn {} {@var{a} =} gallery ("lehmer", @var{n}) |
19040
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
18846
diff
changeset
|
221 ## Create a @nospell{Lehmer} matrix (symmetric positive definite). |
16634 | 222 ## |
223 ## @end deftypefn | |
224 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
225 ## @deftypefn {} {@var{t} =} gallery ("lesp", @var{n}) |
16634 | 226 ## Create a tridiagonal matrix with real, sensitive eigenvalues. |
227 ## | |
228 ## @end deftypefn | |
229 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
230 ## @deftypefn {} {@var{a} =} gallery ("lotkin", @var{n}) |
19040
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
18846
diff
changeset
|
231 ## Create a @nospell{Lotkin} matrix. |
16634 | 232 ## |
233 ## @end deftypefn | |
234 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
235 ## @deftypefn {} {@var{a} =} gallery ("minij", @var{n}) |
16634 | 236 ## Create a symmetric positive definite matrix MIN(i,j). |
237 ## | |
238 ## @end deftypefn | |
239 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
240 ## @deftypefn {} {@var{a} =} gallery ("moler", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
241 ## @deftypefnx {} {@var{a} =} gallery ("moler", @var{n}, @var{alpha}) |
19040
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
18846
diff
changeset
|
242 ## Create a @nospell{Moler} matrix (symmetric positive definite). |
16634 | 243 ## |
244 ## @end deftypefn | |
245 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
246 ## @deftypefn {} {[@var{a}, @var{t}] =} gallery ("neumann", @var{n}) |
16634 | 247 ## Create a singular matrix from the discrete Neumann problem (sparse). |
248 ## | |
249 ## @end deftypefn | |
250 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
251 ## @deftypefn {} {@var{a} =} gallery ("normaldata", [@var{M} @var{N} @dots{}], @var{j}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
252 ## @deftypefnx {} {@var{a} =} gallery ("normaldata", @var{M}, @var{N}, @dots{}, @var{j}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
253 ## @deftypefnx {} {@var{a} =} gallery ("normaldata", @dots{}, "@var{class}") |
16982
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
254 ## Create a matrix with random samples from the standard normal distribution |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
255 ## (mean = 0, std = 1). |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
256 ## |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
257 ## The first input is a matrix of dimensions describing the size of the output. |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
258 ## The dimensions can also be input as comma-separated arguments. |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
259 ## |
20162
2645f9ef8c88
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19944
diff
changeset
|
260 ## The input @var{j} is an integer index in the range [0, 2^32-1]. The values |
2645f9ef8c88
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19944
diff
changeset
|
261 ## of the output matrix are always exactly the same (reproducibility) for a |
2645f9ef8c88
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19944
diff
changeset
|
262 ## given size input and @var{j} index. |
16982
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
263 ## |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
264 ## The final optional argument determines the class of the resulting matrix. |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17199
diff
changeset
|
265 ## Possible values for @var{class}: @qcode{"single"}, @qcode{"double"}. |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17199
diff
changeset
|
266 ## The default is @qcode{"double"}. |
16982
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
267 ## |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
268 ## @end deftypefn |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
269 ## |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
270 ## @deftypefn {} {@var{q} =} gallery ("orthog", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
271 ## @deftypefnx {} {@var{q} =} gallery ("orthog", @var{n}, @var{k}) |
16634 | 272 ## Create orthogonal and nearly orthogonal matrices. |
273 ## | |
274 ## @end deftypefn | |
275 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
276 ## @deftypefn {} {@var{a} =} gallery ("parter", @var{n}) |
19040
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
18846
diff
changeset
|
277 ## Create a @nospell{Parter} matrix (a Toeplitz matrix with singular values |
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
18846
diff
changeset
|
278 ## near pi). |
16634 | 279 ## |
280 ## @end deftypefn | |
281 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
282 ## @deftypefn {} {@var{p} =} gallery ("pei", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
283 ## @deftypefnx {} {@var{p} =} gallery ("pei", @var{n}, @var{alpha}) |
16634 | 284 ## Create a Pei matrix. |
285 ## | |
286 ## @end deftypefn | |
287 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
288 ## @deftypefn {} {@var{a} =} gallery ("Poisson", @var{n}) |
16634 | 289 ## Create a block tridiagonal matrix from Poisson's equation (sparse). |
290 ## | |
291 ## @end deftypefn | |
292 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
293 ## @deftypefn {} {@var{a} =} gallery ("prolate", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
294 ## @deftypefnx {} {@var{a} =} gallery ("prolate", @var{n}, @var{w}) |
16634 | 295 ## Create a prolate matrix (symmetric, ill-conditioned Toeplitz matrix). |
296 ## | |
297 ## @end deftypefn | |
298 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
299 ## @deftypefn {} {@var{h} =} gallery ("randhess", @var{x}) |
16634 | 300 ## Create a random, orthogonal upper Hessenberg matrix. |
301 ## | |
302 ## @end deftypefn | |
303 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
304 ## @deftypefn {} {@var{a} =} gallery ("rando", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
305 ## @deftypefnx {} {@var{a} =} gallery ("rando", @var{n}, @var{k}) |
16634 | 306 ## Create a random matrix with elements -1, 0 or 1. |
307 ## | |
308 ## @end deftypefn | |
309 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
310 ## @deftypefn {} {@var{a} =} gallery ("randsvd", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
311 ## @deftypefnx {} {@var{a} =} gallery ("randsvd", @var{n}, @var{kappa}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
312 ## @deftypefnx {} {@var{a} =} gallery ("randsvd", @var{n}, @var{kappa}, @var{mode}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
313 ## @deftypefnx {} {@var{a} =} gallery ("randsvd", @var{n}, @var{kappa}, @var{mode}, @var{kl}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
314 ## @deftypefnx {} {@var{a} =} gallery ("randsvd", @var{n}, @var{kappa}, @var{mode}, @var{kl}, @var{ku}) |
16634 | 315 ## Create a random matrix with pre-assigned singular values. |
316 ## | |
317 ## @end deftypefn | |
318 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
319 ## @deftypefn {} {@var{a} =} gallery ("redheff", @var{n}) |
19040
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
18846
diff
changeset
|
320 ## Create a zero and ones matrix of @nospell{Redheffer} associated with the |
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
18846
diff
changeset
|
321 ## Riemann hypothesis. |
16634 | 322 ## |
323 ## @end deftypefn | |
324 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
325 ## @deftypefn {} {@var{a} =} gallery ("riemann", @var{n}) |
16634 | 326 ## Create a matrix associated with the Riemann hypothesis. |
327 ## | |
328 ## @end deftypefn | |
329 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
330 ## @deftypefn {} {@var{a} =} gallery ("ris", @var{n}) |
16634 | 331 ## Create a symmetric Hankel matrix. |
332 ## | |
333 ## @end deftypefn | |
334 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
335 ## @deftypefn {} {@var{a} =} gallery ("smoke", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
336 ## @deftypefnx {} {@var{a} =} gallery ("smoke", @var{n}, @var{k}) |
16634 | 337 ## Create a complex matrix, with a `smoke ring' pseudospectrum. |
338 ## | |
339 ## @end deftypefn | |
340 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
341 ## @deftypefn {} {@var{t} =} gallery ("toeppd", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
342 ## @deftypefnx {} {@var{t} =} gallery ("toeppd", @var{n}, @var{m}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
343 ## @deftypefnx {} {@var{t} =} gallery ("toeppd", @var{n}, @var{m}, @var{w}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
344 ## @deftypefnx {} {@var{t} =} gallery ("toeppd", @var{n}, @var{m}, @var{w}, @var{theta}) |
16634 | 345 ## Create a symmetric positive definite Toeplitz matrix. |
346 ## | |
347 ## @end deftypefn | |
348 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
349 ## @deftypefn {} {@var{p} =} gallery ("toeppen", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
350 ## @deftypefnx {} {@var{p} =} gallery ("toeppen", @var{n}, @var{a}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
351 ## @deftypefnx {} {@var{p} =} gallery ("toeppen", @var{n}, @var{a}, @var{b}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
352 ## @deftypefnx {} {@var{p} =} gallery ("toeppen", @var{n}, @var{a}, @var{b}, @var{c}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
353 ## @deftypefnx {} {@var{p} =} gallery ("toeppen", @var{n}, @var{a}, @var{b}, @var{c}, @var{d}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
354 ## @deftypefnx {} {@var{p} =} gallery ("toeppen", @var{n}, @var{a}, @var{b}, @var{c}, @var{d}, @var{e}) |
16634 | 355 ## Create a pentadiagonal Toeplitz matrix (sparse). |
356 ## | |
357 ## @end deftypefn | |
358 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
359 ## @deftypefn {} {@var{a} =} gallery ("tridiag", @var{x}, @var{y}, @var{z}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
360 ## @deftypefnx {} {@var{a} =} gallery ("tridiag", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
361 ## @deftypefnx {} {@var{a} =} gallery ("tridiag", @var{n}, @var{c}, @var{d}, @var{e}) |
16634 | 362 ## Create a tridiagonal matrix (sparse). |
363 ## | |
364 ## @end deftypefn | |
365 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
366 ## @deftypefn {} {@var{t} =} gallery ("triw", @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
367 ## @deftypefnx {} {@var{t} =} gallery ("triw", @var{n}, @var{alpha}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
368 ## @deftypefnx {} {@var{t} =} gallery ("triw", @var{n}, @var{alpha}, @var{k}) |
19040
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
18846
diff
changeset
|
369 ## Create an upper triangular matrix discussed by |
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
18846
diff
changeset
|
370 ## @nospell{Kahan, Golub, and Wilkinson}. |
16634 | 371 ## |
372 ## @end deftypefn | |
373 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
374 ## @deftypefn {} {@var{a} =} gallery ("uniformdata", [@var{M} @var{N} @dots{}], @var{j}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
375 ## @deftypefnx {} {@var{a} =} gallery ("uniformdata", @var{M}, @var{N}, @dots{}, @var{j}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
376 ## @deftypefnx {} {@var{a} =} gallery ("uniformdata", @dots{}, "@var{class}") |
16982
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
377 ## Create a matrix with random samples from the standard uniform distribution |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
378 ## (range [0,1]). |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
379 ## |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
380 ## The first input is a matrix of dimensions describing the size of the output. |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
381 ## The dimensions can also be input as comma-separated arguments. |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
382 ## |
20162
2645f9ef8c88
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19944
diff
changeset
|
383 ## The input @var{j} is an integer index in the range [0, 2^32-1]. The values |
2645f9ef8c88
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19944
diff
changeset
|
384 ## of the output matrix are always exactly the same (reproducibility) for a |
2645f9ef8c88
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19944
diff
changeset
|
385 ## given size input and @var{j} index. |
16982
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
386 ## |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
387 ## The final optional argument determines the class of the resulting matrix. |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17199
diff
changeset
|
388 ## Possible values for @var{class}: @qcode{"single"}, @qcode{"double"}. |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17199
diff
changeset
|
389 ## The default is @qcode{"double"}. |
16982
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
390 ## |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
391 ## @end deftypefn |
badc46a0a230
doc: Document 'uniformdata', 'normaldata', 'integerdata' matrices in gallery.m.
Rik <rik@octave.org>
parents:
16980
diff
changeset
|
392 ## |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
393 ## @deftypefn {} {@var{a} =} gallery ("wathen", @var{nx}, @var{ny}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
394 ## @deftypefnx {} {@var{a} =} gallery ("wathen", @var{nx}, @var{ny}, @var{k}) |
19040
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
18846
diff
changeset
|
395 ## Create the @nospell{Wathen} matrix. |
16634 | 396 ## |
397 ## @end deftypefn | |
398 ## | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20299
diff
changeset
|
399 ## @deftypefn {} {[@var{a}, @var{b}] =} gallery ("wilk", @var{n}) |
16634 | 400 ## Create various specific matrices devised/discussed by Wilkinson. |
401 ## | |
402 ## @end deftypefn | |
403 | |
404 ## Code for most of the individual matrices (except binomial, gcdmat, | |
405 ## integerdata, leslie, normaldata, randcolu, randcorr, randjorth, sampling, | |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21562
diff
changeset
|
406 ## uniformdata) by Nicholas J. Higham <Nicholas.J.Higham@manchester.ac.uk> |
16634 | 407 ## Adapted for Octave and into single gallery function by Carnë Draug |
408 | |
409 function [varargout] = gallery (name, varargin) | |
410 | |
411 if (nargin < 1) | |
412 print_usage (); | |
413 elseif (! ischar (name)) | |
414 error ("gallery: NAME must be a string."); | |
415 endif | |
416 | |
417 ## NOTE: there isn't a lot of input check in the individual functions | |
418 ## that actually build the functions. This is by design. The original | |
419 ## code by Higham did not perform it and was propagated to Matlab, so | |
420 ## for compatibility, we also don't make it. For example, arguments | |
421 ## that behave as switches, and in theory accepting a value of 0 or 1, | |
422 ## will use a value of 0, for any value other than 1 (only check made | |
423 ## is if the value is equal to 1). It will often also accept string | |
424 ## values instead of numeric. Only input check added was where it | |
425 ## would be causing an error anyway. | |
426 | |
427 ## we will always want to return at least 1 output | |
428 n_out = nargout; | |
429 if (n_out == 0) | |
430 n_out = 1; | |
431 endif | |
432 | |
433 switch (tolower (name)) | |
434 case "binomial" | |
435 error ("gallery: matrix %s not implemented.", name); | |
436 case "cauchy" , [varargout{1:n_out}] = cauchy (varargin{:}); | |
437 case "chebspec" , [varargout{1:n_out}] = chebspec (varargin{:}); | |
438 case "chebvand" , [varargout{1:n_out}] = chebvand (varargin{:}); | |
439 case "chow" , [varargout{1:n_out}] = chow (varargin{:}); | |
440 case "circul" , [varargout{1:n_out}] = circul (varargin{:}); | |
441 case "clement" , [varargout{1:n_out}] = clement (varargin{:}); | |
442 case "compar" , [varargout{1:n_out}] = compar (varargin{:}); | |
443 case "condex" , [varargout{1:n_out}] = condex (varargin{:}); | |
444 case "cycol" , [varargout{1:n_out}] = cycol (varargin{:}); | |
445 case "dorr" , [varargout{1:n_out}] = dorr (varargin{:}); | |
446 case "dramadah" , [varargout{1:n_out}] = dramadah (varargin{:}); | |
447 case "fiedler" , [varargout{1:n_out}] = fiedler (varargin{:}); | |
448 case "forsythe" , [varargout{1:n_out}] = forsythe (varargin{:}); | |
449 case "frank" , [varargout{1:n_out}] = frank (varargin{:}); | |
450 case "gearmat" , [varargout{1:n_out}] = gearmat (varargin{:}); | |
451 case "gcdmat" , [varargout{1:n_out}] = gcdmat (varargin{:}); | |
452 case "grcar" , [varargout{1:n_out}] = grcar (varargin{:}); | |
453 case "hanowa" , [varargout{1:n_out}] = hanowa (varargin{:}); | |
454 case "house" , [varargout{1:n_out}] = house (varargin{:}); | |
16980
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
455 case "integerdata", [varargout{1:n_out}] = integerdata (varargin{:}); |
16634 | 456 case "invhess" , [varargout{1:n_out}] = invhess (varargin{:}); |
457 case "invol" , [varargout{1:n_out}] = invol (varargin{:}); | |
458 case "ipjfact" , [varargout{1:n_out}] = ipjfact (varargin{:}); | |
459 case "jordbloc" , [varargout{1:n_out}] = jordbloc (varargin{:}); | |
460 case "kahan" , [varargout{1:n_out}] = kahan (varargin{:}); | |
461 case "kms" , [varargout{1:n_out}] = kms (varargin{:}); | |
462 case "krylov" , [varargout{1:n_out}] = krylov (varargin{:}); | |
463 case "lauchli" , [varargout{1:n_out}] = lauchli (varargin{:}); | |
464 case "lehmer" , [varargout{1:n_out}] = lehmer (varargin{:}); | |
465 case "leslie" | |
466 error ("gallery: matrix %s not implemented.", name); | |
467 case "lesp" , [varargout{1:n_out}] = lesp (varargin{:}); | |
468 case "lotkin" , [varargout{1:n_out}] = lotkin (varargin{:}); | |
469 case "minij" , [varargout{1:n_out}] = minij (varargin{:}); | |
470 case "moler" , [varargout{1:n_out}] = moler (varargin{:}); | |
471 case "neumann" , [varargout{1:n_out}] = neumann (varargin{:}); | |
16979
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
472 case "normaldata" , [varargout{1:n_out}] = normaldata (varargin{:}); |
16634 | 473 case "orthog" , [varargout{1:n_out}] = orthog (varargin{:}); |
474 case "parter" , [varargout{1:n_out}] = parter (varargin{:}); | |
475 case "pei" , [varargout{1:n_out}] = pei (varargin{:}); | |
476 case "poisson" , [varargout{1:n_out}] = poisson (varargin{:}); | |
477 case "prolate" , [varargout{1:n_out}] = prolate (varargin{:}); | |
478 case "randcolu" | |
479 error ("gallery: matrix %s not implemented.", name); | |
480 case "randcorr" | |
481 error ("gallery: matrix %s not implemented.", name); | |
482 case "randhess" , [varargout{1:n_out}] = randhess (varargin{:}); | |
483 case "randjorth" | |
484 error ("gallery: matrix %s not implemented.", name); | |
485 case "rando" , [varargout{1:n_out}] = rando (varargin{:}); | |
486 case "randsvd" , [varargout{1:n_out}] = randsvd (varargin{:}); | |
487 case "redheff" , [varargout{1:n_out}] = redheff (varargin{:}); | |
488 case "riemann" , [varargout{1:n_out}] = riemann (varargin{:}); | |
489 case "ris" , [varargout{1:n_out}] = ris (varargin{:}); | |
490 case "sampling" | |
491 error ("gallery: matrix %s not implemented.", name); | |
492 case "smoke" , [varargout{1:n_out}] = smoke (varargin{:}); | |
493 case "toeppd" , [varargout{1:n_out}] = toeppd (varargin{:}); | |
494 case "toeppen" , [varargout{1:n_out}] = toeppen (varargin{:}); | |
495 case "tridiag" , [varargout{1:n_out}] = tridiag (varargin{:}); | |
496 case "triw" , [varargout{1:n_out}] = triw (varargin{:}); | |
16978
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
497 case "uniformdata" , [varargout{1:n_out}] = uniformdata (varargin{:}); |
16634 | 498 case "wathen" , [varargout{1:n_out}] = wathen (varargin{:}); |
499 case "wilk" , [varargout{1:n_out}] = wilk (varargin{:}); | |
500 otherwise | |
501 error ("gallery: unknown matrix with NAME %s", name); | |
502 endswitch | |
503 | |
504 endfunction | |
505 | |
506 function C = cauchy (x, y) | |
21562
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
507 ## CAUCHY Cauchy matrix. |
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
508 ## C = CAUCHY(X, Y), where X, Y are N-vectors, is the N-by-N matrix |
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
509 ## with C(i,j) = 1/(X(i)+Y(j)). By default, Y = X. |
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
510 ## Special case: if X is a scalar CAUCHY(X) is the same as CAUCHY(1:X). |
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
511 ## Explicit formulas are known for DET(C) (which is nonzero if X and Y |
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
512 ## both have distinct elements) and the elements of INV(C). |
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
513 ## C is totally positive if 0 < X(1) < ... < X(N) and |
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
514 ## 0 < Y(1) < ... < Y(N). |
16634 | 515 ## |
21562
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
516 ## References: |
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
517 ## N.J. Higham, Accuracy and Stability of Numerical Algorithms, |
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
518 ## Society for Industrial and Applied Mathematics, Philadelphia, PA, |
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
519 ## USA, 1996; sec. 26.1. |
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
520 ## D.E. Knuth, The Art of Computer Programming, Volume 1, |
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
521 ## Fundamental Algorithms, second edition, Addison-Wesley, Reading, |
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
522 ## Massachusetts, 1973, p. 36. |
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
523 ## E.E. Tyrtyshnikov, Cauchy-Toeplitz matrices and some applications, |
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
524 ## Linear Algebra and Appl., 149 (1991), pp. 1-18. |
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
525 ## O. Taussky and M. Marcus, Eigenvalues of finite matrices, in |
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
526 ## Survey of Numerical Analysis, J. Todd, ed., McGraw-Hill, New York, |
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21546
diff
changeset
|
527 ## pp. 279-313, 1962. (States the totally positive property on p. 295.) |
16634 | 528 |
529 if (nargin < 1 || nargin > 2) | |
530 error ("gallery: 1 or 2 arguments are required for cauchy matrix."); | |
531 elseif (! isnumeric (x)) | |
532 error ("gallery: X must be numeric for cauchy matrix."); | |
533 elseif (nargin == 2 && ! isnumeric (y)) | |
534 error ("gallery: Y must be numeric for cauchy matrix."); | |
535 endif | |
536 | |
537 n = numel (x); | |
538 if (isscalar (x) && fix (x) == x) | |
539 n = x; | |
540 x = 1:n; | |
541 elseif (n > 1 && isvector (x)) | |
542 ## do nothing | |
543 else | |
544 error ("gallery: X be an integer or a vector for cauchy matrix."); | |
545 endif | |
546 | |
547 if (nargin == 1) | |
548 y = x; | |
549 endif | |
550 | |
551 ## Ensure x and y are column vectors | |
552 x = x(:); | |
553 y = y(:); | |
554 if (numel (x) != numel (y)) | |
555 error ("gallery: X and Y must be vectors of same length for cauchy matrix."); | |
556 endif | |
557 | |
23381
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
558 C = 1 ./ (x .+ y.'); |
16634 | 559 endfunction |
560 | |
561 function C = chebspec (n, k = 0) | |
562 ## CHEBSPEC Chebyshev spectral differentiation matrix. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
563 ## C = CHEBSPEC(N, K) is a Chebyshev spectral differentiation |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
564 ## matrix of order N. K = 0 (the default) or 1. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
565 ## For K = 0 (`no boundary conditions'), C is nilpotent, with |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
566 ## C^N = 0 and it has the null vector ONES(N,1). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
567 ## C is similar to a Jordan block of size N with eigenvalue zero. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
568 ## For K = 1, C is nonsingular and well-conditioned, and its eigenvalues |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
569 ## have negative real parts. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
570 ## For both K, the computed eigenvector matrix X from EIG is |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
571 ## ill-conditioned (MESH(REAL(X)) is interesting). |
16634 | 572 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
573 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
574 ## C. Canuto, M.Y. Hussaini, A. Quarteroni and T.A. Zang, Spectral |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
575 ## Methods in Fluid Dynamics, Springer-Verlag, Berlin, 1988; p. 69. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
576 ## L.N. Trefethen and M.R. Trummer, An instability phenomenon in |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
577 ## spectral methods, SIAM J. Numer. Anal., 24 (1987), pp. 1008-1023. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
578 ## D. Funaro, Computing the inverse of the Chebyshev collocation |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
579 ## derivative, SIAM J. Sci. Stat. Comput., 9 (1988), pp. 1050-1057. |
16634 | 580 |
581 if (nargin < 1 || nargin > 2) | |
582 error ("gallery: 1 to 2 arguments are required for chebspec matrix."); | |
583 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
584 error ("gallery: N must be an integer for chebspec matrix."); | |
585 elseif (! isnumeric (k) || ! isscalar (k)) | |
586 error ("gallery: K must be a scalar for chebspec matrix."); | |
587 endif | |
588 | |
589 ## k = 1 case obtained from k = 0 case with one bigger n. | |
590 switch (k) | |
591 case (0), # do nothing | |
592 case (1), n = n + 1; | |
593 otherwise | |
20294
2102c4582e32
gallery: fix chebspec, cycol, gearmat, hanowa, lauchli, and pei (bug #45466)
Massimiliano Fasi <massimiliano.fasi@gmail.com>
parents:
20231
diff
changeset
|
594 error ("gallery: K should be either 0 or 1 for chebspec matrix."); |
16634 | 595 endswitch |
596 | |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
20162
diff
changeset
|
597 n -= 1; |
16634 | 598 C = zeros (n+1); |
599 | |
600 one = ones (n+1, 1); | |
601 x = cos ((0:n)' * (pi/n)); | |
602 d = ones (n+1, 1); | |
603 d(1) = 2; | |
604 d(n+1) = 2; | |
605 | |
606 ## eye(size(C)) on next line avoids div by zero. | |
607 C = (d * (one./d)') ./ (x*one'-one*x' + eye (size (C))); | |
608 | |
609 ## Now fix diagonal and signs. | |
610 C(1,1) = (2*n^2+1)/6; | |
611 for i = 2:n+1 | |
612 if (rem (i, 2) == 0) | |
613 C(:,i) = -C(:,i); | |
614 C(i,:) = -C(i,:); | |
615 endif | |
616 if (i < n+1) | |
617 C(i,i) = -x(i)/(2*(1-x(i)^2)); | |
618 else | |
619 C(n+1,n+1) = -C(1,1); | |
620 endif | |
621 endfor | |
622 | |
623 if (k == 1) | |
624 C = C(2:n+1,2:n+1); | |
625 endif | |
626 endfunction | |
627 | |
628 function C = chebvand (m, p) | |
629 ## CHEBVAND Vandermonde-like matrix for the Chebyshev polynomials. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
630 ## C = CHEBVAND(P), where P is a vector, produces the (primal) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
631 ## Chebyshev Vandermonde matrix based on the points P, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
632 ## i.e., C(i,j) = T_{i-1}(P(j)), where T_{i-1} is the Chebyshev |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
633 ## polynomial of degree i-1. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
634 ## CHEBVAND(M,P) is a rectangular version of CHEBVAND(P) with M rows. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
635 ## Special case: If P is a scalar then P equally spaced points on |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
636 ## [0,1] are used. |
16634 | 637 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
638 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
639 ## N.J. Higham, Stability analysis of algorithms for solving confluent |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
640 ## Vandermonde-like systems, SIAM J. Matrix Anal. Appl., 11 (1990), |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
641 ## pp. 23-41. |
16634 | 642 |
643 if (nargin < 1 || nargin > 2) | |
644 error ("gallery: 1 or 2 arguments are required for chebvand matrix."); | |
645 endif | |
646 | |
647 ## because the order of the arguments changes if nargin is 1 or 2 ... | |
648 | |
649 if (nargin == 1) | |
650 p = m; | |
651 endif | |
652 | |
653 n = numel (p); | |
654 if (! isnumeric (p)) | |
655 error ("gallery: P must be numeric for chebvand matrix."); | |
656 elseif (isscalar (p) && fix (p) == p) | |
657 n = p; | |
658 p = linspace (0, 1, n); | |
659 elseif (n > 1 && isvector (p)) | |
660 ## do nothing | |
661 endif | |
662 p = p(:).'; # Ensure p is a row vector. | |
663 | |
664 if (nargin == 1) | |
665 m = n; | |
666 elseif (! isnumeric (m) || ! isscalar (m)) | |
667 error ("gallery: M must be a scalar for chebvand matrix."); | |
668 endif | |
669 | |
670 C = ones (m, n); | |
671 if (m != 1) | |
672 C(2,:) = p; | |
673 ## Use Chebyshev polynomial recurrence. | |
674 for i = 3:m | |
675 C(i,:) = 2.*p.*C(i-1,:) - C(i-2,:); | |
676 endfor | |
677 endif | |
678 endfunction | |
679 | |
680 function A = chow (n, alpha = 1, delta = 0) | |
681 ## CHOW Chow matrix - a singular Toeplitz lower Hessenberg matrix. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
682 ## A = CHOW(N, ALPHA, DELTA) is a Toeplitz lower Hessenberg matrix |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
683 ## A = H(ALPHA) + DELTA*EYE, where H(i,j) = ALPHA^(i-j+1). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
684 ## H(ALPHA) has p = FLOOR(N/2) zero eigenvalues, the rest being |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
685 ## 4*ALPHA*COS( k*PI/(N+2) )^2, k=1:N-p. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
686 ## Defaults: ALPHA = 1, DELTA = 0. |
16634 | 687 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
688 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
689 ## T.S. Chow, A class of Hessenberg matrices with known |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
690 ## eigenvalues and inverses, SIAM Review, 11 (1969), pp. 391-395. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
691 ## G. Fairweather, On the eigenvalues and eigenvectors of a class of |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
692 ## Hessenberg matrices, SIAM Review, 13 (1971), pp. 220-221. |
16634 | 693 |
694 if (nargin < 1 || nargin > 3) | |
695 error ("gallery: 1 to 3 arguments are required for chow matrix."); | |
696 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
697 error ("gallery: N must be an integer for chow matrix."); | |
698 elseif (! isnumeric (alpha) || ! isscalar (alpha)) | |
699 error ("gallery: ALPHA must be a scalar for chow matrix."); | |
700 elseif (! isnumeric (delta) || ! isscalar (delta)) | |
701 error ("gallery: DELTA must be a scalar for chow matrix."); | |
702 endif | |
703 | |
704 A = toeplitz (alpha.^(1:n), [alpha 1 zeros(1, n-2)]) + delta * eye (n); | |
705 endfunction | |
706 | |
707 function C = circul (v) | |
708 ## CIRCUL Circulant matrix. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
709 ## C = CIRCUL(V) is the circulant matrix whose first row is V. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
710 ## (A circulant matrix has the property that each row is obtained |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
711 ## from the previous one by cyclically permuting the entries one step |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
712 ## forward; it is a special Toeplitz matrix in which the diagonals |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
713 ## `wrap round'.) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
714 ## Special case: if V is a scalar then C = CIRCUL(1:V). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
715 ## The eigensystem of C (N-by-N) is known explicitly. If t is an Nth |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
716 ## root of unity, then the inner product of V with W = [1 t t^2 ... t^N] |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
717 ## is an eigenvalue of C, and W(N:-1:1) is an eigenvector of C. |
16634 | 718 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
719 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
720 ## P.J. Davis, Circulant Matrices, John Wiley, 1977. |
16634 | 721 |
722 if (nargin != 1) | |
723 error ("gallery: 1 argument is required for circul matrix."); | |
724 elseif (! isnumeric (v)) | |
725 error ("gallery: V must be numeric for circul matrix."); | |
726 endif | |
727 | |
16734
67b67fc0969a
gallery: fix bug from typo in variable name
Carnë Draug <carandraug@octave.org>
parents:
16634
diff
changeset
|
728 n = numel (v); |
67b67fc0969a
gallery: fix bug from typo in variable name
Carnë Draug <carandraug@octave.org>
parents:
16634
diff
changeset
|
729 if (isscalar (v) && fix (v) == v) |
16634 | 730 n = v; |
731 v = 1:n; | |
16734
67b67fc0969a
gallery: fix bug from typo in variable name
Carnë Draug <carandraug@octave.org>
parents:
16634
diff
changeset
|
732 elseif (n > 1 && isvector (v)) |
16634 | 733 ## do nothing |
734 else | |
735 error ("gallery: X must be a scalar or a vector for circul matrix."); | |
736 endif | |
737 | |
738 v = v(:).'; # Make sure v is a row vector | |
739 C = toeplitz ([v(1) v(n:-1:2)], v); | |
740 endfunction | |
741 | |
742 function A = clement (n, k = 0) | |
743 ## CLEMENT Clement matrix - tridiagonal with zero diagonal entries. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
744 ## CLEMENT(N, K) is a tridiagonal matrix with zero diagonal entries |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
745 ## and known eigenvalues. It is singular if N is odd. About 64 |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
746 ## percent of the entries of the inverse are zero. The eigenvalues |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
747 ## are plus and minus the numbers N-1, N-3, N-5, ..., (1 or 0). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
748 ## For K = 0 (the default) the matrix is unsymmetric, while for |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
749 ## K = 1 it is symmetric. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
750 ## CLEMENT(N, 1) is diagonally similar to CLEMENT(N). |
16634 | 751 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
752 ## Similar properties hold for TRIDIAG(X,Y,Z) where Y = ZEROS(N,1). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
753 ## The eigenvalues still come in plus/minus pairs but they are not |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
754 ## known explicitly. |
16634 | 755 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
756 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
757 ## P.A. Clement, A class of triple-diagonal matrices for test |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
758 ## purposes, SIAM Review, 1 (1959), pp. 50-52. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
759 ## A. Edelman and E. Kostlan, The road from Kac's matrix to Kac's |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
760 ## random polynomials. In John~G. Lewis, editor, Proceedings of |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
761 ## the Fifth SIAM Conference on Applied Linear Algebra Society |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
762 ## for Industrial and Applied Mathematics, Philadelphia, 1994, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
763 ## pp. 503-507. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
764 ## O. Taussky and J. Todd, Another look at a matrix of Mark Kac, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
765 ## Linear Algebra and Appl., 150 (1991), pp. 341-360. |
16634 | 766 |
767 if (nargin < 1 || nargin > 2) | |
768 error ("gallery: 1 or 2 arguments are required for clement matrix."); | |
769 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
770 error ("gallery: N must be an integer for clement matrix."); | |
771 elseif (! isnumeric (k) || ! isscalar (k)) | |
772 error ("gallery: K must be a numeric scalar for clement matrix."); | |
773 endif | |
774 | |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
20162
diff
changeset
|
775 n -= 1; |
16634 | 776 x = n:-1:1; |
777 z = 1:n; | |
778 | |
779 if (k == 0) | |
780 A = diag (x, -1) + diag (z, 1); | |
781 elseif (k == 1) | |
782 y = sqrt (x.*z); | |
783 A = diag (y, -1) + diag (y, 1); | |
784 else | |
785 error ("gallery: K must have a value of 0 or 1 for clement matrix."); | |
786 endif | |
787 endfunction | |
788 | |
789 function C = compar (A, k = 0) | |
790 ## COMP Comparison matrices. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
791 ## COMP(A) is DIAG(B) - TRIL(B,-1) - TRIU(B,1), where B = ABS(A). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
792 ## COMP(A, 1) is A with each diagonal element replaced by its |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
793 ## absolute value, and each off-diagonal element replaced by minus |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
794 ## the absolute value of the largest element in absolute value in |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
795 ## its row. However, if A is triangular COMP(A, 1) is too. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
796 ## COMP(A, 0) is the same as COMP(A). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
797 ## COMP(A) is often denoted by M(A) in the literature. |
16634 | 798 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
799 ## Reference (e.g.): |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
800 ## N.J. Higham, A survey of condition number estimation for |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
801 ## triangular matrices, SIAM Review, 29 (1987), pp. 575-596. |
16634 | 802 |
803 if (nargin < 1 || nargin > 2) | |
804 error ("gallery: 1 or 2 arguments are required for compar matrix."); | |
805 elseif (! isnumeric (A) || ndims (A) != 2) | |
17199 | 806 error ("gallery: A must be a 2-D matrix for compar matrix."); |
16634 | 807 elseif (! isnumeric (k) || ! isscalar (k)) |
808 error ("gallery: K must be a numeric scalar for compar matrix."); | |
809 endif | |
810 | |
811 [m, n] = size (A); | |
812 p = min (m, n); | |
813 | |
814 if (k == 0) | |
815 ## This code uses less temporary storage than | |
816 ## the `high level' definition above. | |
817 C = -abs (A); | |
818 for j = 1:p | |
819 C(j,j) = abs (A(j,j)); | |
820 endfor | |
821 | |
822 elseif (k == 1) | |
823 C = A'; | |
824 for j = 1:p | |
825 C(k,k) = 0; | |
826 endfor | |
827 mx = max (abs (C)); | |
828 C = -mx'*ones (1, n); | |
829 for j = 1:p | |
830 C(j,j) = abs (A(j,j)); | |
831 endfor | |
832 if (all (A == tril (A))), C = tril (C); endif | |
833 if (all (A == triu (A))), C = triu (C); endif | |
834 | |
835 else | |
836 error ("gallery: K must have a value of 0 or 1 for compar matrix."); | |
837 endif | |
838 | |
839 endfunction | |
840 | |
841 function A = condex (n, k = 4, theta = 100) | |
842 ## CONDEX `Counterexamples' to matrix condition number estimators. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
843 ## CONDEX(N, K, THETA) is a `counterexample' matrix to a condition |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
844 ## estimator. It has order N and scalar parameter THETA (default 100). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
845 ## If N is not equal to the `natural' size of the matrix then |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
846 ## the matrix is padded out with an identity matrix to order N. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
847 ## The matrix, its natural size, and the estimator to which it applies |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
848 ## are specified by K (default K = 4) as follows: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
849 ## K = 1: 4-by-4, LINPACK (RCOND) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
850 ## K = 2: 3-by-3, LINPACK (RCOND) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
851 ## K = 3: arbitrary, LINPACK (RCOND) (independent of THETA) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
852 ## K = 4: N >= 4, SONEST (Higham 1988) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
853 ## (Note that in practice the K = 4 matrix is not usually a |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
854 ## counterexample because of the rounding errors in forming it.) |
16634 | 855 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
856 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
857 ## A.K. Cline and R.K. Rew, A set of counter-examples to three |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
858 ## condition number estimators, SIAM J. Sci. Stat. Comput., |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
859 ## 4 (1983), pp. 602-611. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
860 ## N.J. Higham, FORTRAN codes for estimating the one-norm of a real or |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
861 ## complex matrix, with applications to condition estimation |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
862 ## (Algorithm 674), ACM Trans. Math. Soft., 14 (1988), pp. 381-396. |
16634 | 863 |
864 if (nargin < 1 || nargin > 3) | |
865 error ("gallery: 1 to 3 arguments are required for condex matrix."); | |
866 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
867 error ("gallery: N must be an integer for condex matrix."); | |
868 elseif (! isnumeric (k) || ! isscalar (k)) | |
869 error ("gallery: K must be a numeric scalar for condex matrix."); | |
870 elseif (! isnumeric (theta) || ! isscalar (theta)) | |
871 error ("gallery: THETA must be a numeric scalar for condex matrix."); | |
872 endif | |
873 | |
874 if (k == 1) # Cline and Rew (1983), Example B. | |
875 A = [1 -1 -2*theta 0 | |
876 0 1 theta -theta | |
877 0 1 1+theta -(theta+1) | |
878 0 0 0 theta]; | |
879 | |
880 elseif (k == 2) # Cline and Rew (1983), Example C. | |
881 A = [1 1-2/theta^2 -2 | |
882 0 1/theta -1/theta | |
883 0 0 1]; | |
884 | |
885 elseif (k == 3) # Cline and Rew (1983), Example D. | |
886 A = gallery ("triw", n, -1)'; | |
887 A(n,n) = -1; | |
888 | |
889 elseif (k == 4) # Higham (1988), p. 390. | |
890 x = ones (n, 3); # First col is e | |
891 x(2:n,2) = zeros (n-1, 1); # Second col is e(1) | |
892 | |
893 ## Third col is special vector b in SONEST | |
894 x(:, 3) = (-1).^[0:n-1]' .* ( 1 + [0:n-1]'/(n-1) ); | |
895 | |
896 Q = orth (x); # Q*Q' is now the orthogonal projector onto span(e(1),e,b)). | |
897 P = eye (n) - Q*Q'; | |
898 A = eye (n) + theta*P; | |
899 | |
900 else | |
16766
7268845c0a1e
avoid backquote in error messages, some uses in doc strings
John W. Eaton <jwe@octave.org>
parents:
16734
diff
changeset
|
901 error ("gallery: unknown estimator K '%d' for condex matrix.", k); |
16634 | 902 endif |
903 | |
904 ## Pad out with identity as necessary. | |
905 m = columns (A); | |
906 if (m < n) | |
907 for i = n:-1:m+1 | |
908 A(i,i) = 1; | |
909 endfor | |
910 endif | |
911 endfunction | |
912 | |
20298
ababbe103048
gallery: allow N to be a 2 element vectors for cycol matrices.
Carnë Draug <carandraug@octave.org>
parents:
20297
diff
changeset
|
913 function A = cycol (n, k = max (round (n(end)/4), 1)) |
16634 | 914 ## CYCOL Matrix whose columns repeat cyclically. |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
915 ## A = CYCOL([M N], K) is an M-by-N matrix of the form A = B(1:M,1:N) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
916 ## where B = [C C C...] and C = RANDN(M, K). Thus A's columns repeat |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
917 ## cyclically, and A has rank at most K. K need not divide N. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
918 ## K defaults to ROUND(N/4). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
919 ## CYCOL(N, K), where N is a scalar, is the same as CYCOL([N N], K). |
16634 | 920 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
921 ## This type of matrix can lead to underflow problems for Gaussian |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
922 ## elimination: see NA Digest Volume 89, Issue 3 (January 22, 1989). |
16634 | 923 |
924 if (nargin < 1 || nargin > 2) | |
925 error ("gallery: 1 or 2 arguments are required for cycol matrix."); | |
926 elseif (! isnumeric (n) || all (numel (n) != [1 2]) || fix (n) != n) | |
927 error ("gallery: N must be a 1 or 2 element integer for cycol matrix."); | |
928 elseif (! isnumeric (k) || ! isscalar (k)) | |
929 error ("gallery: K must be a scalar for cycol matrix."); | |
930 endif | |
931 | |
932 ## Parameter n specifies dimension: m-by-n | |
933 m = n(1); | |
934 n = n(end); | |
935 | |
936 A = randn (m, k); | |
937 for i = 2:ceil (n/k) | |
938 A = [A A(:,1:k)]; | |
939 endfor | |
940 A = A(:,1:n); | |
941 endfunction | |
942 | |
943 function [c, d, e] = dorr (n, theta = 0.01) | |
944 ## DORR Dorr matrix - diagonally dominant, ill conditioned, tridiagonal. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
945 ## [C, D, E] = DORR(N, THETA) returns the vectors defining a row diagonally |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
946 ## dominant, tridiagonal M-matrix that is ill conditioned for small |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
947 ## values of the parameter THETA >= 0. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
948 ## If only one output parameter is supplied then |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
949 ## C = FULL(TRIDIAG(C,D,E)), i.e., the matrix iself is returned. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
950 ## The columns of INV(C) vary greatly in norm. THETA defaults to 0.01. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
951 ## The amount of diagonal dominance is given by (ignoring rounding errors): |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
952 ## COMP(C)*ONES(N,1) = THETA*(N+1)^2 * [1 0 0 ... 0 1]'. |
16634 | 953 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
954 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
955 ## F.W. Dorr, An example of ill-conditioning in the numerical |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
956 ## solution of singular perturbation problems, Math. Comp., 25 (1971), |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
957 ## pp. 271-283. |
16634 | 958 |
959 if (nargin < 1 || nargin > 2) | |
960 error ("gallery: 1 or 2 arguments are required for dorr matrix."); | |
961 elseif (! isscalar (n) || ! isnumeric (n) || fix (n) != n) | |
962 error ("gallery: N must be an integer for dorr matrix."); | |
963 elseif (! isscalar (theta) || ! isnumeric (theta)) | |
964 error ("gallery: THETA must be a numeric scalar for dorr matrix."); | |
965 endif | |
966 | |
967 c = zeros (n, 1); | |
968 e = c; | |
969 d = c; | |
970 ## All length n for convenience. Make c, e of length n-1 later. | |
971 | |
972 h = 1/(n+1); | |
973 m = floor ((n+1)/2); | |
974 term = theta/h^2; | |
975 | |
976 i = (1:m)'; | |
977 c(i) = -term * ones (m, 1); | |
978 e(i) = c(i) - (0.5-i*h)/h; | |
979 d(i) = -(c(i) + e(i)); | |
980 | |
981 i = (m+1:n)'; | |
982 e(i) = -term * ones (n-m, 1); | |
983 c(i) = e(i) + (0.5-i*h)/h; | |
984 d(i) = -(c(i) + e(i)); | |
985 | |
986 c = c(2:n); | |
987 e = e(1:n-1); | |
988 | |
989 if (nargout <= 1) | |
990 c = tridiag (c, d, e); | |
991 endif | |
992 endfunction | |
993 | |
994 function A = dramadah (n, k = 1) | |
995 ## DRAMADAH A (0,1) matrix whose inverse has large integer entries. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
996 ## An anti-Hadamard matrix A is a matrix with elements 0 or 1 for |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
997 ## which MU(A) := NORM(INV(A),'FRO') is maximal. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
998 ## A = DRAMADAH(N, K) is an N-by-N (0,1) matrix for which MU(A) is |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
999 ## relatively large, although not necessarily maximal. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1000 ## Available types (the default is K = 1): |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1001 ## K = 1: A is Toeplitz, with ABS(DET(A)) = 1, and MU(A) > c(1.75)^N, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1002 ## where c is a constant. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1003 ## K = 2: A is upper triangular and Toeplitz. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1004 ## The inverses of both types have integer entries. |
16634 | 1005 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1006 ## Another interesting (0,1) matrix: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1007 ## K = 3: A has maximal determinant among (0,1) lower Hessenberg |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1008 ## matrices: det(A) = the n'th Fibonacci number. A is Toeplitz. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1009 ## The eigenvalues have an interesting distribution in the complex |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1010 ## plane. |
16634 | 1011 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1012 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1013 ## R.L. Graham and N.J.A. Sloane, Anti-Hadamard matrices, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1014 ## Linear Algebra and Appl., 62 (1984), pp. 113-137. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1015 ## L. Ching, The maximum determinant of an nxn lower Hessenberg |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1016 ## (0,1) matrix, Linear Algebra and Appl., 183 (1993), pp. 147-153. |
16634 | 1017 |
1018 if (nargin < 1 || nargin > 2) | |
1019 error ("gallery: 1 to 2 arguments are required for dramadah matrix."); | |
1020 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
1021 error ("gallery: N must be an integer for dramadah matrix."); | |
1022 elseif (! isnumeric (k) || ! isscalar (k)) | |
1023 error ("gallery: K must be a numeric scalar for dramadah matrix."); | |
1024 endif | |
1025 | |
1026 switch (k) | |
1027 case (1) # Toeplitz | |
1028 c = ones (n, 1); | |
1029 for i = 2:4:n | |
1030 m = min (1, n-i); | |
1031 c(i:i+m) = zeros (m+1, 1); | |
1032 endfor | |
1033 r = zeros (n, 1); | |
1034 r(1:4) = [1 1 0 1]; | |
1035 if (n < 4) | |
1036 r = r(1:n); | |
1037 endif | |
1038 A = toeplitz (c, r); | |
1039 | |
1040 case (2) # Upper triangular and Toeplitz | |
1041 c = zeros (n, 1); | |
1042 c(1) = 1; | |
1043 r = ones (n, 1); | |
1044 for i= 3:2:n | |
1045 r(i) = 0; | |
1046 endfor | |
1047 A = toeplitz (c, r); | |
1048 | |
1049 case (3) # Lower Hessenberg | |
1050 c = ones (n, 1); | |
1051 for i= 2:2:n | |
1052 c(i) = 0; | |
1053 endfor | |
1054 A = toeplitz (c, [1 1 zeros(1,n-2)]); | |
1055 | |
1056 otherwise | |
16766
7268845c0a1e
avoid backquote in error messages, some uses in doc strings
John W. Eaton <jwe@octave.org>
parents:
16734
diff
changeset
|
1057 error ("gallery: unknown K '%d' for dramadah matrix.", k); |
16634 | 1058 endswitch |
1059 endfunction | |
1060 | |
1061 function A = fiedler (c) | |
1062 ## FIEDLER Fiedler matrix - symmetric. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1063 ## FIEDLER(C), where C is an n-vector, is the n-by-n symmetric |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1064 ## matrix with elements ABS(C(i)-C(j)). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1065 ## Special case: if C is a scalar, then A = FIEDLER(1:C) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1066 ## (i.e. A(i,j) = ABS(i-j)). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1067 ## Properties: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1068 ## FIEDLER(N) has a dominant positive eigenvalue and all the other |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1069 ## eigenvalues are negative (Szego, 1936). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1070 ## Explicit formulas for INV(A) and DET(A) are given by Todd (1977) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1071 ## and attributed to Fiedler. These indicate that INV(A) is |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1072 ## tridiagonal except for nonzero (1,n) and (n,1) elements. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1073 ## [I think these formulas are valid only if the elements of |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1074 ## C are in increasing or decreasing order---NJH.] |
16634 | 1075 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1076 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1077 ## G. Szego, Solution to problem 3705, Amer. Math. Monthly, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1078 ## 43 (1936), pp. 246-259. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1079 ## J. Todd, Basic Numerical Mathematics, Vol. 2: Numerical Algebra, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1080 ## Birkhauser, Basel, and Academic Press, New York, 1977, p. 159. |
16634 | 1081 |
1082 if (nargin != 1) | |
1083 error ("gallery: 1 argument is required for fiedler matrix."); | |
1084 elseif (! isnumeric (c)) | |
1085 error ("gallery: C must be numeric for fiedler matrix."); | |
1086 endif | |
1087 | |
1088 n = numel (c); | |
1089 if (isscalar (c) && fix (c) == c) | |
1090 n = c; | |
1091 c = 1:n; | |
1092 elseif (n > 1 && isvector (c)) | |
1093 ## do nothing | |
1094 else | |
1095 error ("gallery: C must be an integer or a vector for fiedler matrix."); | |
1096 endif | |
1097 c = c(:).'; # Ensure c is a row vector. | |
1098 | |
23381
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
1099 A = abs (c - c.'); |
16634 | 1100 endfunction |
1101 | |
1102 function A = forsythe (n, alpha = sqrt (eps), lambda = 0) | |
1103 ## FORSYTHE Forsythe matrix - a perturbed Jordan block. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1104 ## FORSYTHE(N, ALPHA, LAMBDA) is the N-by-N matrix equal to |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1105 ## JORDBLOC(N, LAMBDA) except it has an ALPHA in the (N,1) position. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1106 ## It has the characteristic polynomial |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1107 ## DET(A-t*EYE) = (LAMBDA-t)^N - (-1)^N ALPHA. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1108 ## ALPHA defaults to SQRT(EPS) and LAMBDA to 0. |
16634 | 1109 |
1110 if (nargin < 1 || nargin > 3) | |
1111 error ("gallery: 1 to 3 arguments are required for forsythe matrix."); | |
1112 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
1113 error ("gallery: N must be an integer for forsythe matrix."); | |
1114 elseif (! isnumeric (alpha) || ! isscalar (alpha)) | |
1115 error ("gallery: ALPHA must be a numeric scalar for forsythe matrix."); | |
1116 elseif (! isnumeric (lambda) || ! isscalar (lambda)) | |
1117 error ("gallery: LAMBDA must be a numeric scalar for forsythe matrix."); | |
1118 endif | |
1119 | |
1120 A = jordbloc (n, lambda); | |
1121 A(n,1) = alpha; | |
1122 endfunction | |
1123 | |
1124 function F = frank (n, k = 0) | |
1125 ## FRANK Frank matrix---ill conditioned eigenvalues. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1126 ## F = FRANK(N, K) is the Frank matrix of order N. It is upper |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1127 ## Hessenberg with determinant 1. K = 0 is the default; if K = 1 the |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1128 ## elements are reflected about the anti-diagonal (1,N)--(N,1). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1129 ## F has all positive eigenvalues and they occur in reciprocal pairs |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1130 ## (so that 1 is an eigenvalue if N is odd). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1131 ## The eigenvalues of F may be obtained in terms of the zeros of the |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1132 ## Hermite polynomials. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1133 ## The FLOOR(N/2) smallest eigenvalues of F are ill conditioned, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1134 ## the more so for bigger N. |
16634 | 1135 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1136 ## DET(FRANK(N)') comes out far from 1 for large N---see Frank (1958) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1137 ## and Wilkinson (1960) for discussions. |
16634 | 1138 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1139 ## This version incorporates improvements suggested by W. Kahan. |
16634 | 1140 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1141 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1142 ## W.L. Frank, Computing eigenvalues of complex matrices by determinant |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1143 ## evaluation and by methods of Danilewski and Wielandt, J. Soc. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1144 ## Indust. Appl. Math., 6 (1958), pp. 378-392 (see pp. 385, 388). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1145 ## G.H. Golub and J.H. Wilkinson, Ill-conditioned eigensystems and the |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1146 ## computation of the Jordan canonical form, SIAM Review, 18 (1976), |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1147 ## pp. 578-619 (Section 13). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1148 ## H. Rutishauser, On test matrices, Programmation en Mathematiques |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1149 ## Numeriques, Editions Centre Nat. Recherche Sci., Paris, 165, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1150 ## 1966, pp. 349-365. Section 9. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1151 ## J.H. Wilkinson, Error analysis of floating-point computation, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1152 ## Numer. Math., 2 (1960), pp. 319-340 (Section 8). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1153 ## J.H. Wilkinson, The Algebraic Eigenvalue Problem, Oxford University |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1154 ## Press, 1965 (pp. 92-93). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1155 ## The next two references give details of the eigensystem, as does |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1156 ## Rutishauser (see above). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1157 ## P.J. Eberlein, A note on the matrices denoted by B_n, SIAM J. Appl. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1158 ## Math., 20 (1971), pp. 87-92. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1159 ## J.M. Varah, A generalization of the Frank matrix, SIAM J. Sci. Stat. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1160 ## Comput., 7 (1986), pp. 835-839. |
16634 | 1161 |
1162 if (nargin < 1 || nargin > 2) | |
1163 error ("gallery: 1 to 2 arguments are required for frank matrix."); | |
1164 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
1165 error ("gallery: N must be an integer for frank matrix."); | |
1166 elseif (! isnumeric (k) || ! isscalar (k)) | |
1167 error ("gallery: K must be a numeric scalar for frank matrix."); | |
1168 endif | |
1169 | |
1170 p = n:-1:1; | |
1171 F = triu (p(ones (n, 1), :) - diag (ones (n-1, 1), -1), -1); | |
1172 | |
1173 switch (k) | |
1174 case (0), # do nothing | |
1175 case (1), F = F(p,p)'; | |
1176 otherwise | |
1177 error ("gallery: K must have a value of 0 or 1 for frank matrix."); | |
1178 endswitch | |
1179 endfunction | |
1180 | |
1181 function c = gcdmat (n) | |
1182 if (nargin != 1) | |
1183 error ("gallery: 1 argument is required for gcdmat matrix."); | |
1184 elseif (! isscalar (n) || ! isnumeric (n) || fix (n) != n) | |
1185 error ("gallery: N must be an integer for gcdmat matrix."); | |
1186 endif | |
1187 c = gcd (repmat ((1:n)', [1 n]), repmat (1:n, [n 1])); | |
1188 endfunction | |
1189 | |
1190 function A = gearmat (n, i = n, j = -n) | |
1191 ## NOTE: this function was named gearm in the original Test Matrix Toolbox | |
1192 ## GEARMAT Gear matrix. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1193 ## A = GEARMAT(N,I,J) is the N-by-N matrix with ones on the sub- and |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1194 ## super-diagonals, SIGN(I) in the (1,ABS(I)) position, SIGN(J) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1195 ## in the (N,N+1-ABS(J)) position, and zeros everywhere else. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1196 ## Defaults: I = N, j = -N. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1197 ## All eigenvalues are of the form 2*COS(a) and the eigenvectors |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1198 ## are of the form [SIN(w+a), SIN(w+2a), ..., SIN(w+Na)]. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1199 ## The values of a and w are given in the reference below. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1200 ## A can have double and triple eigenvalues and can be defective. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1201 ## GEARMAT(N) is singular. |
16634 | 1202 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1203 ## (GEAR is a Simulink function, hence GEARMAT for Gear matrix.) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1204 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1205 ## C.W. Gear, A simple set of test matrices for eigenvalue programs, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1206 ## Math. Comp., 23 (1969), pp. 119-125. |
16634 | 1207 |
1208 if (nargin < 1 || nargin > 3) | |
1209 error ("gallery: 1 to 3 arguments are required for gearmat matrix."); | |
1210 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
1211 error ("gallery: N must be an integer for gearmat matrix."); | |
20294
2102c4582e32
gallery: fix chebspec, cycol, gearmat, hanowa, lauchli, and pei (bug #45466)
Massimiliano Fasi <massimiliano.fasi@gmail.com>
parents:
20231
diff
changeset
|
1212 elseif (! isnumeric (i) || ! isscalar (i) || i == 0 || abs (i) > n) |
18812
9ac2357f19bc
doc: Replace "non-zero" with "nonzero" to match existing usage.
Rik <rik@octave.org>
parents:
17386
diff
changeset
|
1213 error ("gallery: I must be a nonzero scalar, and abs (I) <= N for gearmat matrix."); |
20294
2102c4582e32
gallery: fix chebspec, cycol, gearmat, hanowa, lauchli, and pei (bug #45466)
Massimiliano Fasi <massimiliano.fasi@gmail.com>
parents:
20231
diff
changeset
|
1214 elseif (! isnumeric (j) || ! isscalar (j) || i == 0 || abs (j) > n) |
18812
9ac2357f19bc
doc: Replace "non-zero" with "nonzero" to match existing usage.
Rik <rik@octave.org>
parents:
17386
diff
changeset
|
1215 error ("gallery: J must be a nonzero scalar, and abs (J) <= N for gearmat matrix."); |
16634 | 1216 endif |
1217 | |
1218 A = diag (ones (n-1, 1), -1) + diag (ones (n-1, 1), 1); | |
1219 A(1, abs (i)) = sign (i); | |
1220 A(n, n+1 - abs (j)) = sign (j); | |
1221 endfunction | |
1222 | |
1223 function G = grcar (n, k = 3) | |
1224 ## GRCAR Grcar matrix - a Toeplitz matrix with sensitive eigenvalues. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1225 ## GRCAR(N, K) is an N-by-N matrix with -1s on the |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1226 ## subdiagonal, 1s on the diagonal, and K superdiagonals of 1s. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1227 ## The default is K = 3. The eigenvalues of this matrix form an |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1228 ## interesting pattern in the complex plane (try PS(GRCAR(32))). |
16634 | 1229 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1230 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1231 ## J.F. Grcar, Operator coefficient methods for linear equations, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1232 ## Report SAND89-8691, Sandia National Laboratories, Albuquerque, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1233 ## New Mexico, 1989 (Appendix 2). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1234 ## N.M. Nachtigal, L. Reichel and L.N. Trefethen, A hybrid GMRES |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1235 ## algorithm for nonsymmetric linear systems, SIAM J. Matrix Anal. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1236 ## Appl., 13 (1992), pp. 796-825. |
16634 | 1237 |
1238 if (nargin < 1 || nargin > 2) | |
1239 error ("gallery: 1 to 2 arguments are required for grcar matrix."); | |
1240 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
1241 error ("gallery: N must be an integer for grcar matrix."); | |
1242 elseif (! isnumeric (k) || ! isscalar (k)) | |
1243 error ("gallery: K must be a numeric scalar for grcar matrix."); | |
1244 endif | |
1245 | |
1246 G = tril (triu (ones (n)), k) - diag (ones (n-1, 1), -1); | |
1247 endfunction | |
1248 | |
1249 function A = hanowa (n, d = -1) | |
1250 ## HANOWA A matrix whose eigenvalues lie on a vertical line in the complex plane. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1251 ## HANOWA(N, d) is the N-by-N block 2x2 matrix (thus N = 2M must be even) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1252 ## [d*EYE(M) -DIAG(1:M) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1253 ## DIAG(1:M) d*EYE(M)] |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1254 ## It has complex eigenvalues lambda(k) = d +/- k*i (1 <= k <= M). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1255 ## Parameter d defaults to -1. |
16634 | 1256 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1257 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1258 ## E. Hairer, S.P. Norsett and G. Wanner, Solving Ordinary |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1259 ## Differential Equations I: Nonstiff Problems, Springer-Verlag, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1260 ## Berlin, 1987. (pp. 86-87) |
16634 | 1261 |
1262 if (nargin < 1 || nargin > 2) | |
1263 error ("gallery: 1 to 2 arguments are required for hanowa matrix."); | |
1264 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
1265 error ("gallery: N must be an integer for hanowa matrix."); | |
1266 elseif (rem (n, 2) != 0) | |
1267 error ("gallery: N must be even for hanowa matrix."); | |
20294
2102c4582e32
gallery: fix chebspec, cycol, gearmat, hanowa, lauchli, and pei (bug #45466)
Massimiliano Fasi <massimiliano.fasi@gmail.com>
parents:
20231
diff
changeset
|
1268 elseif (! isnumeric (d) || ! isscalar (d)) |
16634 | 1269 error ("gallery: D must be a numeric scalar for hanowa matrix."); |
1270 endif | |
1271 | |
1272 m = n/2; | |
1273 A = [ d*eye(m) -diag(1:m) | |
1274 diag(1:m) d*eye(m) ]; | |
1275 endfunction | |
1276 | |
1277 function [v, beta] = house (x) | |
1278 ## HOUSE Householder matrix. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1279 ## If [v, beta] = HOUSE(x) then H = EYE - beta*v*v' is a Householder |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1280 ## matrix such that Hx = -sign(x(1))*norm(x)*e_1. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1281 ## NB: If x = 0 then v = 0, beta = 1 is returned. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1282 ## x can be real or complex. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1283 ## sign(x) := exp(i*arg(x)) ( = x./abs(x) when x ~= 0). |
16634 | 1284 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1285 ## Theory: (textbook references Golub & Van Loan 1989, 38-43; |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1286 ## Stewart 1973, 231-234, 262; Wilkinson 1965, 48-50). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1287 ## Hx = y: (I - beta*v*v')x = -s*e_1. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1288 ## Must have |s| = norm(x), v = x+s*e_1, and |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1289 ## x'y = x'Hx =(x'Hx)' real => arg(s) = arg(x(1)). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1290 ## So take s = sign(x(1))*norm(x) (which avoids cancellation). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1291 ## v'v = (x(1)+s)^2 + x(2)^2 + ... + x(n)^2 |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1292 ## = 2*norm(x)*(norm(x) + |x(1)|). |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17386
diff
changeset
|
1293 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1294 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1295 ## G.H. Golub and C.F. Van Loan, Matrix Computations, second edition, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1296 ## Johns Hopkins University Press, Baltimore, Maryland, 1989. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1297 ## G.W. Stewart, Introduction to Matrix Computations, Academic Press, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1298 ## New York, 1973, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1299 ## J.H. Wilkinson, The Algebraic Eigenvalue Problem, Oxford University |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1300 ## Press, 1965. |
16634 | 1301 |
1302 if (nargin != 1) | |
1303 error ("gallery: 1 argument is required for house matrix."); | |
20295
557979395ca9
gallery: allow single element vectors for 'house'.
Carnë Draug <carandraug@octave.org>
parents:
20294
diff
changeset
|
1304 elseif (! isnumeric (x) || ! isvector (x)) |
16634 | 1305 error ("gallery: X must be a vector for house matrix."); |
1306 endif | |
1307 | |
1308 ## must be a column vector | |
1309 x = x(:); | |
1310 | |
1311 s = norm (x) * (sign (x(1)) + (x(1) == 0)); # Modification for sign (0) == 1. | |
1312 v = x; | |
1313 if (s == 0) | |
1314 ## Quit if x is the zero vector. | |
1315 beta = 1; | |
1316 else | |
1317 v(1) = v(1) + s; | |
1318 beta = 1/(s'*v(1)); # NB the conjugated s. | |
1319 ## beta = 1/(abs (s) * (abs (s) +abs(x(1)) would guarantee beta real. | |
1320 ## But beta as above can be non-real (due to rounding) only when x is complex. | |
1321 endif | |
1322 endfunction | |
1323 | |
16980
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1324 function A = integerdata (varargin) |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1325 |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1326 if (nargin < 3) |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1327 error ("gallery: At least 3 arguments required for integerdata matrix."); |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1328 endif |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1329 |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1330 if (isnumeric (varargin{end})) |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1331 jidx = varargin{end}; |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1332 svec = [varargin{:}]; |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1333 varargin(end) = []; |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1334 elseif (ischar (varargin{end})) |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1335 if (nargin < 4) |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1336 error (["gallery: CLASS argument requires 4 inputs " ... |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1337 "for integerdata matrix."]); |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1338 endif |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1339 jidx = varargin{end-1}; |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1340 svec = [varargin{1:end-1}]; |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1341 varargin(end-1) = []; |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17386
diff
changeset
|
1342 else |
16980
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1343 error (["gallery: J must be an integer in the range [0, 2^32-1] " ... |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1344 "for integerdata matrix"]); |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1345 endif |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1346 |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1347 if (! (isnumeric (jidx) && isscalar (jidx) |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1348 && jidx == fix (jidx) |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1349 && jidx >= 0 && jidx <= 0xFFFFFFFF)) |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1350 error (["gallery: J must be an integer in the range [0, 2^32-1] " ... |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1351 "for integerdata matrix"]); |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1352 endif |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1353 |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1354 ## Save and restore random state. Initialization done so that reproducible |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1355 ## data is available from gallery depending on the jidx and size vector. |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17386
diff
changeset
|
1356 randstate = rand ("state"); |
16980
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1357 unwind_protect |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1358 rand ("state", svec); |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1359 A = randi (varargin{:}); |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1360 unwind_protect_cleanup |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1361 rand ("state", randstate); |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1362 end_unwind_protect |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1363 |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1364 endfunction |
1909e1ed63e6
gallery.m: Add 'integerdata' matrix to function.
Rik <rik@octave.org>
parents:
16979
diff
changeset
|
1365 |
16634 | 1366 function A = invhess (x, y) |
1367 ## INVHESS Inverse of an upper Hessenberg matrix. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1368 ## INVHESS(X, Y), where X is an N-vector and Y an N-1 vector, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1369 ## is the matrix whose lower triangle agrees with that of |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1370 ## ONES(N,1)*X' and whose strict upper triangle agrees with |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1371 ## that of [1 Y]*ONES(1,N). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1372 ## The matrix is nonsingular if X(1) ~= 0 and X(i+1) ~= Y(i) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1373 ## for all i, and its inverse is an upper Hessenberg matrix. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1374 ## If Y is omitted it defaults to -X(1:N-1). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1375 ## Special case: if X is a scalar INVHESS(X) is the same as |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1376 ## INVHESS(1:X). |
16634 | 1377 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1378 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1379 ## F.N. Valvi and V.S. Geroyannis, Analytic inverses and |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1380 ## determinants for a class of matrices, IMA Journal of Numerical |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1381 ## Analysis, 7 (1987), pp. 123-128. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1382 ## W.-L. Cao and W.J. Stewart, A note on inverses of Hessenberg-like |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1383 ## matrices, Linear Algebra and Appl., 76 (1986), pp. 233-240. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1384 ## Y. Ikebe, On inverses of Hessenberg matrices, Linear Algebra and |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1385 ## Appl., 24 (1979), pp. 93-97. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1386 ## P. Rozsa, On the inverse of band matrices, Integral Equations and |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1387 ## Operator Theory, 10 (1987), pp. 82-95. |
16634 | 1388 |
1389 if (nargin < 1 || nargin > 2) | |
1390 error ("gallery: 1 to 2 arguments are required for invhess matrix."); | |
1391 elseif (! isnumeric (x)) | |
1392 error ("gallery: X must be numeric for invhess matrix."); | |
1393 endif | |
1394 | |
1395 if (isscalar (x) && fix (x) == x) | |
1396 n = x; | |
1397 x = 1:n; | |
1398 elseif (! isscalar (x) && isvector (x)) | |
20297
26fc9bbb8762
gallery: fix typo on variable name for invhess matrix.
Carnë Draug <carandraug@octave.org>
parents:
20296
diff
changeset
|
1399 n = numel (x); |
16634 | 1400 else |
1401 error ("gallery: X must be an integer scalar, or a vector for invhess matrix."); | |
1402 endif | |
1403 | |
1404 if (nargin < 2) | |
1405 y = -x(1:end-1); | |
1406 elseif (! isvector (y) || numel (y) != numel (x) -1) | |
1407 error ("gallery: Y must be a vector of length -1 than X for invhess matrix."); | |
1408 endif | |
1409 | |
1410 x = x(:); | |
1411 y = y(:); | |
1412 | |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
1413 ## FIXME: On next line, z = x'; A = z(ones(n,1),:) would be more efficient. |
16634 | 1414 A = ones (n, 1) * x'; |
1415 for j = 2:n | |
1416 A(1:j-1,j) = y(1:j-1); | |
1417 endfor | |
1418 endfunction | |
1419 | |
1420 function A = invol (n) | |
1421 ## INVOL An involutory matrix. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1422 ## A = INVOL(N) is an N-by-N involutory (A*A = EYE(N)) and |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1423 ## ill-conditioned matrix. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1424 ## It is a diagonally scaled version of HILB(N). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1425 ## NB: B = (EYE(N)-A)/2 and B = (EYE(N)+A)/2 are idempotent (B*B = B). |
16634 | 1426 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1427 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1428 ## A.S. Householder and J.A. Carpenter, The singular values |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1429 ## of involutory and of idempotent matrices, Numer. Math. 5 (1963), |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1430 ## pp. 234-237. |
16634 | 1431 |
1432 if (nargin != 1) | |
1433 error ("gallery: 1 argument is required for invol matrix."); | |
1434 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
1435 error ("gallery: N must be an integer for invol matrix."); | |
1436 endif | |
1437 | |
1438 A = hilb (n); | |
1439 | |
1440 d = -n; | |
1441 A(:, 1) = d * A(:, 1); | |
1442 | |
1443 for i = 1:n-1 | |
1444 d = -(n+i)*(n-i)*d/(i*i); | |
1445 A(i+1,:) = d * A(i+1,:); | |
1446 endfor | |
1447 endfunction | |
1448 | |
1449 function [A, detA] = ipjfact (n, k = 0) | |
1450 ## IPJFACT A Hankel matrix with factorial elements. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1451 ## A = IPJFACT(N, K) is the matrix with |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1452 ## A(i,j) = (i+j)! (K = 0, default) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1453 ## A(i,j) = 1/(i+j)! (K = 1) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1454 ## Both are Hankel matrices. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1455 ## The determinant and inverse are known explicitly. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1456 ## If a second output argument is present, d = DET(A) is returned: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1457 ## [A, d] = IPJFACT(N, K); |
16634 | 1458 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1459 ## Suggested by P. R. Graves-Morris. |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17386
diff
changeset
|
1460 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1461 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1462 ## M.J.C. Gover, The explicit inverse of factorial Hankel matrices, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1463 ## Dept. of Mathematics, University of Bradford, 1993. |
16634 | 1464 |
1465 if (nargin < 1 || nargin > 2) | |
1466 error ("gallery: 1 to 2 arguments are required for ipjfact matrix."); | |
1467 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
1468 error ("gallery: N must be an integer for ipjfact matrix."); | |
1469 elseif (! isnumeric (k) || ! isscalar (k)) | |
1470 error ("gallery: K must be a numeric scalar for ipjfact matrix."); | |
1471 endif | |
1472 | |
1473 c = cumprod (2:n+1); | |
1474 d = cumprod (n+1:2*n) * c(n-1); | |
1475 | |
1476 A = hankel (c, d); | |
1477 | |
1478 switch (k) | |
1479 case (0), # do nothing | |
1480 case (1), A = ones (n) ./ A; | |
1481 otherwise | |
1482 error ("gallery: K must have a value of 0 or 1 for ipjfact matrix."); | |
1483 endswitch | |
1484 | |
1485 if (nargout == 2) | |
1486 d = 1; | |
1487 | |
1488 if (k == 0) | |
1489 for i = 1:n-1 | |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
20162
diff
changeset
|
1490 d *= prod (1:i+1) * prod (1:n-i); |
16634 | 1491 endfor |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
20162
diff
changeset
|
1492 d *= prod (1:n+1); |
16634 | 1493 |
1494 elseif (k == 1) | |
1495 for i = 0:n-1 | |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
20162
diff
changeset
|
1496 d *= prod (1:i) / prod (1:n+1+i); |
16634 | 1497 endfor |
1498 if (rem (n*(n-1)/2, 2)) | |
1499 d = -d; | |
1500 endif | |
1501 | |
1502 else | |
1503 error ("gallery: K must have a value of 0 or 1 for ipjfact matrix."); | |
1504 endif | |
1505 | |
1506 detA = d; | |
1507 endif | |
1508 endfunction | |
1509 | |
1510 function J = jordbloc (n, lambda = 1) | |
1511 ## JORDBLOC Jordan block. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1512 ## JORDBLOC(N, LAMBDA) is the N-by-N Jordan block with eigenvalue |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1513 ## LAMBDA. LAMBDA = 1 is the default. |
16634 | 1514 |
1515 if (nargin < 1 || nargin > 2) | |
1516 error ("gallery: 1 to 2 arguments are required for jordbloc matrix."); | |
1517 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
1518 error ("gallery: N must be an integer for jordbloc matrix."); | |
1519 elseif (! isnumeric (lambda) || ! isscalar (lambda)) | |
1520 error ("gallery: LAMBDA must be a numeric scalar for jordbloc matrix."); | |
1521 endif | |
1522 | |
1523 J = lambda * eye (n) + diag (ones (n-1, 1), 1); | |
1524 endfunction | |
1525 | |
1526 function U = kahan (n, theta = 1.2, pert = 25) | |
1527 ## KAHAN Kahan matrix - upper trapezoidal. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1528 ## KAHAN(N, THETA) is an upper trapezoidal matrix |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1529 ## that has some interesting properties regarding estimation of |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1530 ## condition and rank. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1531 ## The matrix is N-by-N unless N is a 2-vector, in which case it |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1532 ## is N(1)-by-N(2). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1533 ## The parameter THETA defaults to 1.2. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1534 ## The useful range of THETA is 0 < THETA < PI. |
16634 | 1535 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1536 ## To ensure that the QR factorization with column pivoting does not |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1537 ## interchange columns in the presence of rounding errors, the diagonal |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1538 ## is perturbed by PERT*EPS*diag( [N:-1:1] ). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1539 ## The default is PERT = 25, which ensures no interchanges for KAHAN(N) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1540 ## up to at least N = 90 in IEEE arithmetic. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1541 ## KAHAN(N, THETA, PERT) uses the given value of PERT. |
16634 | 1542 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1543 ## The inverse of KAHAN(N, THETA) is known explicitly: see |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1544 ## Higham (1987, p. 588), for example. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1545 ## The diagonal perturbation was suggested by Christian Bischof. |
16634 | 1546 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1547 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1548 ## W. Kahan, Numerical linear algebra, Canadian Math. Bulletin, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1549 ## 9 (1966), pp. 757-801. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1550 ## N.J. Higham, A survey of condition number estimation for |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1551 ## triangular matrices, SIAM Review, 29 (1987), pp. 575-596. |
16634 | 1552 |
1553 if (nargin < 1 || nargin > 3) | |
1554 error ("gallery: 1 to 3 arguments are required for kahan matrix."); | |
1555 elseif (! isnumeric (n) || all (numel (n) != [1 2]) || fix (n) != n) | |
1556 error ("gallery: N must be a 1 or 2 element integer for kahan matrix."); | |
1557 elseif (! isnumeric (theta) || ! isscalar (theta)) | |
1558 error ("gallery: THETA must be a numeric scalar for kahan matrix."); | |
1559 elseif (! isnumeric (pert) || ! isscalar (pert)) | |
1560 error ("gallery: PERT must be a numeric scalar for kahan matrix."); | |
1561 endif | |
1562 | |
1563 ## Parameter n specifies dimension: r-by-n | |
1564 r = n(1); | |
1565 n = n(end); | |
1566 | |
1567 s = sin (theta); | |
1568 c = cos (theta); | |
1569 | |
1570 U = eye (n) - c * triu (ones (n), 1); | |
1571 U = diag (s.^[0:n-1]) * U + pert*eps* diag ([n:-1:1]); | |
1572 if (r > n) | |
1573 U(r,n) = 0; # Extend to an r-by-n matrix | |
1574 else | |
1575 U = U(1:r,:); # Reduce to an r-by-n matrix | |
1576 endif | |
1577 endfunction | |
1578 | |
1579 function A = kms (n, rho = 0.5) | |
1580 ## KMS Kac-Murdock-Szego Toeplitz matrix. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1581 ## A = KMS(N, RHO) is the N-by-N Kac-Murdock-Szego Toeplitz matrix with |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1582 ## A(i,j) = RHO^(ABS((i-j))) (for real RHO). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1583 ## If RHO is complex, then the same formula holds except that elements |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1584 ## below the diagonal are conjugated. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1585 ## RHO defaults to 0.5. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1586 ## Properties: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1587 ## A has an LDL' factorization with |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1588 ## L = INV(TRIW(N,-RHO,1)'), |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1589 ## D(i,i) = (1-ABS(RHO)^2)*EYE(N) except D(1,1) = 1. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1590 ## A is positive definite if and only if 0 < ABS(RHO) < 1. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1591 ## INV(A) is tridiagonal. |
16634 | 1592 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1593 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1594 ## W.F. Trench, Numerical solution of the eigenvalue problem |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1595 ## for Hermitian Toeplitz matrices, SIAM J. Matrix Analysis and Appl., |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1596 ## 10 (1989), pp. 135-146 (and see the references therein). |
16634 | 1597 |
1598 if (nargin < 1 || nargin > 2) | |
1599 error ("gallery: 1 to 2 arguments are required for lauchli matrix."); | |
1600 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
21385
89fa0694aa2e
Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents:
20929
diff
changeset
|
1601 error ("gallery: N must be an integer for lauchli matrix."); |
20294
2102c4582e32
gallery: fix chebspec, cycol, gearmat, hanowa, lauchli, and pei (bug #45466)
Massimiliano Fasi <massimiliano.fasi@gmail.com>
parents:
20231
diff
changeset
|
1602 elseif (! isscalar (rho)) |
21385
89fa0694aa2e
Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents:
20929
diff
changeset
|
1603 error ("gallery: RHO must be a scalar for lauchli matrix."); |
16634 | 1604 endif |
1605 | |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
1606 A = (1:n)'*ones (1,n); |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
1607 A = abs (A - A'); |
16634 | 1608 A = rho .^ A; |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
1609 if (imag (rho)) |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
1610 A = conj (tril (A,-1)) + triu (A); |
16634 | 1611 endif |
1612 endfunction | |
1613 | |
1614 function B = krylov (A, x, j) | |
1615 ## KRYLOV Krylov matrix. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1616 ## KRYLOV(A, x, j) is the Krylov matrix |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1617 ## [x, Ax, A^2x, ..., A^(j-1)x], |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1618 ## where A is an n-by-n matrix and x is an n-vector. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1619 ## Defaults: x = ONES(n,1), j = n. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1620 ## KRYLOV(n) is the same as KRYLOV(RANDN(n)). |
16634 | 1621 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1622 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1623 ## G.H. Golub and C.F. Van Loan, Matrix Computations, second edition, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1624 ## Johns Hopkins University Press, Baltimore, Maryland, 1989, p. 369. |
16634 | 1625 |
1626 if (nargin < 1 || nargin > 3) | |
1627 error ("gallery: 1 to 3 arguments are required for krylov matrix."); | |
1628 elseif (! isnumeric (A) || ! issquare (A) || ndims (A) != 2) | |
17199 | 1629 error ("gallery: A must be a square 2-D matrix for krylov matrix."); |
16634 | 1630 endif |
1631 | |
1632 n = length (A); | |
1633 if (isscalar (A)) | |
1634 n = A; | |
1635 A = randn (n); | |
1636 endif | |
1637 | |
1638 if (nargin < 2) | |
1639 x = ones (n, 1); | |
1640 elseif (! isvector (x) || numel (x) != n) | |
1641 error ("gallery: X must be a vector of length equal to A for krylov matrix."); | |
1642 endif | |
1643 | |
1644 if (nargin < 3) | |
1645 j = n; | |
1646 elseif (! isnumeric (j) || ! isscalar (j) || fix (j) != j) | |
1647 error ("gallery: J must be an integer for krylov matrix."); | |
1648 endif | |
1649 | |
1650 B = ones (n, j); | |
1651 B(:,1) = x(:); | |
1652 for i = 2:j | |
1653 B(:,i) = A*B(:,i-1); | |
1654 endfor | |
1655 endfunction | |
1656 | |
1657 function A = lauchli (n, mu = sqrt (eps)) | |
1658 ## LAUCHLI Lauchli matrix - rectangular. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1659 ## LAUCHLI(N, MU) is the (N+1)-by-N matrix [ONES(1,N); MU*EYE(N))]. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1660 ## It is a well-known example in least squares and other problems |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1661 ## that indicates the dangers of forming A'*A. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1662 ## MU defaults to SQRT(EPS). |
16634 | 1663 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1664 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1665 ## P. Lauchli, Jordan-Elimination und Ausgleichung nach |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1666 ## kleinsten Quadraten, Numer. Math, 3 (1961), pp. 226-240. |
16634 | 1667 |
1668 if (nargin < 1 || nargin > 2) | |
1669 error ("gallery: 1 to 2 arguments are required for lauchli matrix."); | |
1670 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
1671 error ("gallery: N must be an integer for lauchli matrix."); | |
1672 elseif (! isscalar (mu)) | |
1673 error ("gallery: MU must be a scalar for lauchli matrix."); | |
1674 endif | |
1675 | |
1676 A = [ones(1, n) | |
1677 mu*eye(n) ]; | |
1678 endfunction | |
1679 | |
1680 function A = lehmer (n) | |
1681 ## LEHMER Lehmer matrix - symmetric positive definite. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1682 ## A = LEHMER(N) is the symmetric positive definite N-by-N matrix with |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1683 ## A(i,j) = i/j for j >= i. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1684 ## A is totally nonnegative. INV(A) is tridiagonal, and explicit |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1685 ## formulas are known for its entries. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1686 ## N <= COND(A) <= 4*N*N. |
16634 | 1687 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1688 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1689 ## M. Newman and J. Todd, The evaluation of matrix inversion |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1690 ## programs, J. Soc. Indust. Appl. Math., 6 (1958), pp. 466-476. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1691 ## Solutions to problem E710 (proposed by D.H. Lehmer): The inverse |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1692 ## of a matrix, Amer. Math. Monthly, 53 (1946), pp. 534-535. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1693 ## J. Todd, Basic Numerical Mathematics, Vol. 2: Numerical Algebra, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1694 ## Birkhauser, Basel, and Academic Press, New York, 1977, p. 154. |
16634 | 1695 |
1696 if (nargin != 1) | |
1697 error ("gallery: 1 argument is required for lehmer matrix."); | |
1698 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
1699 error ("gallery: N must be an integer for lehmer matrix."); | |
1700 endif | |
1701 | |
1702 A = ones (n, 1) * (1:n); | |
1703 A = A./A'; | |
1704 A = tril (A) + tril (A, -1)'; | |
1705 endfunction | |
1706 | |
1707 function T = lesp (n) | |
1708 ## LESP A tridiagonal matrix with real, sensitive eigenvalues. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1709 ## LESP(N) is an N-by-N matrix whose eigenvalues are real and smoothly |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1710 ## distributed in the interval approximately [-2*N-3.5, -4.5]. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1711 ## The sensitivities of the eigenvalues increase exponentially as |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1712 ## the eigenvalues grow more negative. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1713 ## The matrix is similar to the symmetric tridiagonal matrix with |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1714 ## the same diagonal entries and with off-diagonal entries 1, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1715 ## via a similarity transformation with D = diag(1!,2!,...,N!). |
16634 | 1716 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1717 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1718 ## H.W.J. Lenferink and M.N. Spijker, On the use of stability regions in |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1719 ## the numerical analysis of initial value problems, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1720 ## Math. Comp., 57 (1991), pp. 221-237. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1721 ## L.N. Trefethen, Pseudospectra of matrices, in Numerical Analysis 1991, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1722 ## Proceedings of the 14th Dundee Conference, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1723 ## D.F. Griffiths and G.A. Watson, eds, Pitman Research Notes in |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1724 ## Mathematics, volume 260, Longman Scientific and Technical, Essex, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1725 ## UK, 1992, pp. 234-266. |
16634 | 1726 |
1727 if (nargin != 1) | |
1728 error ("gallery: 1 argument is required for lesp matrix."); | |
1729 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
1730 error ("gallery: N must be an integer for lesp matrix."); | |
1731 endif | |
1732 | |
1733 x = 2:n; | |
1734 T = full (tridiag (ones (size (x)) ./x, -(2*[x n+1]+1), x)); | |
1735 endfunction | |
1736 | |
1737 function A = lotkin (n) | |
1738 ## LOTKIN Lotkin matrix. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1739 ## A = LOTKIN(N) is the Hilbert matrix with its first row altered to |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1740 ## all ones. A is unsymmetric, ill-conditioned, and has many negative |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1741 ## eigenvalues of small magnitude. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1742 ## The inverse has integer entries and is known explicitly. |
16634 | 1743 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1744 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1745 ## M. Lotkin, A set of test matrices, MTAC, 9 (1955), pp. 153-161. |
16634 | 1746 |
1747 if (nargin != 1) | |
1748 error ("gallery: 1 argument is required for lotkin matrix."); | |
1749 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
1750 error ("gallery: N must be an integer for lotkin matrix."); | |
1751 endif | |
1752 | |
1753 A = hilb (n); | |
1754 A(1,:) = ones (1, n); | |
1755 endfunction | |
1756 | |
1757 function A = minij (n) | |
1758 ## MINIJ Symmetric positive definite matrix MIN(i,j). | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1759 ## A = MINIJ(N) is the N-by-N symmetric positive definite matrix with |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1760 ## A(i,j) = MIN(i,j). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1761 ## Properties, variations: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1762 ## INV(A) is tridiagonal: it is minus the second difference matrix |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1763 ## except its (N,N) element is 1. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1764 ## 2*A-ONES(N) (Givens' matrix) has tridiagonal inverse and |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1765 ## eigenvalues .5*sec^2([2r-1)PI/4N], r=1:N. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1766 ## (N+1)*ONES(N)-A also has a tridiagonal inverse. |
16634 | 1767 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1768 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1769 ## J. Todd, Basic Numerical Mathematics, Vol. 2: Numerical Algebra, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1770 ## Birkhauser, Basel, and Academic Press, New York, 1977, p. 158. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1771 ## D.E. Rutherford, Some continuant determinants arising in physics and |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1772 ## chemistry---II, Proc. Royal Soc. Edin., 63, A (1952), pp. 232-241. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1773 ## (For the eigenvalues of Givens' matrix.) |
16634 | 1774 |
1775 if (nargin != 1) | |
1776 error ("gallery: 1 argument is required for minij matrix."); | |
1777 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
1778 error ("gallery: N must be an integer for minij matrix."); | |
1779 endif | |
1780 | |
19944
941e782d0429
gallery: performance increase for minij matrix.
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
1781 A = bsxfun (@min, 1:n, (1:n)'); |
16634 | 1782 endfunction |
1783 | |
1784 function A = moler (n, alpha = -1) | |
1785 ## MOLER Moler matrix - symmetric positive definite. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1786 ## A = MOLER(N, ALPHA) is the symmetric positive definite N-by-N matrix |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1787 ## U'*U where U = TRIW(N, ALPHA). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1788 ## For ALPHA = -1 (the default) A(i,j) = MIN(i,j)-2, A(i,i) = i. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1789 ## A has one small eigenvalue. |
16634 | 1790 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1791 ## Nash (1990) attributes the ALPHA = -1 matrix to Moler. |
16634 | 1792 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1793 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1794 ## J.C. Nash, Compact Numerical Methods for Computers: Linear |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1795 ## Algebra and Function Minimisation, second edition, Adam Hilger, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1796 ## Bristol, 1990 (Appendix 1). |
16634 | 1797 |
1798 if (nargin < 1 || nargin > 2) | |
1799 error ("gallery: 1 to 2 arguments are required for moler matrix."); | |
1800 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
1801 error ("gallery: N must be an integer for moler matrix."); | |
1802 elseif (! isscalar (alpha)) | |
1803 error ("gallery: ALPHA must be a scalar for moler matrix."); | |
1804 endif | |
1805 | |
1806 A = triw (n, alpha)' * triw (n, alpha); | |
1807 endfunction | |
1808 | |
1809 function [A, T] = neumann (n) | |
1810 ## NEUMANN Singular matrix from the discrete Neumann problem (sparse). | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1811 ## NEUMANN(N) is the singular, row diagonally dominant matrix resulting |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1812 ## from discretizing the Neumann problem with the usual five point |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1813 ## operator on a regular mesh. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1814 ## It has a one-dimensional null space with null vector ONES(N,1). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1815 ## The dimension N should be a perfect square, or else a 2-vector, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1816 ## in which case the dimension of the matrix is N(1)*N(2). |
16634 | 1817 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1818 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1819 ## R.J. Plemmons, Regular splittings and the discrete Neumann |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1820 ## problem, Numer. Math., 25 (1976), pp. 153-161. |
16634 | 1821 |
1822 if (nargin != 1) | |
1823 error ("gallery: 1 argument is required for neumann matrix."); | |
1824 elseif (! isnumeric (n) || all (numel (n) != [1 2]) || fix (n) != n) | |
1825 error ("gallery: N must be a 1 or 2 element integer for neumann matrix."); | |
1826 endif | |
1827 | |
1828 if (isscalar (n)) | |
1829 m = sqrt (n); | |
1830 if (m^2 != n) | |
1831 error ("gallery: N must be a perfect square for neumann matrix."); | |
1832 endif | |
1833 n(1) = m; | |
1834 n(2) = m; | |
1835 endif | |
1836 | |
1837 T = tridiag (n(1), -1, 2, -1); | |
1838 T(1,2) = -2; | |
1839 T(n(1),n(1)-1) = -2; | |
1840 | |
1841 A = kron (T, eye (n(2))) + kron (eye (n(2)), T); | |
1842 endfunction | |
1843 | |
16979
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1844 function A = normaldata (varargin) |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1845 |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1846 if (nargin < 2) |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1847 error ("gallery: At least 2 arguments required for normaldata matrix."); |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1848 endif |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1849 if (isnumeric (varargin{end})) |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1850 jidx = varargin{end}; |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1851 svec = [varargin{:}]; |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1852 varargin(end) = []; |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1853 elseif (ischar (varargin{end})) |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1854 if (nargin < 3) |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1855 error (["gallery: CLASS argument requires 3 inputs " ... |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1856 "for normaldata matrix."]); |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1857 endif |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1858 jidx = varargin{end-1}; |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1859 svec = [varargin{1:end-1}]; |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1860 varargin(end-1) = []; |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17386
diff
changeset
|
1861 else |
16979
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1862 error (["gallery: J must be an integer in the range [0, 2^32-1] " ... |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1863 "for normaldata matrix"]); |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1864 endif |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1865 |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1866 if (! (isnumeric (jidx) && isscalar (jidx) |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1867 && jidx == fix (jidx) |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1868 && jidx >= 0 && jidx <= 0xFFFFFFFF)) |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1869 error (["gallery: J must be an integer in the range [0, 2^32-1] " ... |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1870 "for normaldata matrix"]); |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1871 endif |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1872 |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1873 ## Save and restore random state. Initialization done so that reproducible |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1874 ## data is available from gallery depending on the jidx and size vector. |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17386
diff
changeset
|
1875 randstate = randn ("state"); |
16979
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1876 unwind_protect |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1877 randn ("state", svec); |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1878 A = randn (varargin{:}); |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1879 unwind_protect_cleanup |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1880 randn ("state", randstate); |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1881 end_unwind_protect |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1882 |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1883 endfunction |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
1884 |
16634 | 1885 function Q = orthog (n, k = 1) |
1886 ## ORTHOG Orthogonal and nearly orthogonal matrices. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1887 ## Q = ORTHOG(N, K) selects the K'th type of matrix of order N. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1888 ## K > 0 for exactly orthogonal matrices, K < 0 for diagonal scalings of |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1889 ## orthogonal matrices. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1890 ## Available types: (K = 1 is the default) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1891 ## K = 1: Q(i,j) = SQRT(2/(n+1)) * SIN( i*j*PI/(n+1) ) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1892 ## Symmetric eigenvector matrix for second difference matrix. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1893 ## K = 2: Q(i,j) = 2/SQRT(2*n+1)) * SIN( 2*i*j*PI/(2*n+1) ) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1894 ## Symmetric. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1895 ## K = 3: Q(r,s) = EXP(2*PI*i*(r-1)*(s-1)/n) / SQRT(n) (i=SQRT(-1)) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1896 ## Unitary, the Fourier matrix. Q^4 is the identity. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1897 ## This is essentially the same matrix as FFT(EYE(N))/SQRT(N)! |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1898 ## K = 4: Helmert matrix: a permutation of a lower Hessenberg matrix, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1899 ## whose first row is ONES(1:N)/SQRT(N). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1900 ## K = 5: Q(i,j) = SIN( 2*PI*(i-1)*(j-1)/n ) + COS( 2*PI*(i-1)*(j-1)/n ). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1901 ## Symmetric matrix arising in the Hartley transform. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1902 ## K = -1: Q(i,j) = COS( (i-1)*(j-1)*PI/(n-1) ) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1903 ## Chebyshev Vandermonde-like matrix, based on extrema of T(n-1). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1904 ## K = -2: Q(i,j) = COS( (i-1)*(j-1/2)*PI/n) ) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1905 ## Chebyshev Vandermonde-like matrix, based on zeros of T(n). |
16634 | 1906 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1907 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1908 ## N.J. Higham and D.J. Higham, Large growth factors in Gaussian |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1909 ## elimination with pivoting, SIAM J. Matrix Analysis and Appl., |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1910 ## 10 (1989), pp. 155-164. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1911 ## P. Morton, On the eigenvectors of Schur's matrix, J. Number Theory, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1912 ## 12 (1980), pp. 122-127. (Re. ORTHOG(N, 3)) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1913 ## H.O. Lancaster, The Helmert Matrices, Amer. Math. Monthly, 72 (1965), |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1914 ## pp. 4-12. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1915 ## D. Bini and P. Favati, On a matrix algebra related to the discrete |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1916 ## Hartley transform, SIAM J. Matrix Anal. Appl., 14 (1993), |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1917 ## pp. 500-507. |
16634 | 1918 |
1919 if (nargin < 1 || nargin > 2) | |
1920 error ("gallery: 1 to 2 arguments are required for orthog matrix."); | |
1921 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
1922 error ("gallery: N must be an integer for orthog matrix."); | |
1923 elseif (! isnumeric (k) || ! isscalar (k)) | |
1924 error ("gallery: K must be a numeric scalar for orthog matrix."); | |
1925 endif | |
1926 | |
1927 switch (k) | |
1928 case (1) | |
1929 ## E'vectors second difference matrix | |
1930 m = (1:n)'*(1:n) * (pi/(n+1)); | |
1931 Q = sin (m) * sqrt (2/(n+1)); | |
1932 | |
1933 case (2) | |
1934 m = (1:n)'*(1:n) * (2*pi/(2*n+1)); | |
1935 Q = sin (m) * (2/ sqrt (2*n+1)); | |
1936 | |
1937 case (3) | |
1938 ## Vandermonde based on roots of unity | |
1939 m = 0:n-1; | |
1940 Q = exp (m'*m*2*pi* sqrt (-1) / n) / sqrt (n); | |
1941 | |
1942 case (4) | |
1943 ## Helmert matrix | |
1944 Q = tril (ones (n)); | |
1945 Q(1,2:n) = ones (1, n-1); | |
1946 for i = 2:n | |
1947 Q(i,i) = -(i-1); | |
17306
09543e9c8f40
Use explicit form of end (endif, endfor, etc.) in core m-files.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1948 endfor |
16634 | 1949 Q = diag (sqrt ([n 1:n-1] .* [1:n])) \ Q; |
1950 | |
1951 case (5) | |
1952 ## Hartley matrix | |
1953 m = (0:n-1)'*(0:n-1) * (2*pi/n); | |
1954 Q = (cos (m) + sin (m)) / sqrt (n); | |
1955 | |
1956 case (-1) | |
1957 ## extrema of T(n-1) | |
1958 m = (0:n-1)'*(0:n-1) * (pi/(n-1)); | |
1959 Q = cos (m); | |
1960 | |
1961 case (-2) | |
1962 ## zeros of T(n) | |
1963 m = (0:n-1)'*(.5:n-.5) * (pi/n); | |
1964 Q = cos (m); | |
1965 | |
1966 otherwise | |
16766
7268845c0a1e
avoid backquote in error messages, some uses in doc strings
John W. Eaton <jwe@octave.org>
parents:
16734
diff
changeset
|
1967 error ("gallery: unknown K '%d' for orthog matrix.", k); |
16634 | 1968 endswitch |
1969 endfunction | |
1970 | |
1971 function A = parter (n) | |
1972 ## PARTER Parter matrix - a Toeplitz matrix with singular values near PI. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1973 ## PARTER(N) is the matrix with (i,j) element 1/(i-j+0.5). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1974 ## It is a Cauchy matrix and a Toeplitz matrix. |
16634 | 1975 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1976 ## At the Second SIAM Conference on Linear Algebra, Raleigh, N.C., |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1977 ## 1985, Cleve Moler noted that most of the singular values of |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1978 ## PARTER(N) are very close to PI. An explanation of the phenomenon |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1979 ## was given by Parter; see also the paper by Tyrtyshnikov. |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17386
diff
changeset
|
1980 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1981 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1982 ## The MathWorks Newsletter, Volume 1, Issue 1, March 1986, page 2. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1983 ## S.V. Parter, On the distribution of the singular values of Toeplitz |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1984 ## matrices, Linear Algebra and Appl., 80 (1986), pp. 115-130. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1985 ## E.E. Tyrtyshnikov, Cauchy-Toeplitz matrices and some applications, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1986 ## Linear Algebra and Appl., 149 (1991), pp. 1-18. |
16634 | 1987 |
1988 if (nargin != 1) | |
1989 error ("gallery: 1 argument is required for parter matrix."); | |
1990 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
1991 error ("gallery: N must be an integer for parter matrix."); | |
1992 endif | |
1993 | |
1994 A = cauchy ((1:n) + 0.5, -(1:n)); | |
1995 endfunction | |
1996 | |
1997 function P = pei (n, alpha = 1) | |
1998 ## PEI Pei matrix. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1999 ## PEI(N, ALPHA), where ALPHA is a scalar, is the symmetric matrix |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2000 ## ALPHA*EYE(N) + ONES(N). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2001 ## If ALPHA is omitted then ALPHA = 1 is used. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2002 ## The matrix is singular for ALPHA = 0, -N. |
16634 | 2003 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2004 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2005 ## M.L. Pei, A test matrix for inversion procedures, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2006 ## Comm. ACM, 5 (1962), p. 508. |
16634 | 2007 |
2008 if (nargin < 1 || nargin > 2) | |
2009 error ("gallery: 1 to 2 arguments are required for pei matrix."); | |
2010 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
2011 error ("gallery: N must be an integer for pei matrix."); | |
20294
2102c4582e32
gallery: fix chebspec, cycol, gearmat, hanowa, lauchli, and pei (bug #45466)
Massimiliano Fasi <massimiliano.fasi@gmail.com>
parents:
20231
diff
changeset
|
2012 elseif (! isnumeric (alpha) || ! isscalar (alpha)) |
16634 | 2013 error ("gallery: ALPHA must be a scalar for pei matrix."); |
2014 endif | |
2015 | |
2016 P = alpha * eye (n) + ones (n); | |
2017 endfunction | |
2018 | |
2019 function A = poisson (n) | |
2020 ## POISSON Block tridiagonal matrix from Poisson's equation (sparse). | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2021 ## POISSON(N) is the block tridiagonal matrix of order N^2 |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2022 ## resulting from discretizing Poisson's equation with the |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2023 ## 5-point operator on an N-by-N mesh. |
16634 | 2024 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2025 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2026 ## G.H. Golub and C.F. Van Loan, Matrix Computations, second edition, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2027 ## Johns Hopkins University Press, Baltimore, Maryland, 1989 |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2028 ## (Section 4.5.4). |
16634 | 2029 |
2030 if (nargin != 1) | |
2031 error ("gallery: 1 argument is required for poisson matrix."); | |
2032 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
2033 error ("gallery: N must be an integer for poisson matrix."); | |
2034 endif | |
2035 | |
2036 S = tridiag (n, -1, 2, -1); | |
2037 I = speye (n); | |
2038 A = kron (I, S) + kron (S, I); | |
2039 endfunction | |
2040 | |
2041 function A = prolate (n, w = 0.25) | |
2042 ## PROLATE Prolate matrix - symmetric, ill-conditioned Toeplitz matrix. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2043 ## A = PROLATE(N, W) is the N-by-N prolate matrix with parameter W. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2044 ## It is a symmetric Toeplitz matrix. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2045 ## If 0 < W < 0.5 then |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2046 ## - A is positive definite |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2047 ## - the eigenvalues of A are distinct, lie in (0, 1), and |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2048 ## tend to cluster around 0 and 1. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2049 ## W defaults to 0.25. |
16634 | 2050 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2051 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2052 ## J.M. Varah. The Prolate matrix. Linear Algebra and Appl., |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2053 ## 187:269--278, 1993. |
16634 | 2054 |
2055 if (nargin < 1 || nargin > 2) | |
2056 error ("gallery: 1 to 2 arguments are required for prolate matrix."); | |
2057 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
2058 error ("gallery: N must be an integer for prolate matrix."); | |
2059 elseif (! isnumeric (w) || ! isscalar (w)) | |
2060 error ("gallery: W must be a scalar for prolate matrix."); | |
2061 endif | |
2062 | |
2063 a = zeros (n, 1); | |
2064 a(1) = 2*w; | |
2065 a(2:n) = sin (2*pi*w*(1:n-1)) ./ (pi*(1:n-1)); | |
2066 | |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
2067 A = toeplitz (a); |
16634 | 2068 endfunction |
2069 | |
2070 function H = randhess (x) | |
2071 ## NOTE: this function was named ohess in the original Test Matrix Toolbox | |
2072 ## RANDHESS Random, orthogonal upper Hessenberg matrix. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2073 ## H = RANDHESS(N) is an N-by-N real, random, orthogonal |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2074 ## upper Hessenberg matrix. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2075 ## Alternatively, H = RANDHESS(X), where X is an arbitrary real |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2076 ## N-vector (N > 1) constructs H non-randomly using the elements |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2077 ## of X as parameters. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2078 ## In both cases H is constructed via a product of N-1 Givens rotations. |
16634 | 2079 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2080 ## Note: See Gragg (1986) for how to represent an N-by-N (complex) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2081 ## unitary Hessenberg matrix with positive subdiagonal elements in terms |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2082 ## of 2N-1 real parameters (the Schur parametrization). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2083 ## This M-file handles the real case only and is intended simply as a |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2084 ## convenient way to generate random or non-random orthogonal Hessenberg |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2085 ## matrices. |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17386
diff
changeset
|
2086 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2087 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2088 ## W.B. Gragg, The QR algorithm for unitary Hessenberg matrices, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2089 ## J. Comp. Appl. Math., 16 (1986), pp. 1-8. |
16634 | 2090 |
2091 if (nargin != 1) | |
2092 error ("gallery: 1 argument is required for randhess matrix."); | |
2093 elseif (! isnumeric (x) || ! isreal (x)) | |
2094 error ("gallery: N or X must be numeric real values for randhess matrix."); | |
2095 endif | |
2096 | |
2097 if (isscalar (x)) | |
2098 n = x; | |
2099 x = rand (n-1, 1) * 2*pi; | |
2100 H = eye (n); | |
2101 H(n,n) = sign (randn); | |
2102 elseif (isvector (x)) | |
2103 n = numel (x); | |
2104 H = eye (n); | |
2105 H(n,n) = sign (x(n)) + (x(n) == 0); # Second term ensures H(n,n) nonzero. | |
2106 else | |
2107 error ("gallery: N or X must be a scalar or a vector for randhess matrix."); | |
2108 endif | |
2109 | |
2110 for i = n:-1:2 | |
2111 ## Apply Givens rotation through angle x(i-1). | |
2112 theta = x(i-1); | |
2113 c = cos (theta); | |
2114 s = sin (theta); | |
2115 H([i-1 i], :) = [ c*H(i-1,:)+s*H(i,:) | |
2116 -s*H(i-1,:)+c*H(i,:) ]; | |
2117 endfor | |
2118 endfunction | |
2119 | |
2120 function A = rando (n, k = 1) | |
2121 ## RANDO Random matrix with elements -1, 0 or 1. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2122 ## A = RANDO(N, K) is a random N-by-N matrix with elements from |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2123 ## one of the following discrete distributions (default K = 1): |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2124 ## K = 1: A(i,j) = 0 or 1 with equal probability, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2125 ## K = 2: A(i,j) = -1 or 1 with equal probability, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2126 ## K = 3: A(i,j) = -1, 0 or 1 with equal probability. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2127 ## N may be a 2-vector, in which case the matrix is N(1)-by-N(2). |
16634 | 2128 |
2129 if (nargin < 1 || nargin > 2) | |
2130 error ("gallery: 1 to 2 arguments are required for rando matrix."); | |
2131 elseif (! isnumeric (n) || all (numel (n) != [1 2]) || fix (n) != n) | |
2132 error ("gallery: N must be an integer for rando matrix."); | |
2133 elseif (! isnumeric (k) || ! isscalar (k)) | |
2134 error ("gallery: K must be a numeric scalar for smoke matrix."); | |
2135 endif | |
2136 | |
2137 ## Parameter n specifies dimension: m-by-n. | |
2138 m = n(1); | |
2139 n = n(end); | |
2140 | |
2141 switch (k) | |
2142 case (1), A = floor ( rand(m, n) + 0.5); # {0, 1} | |
2143 case (2), A = 2*floor ( rand(m, n) + 0.5) -1; # {-1, 1} | |
2144 case (3), A = round (3*rand(m, n) - 1.5); # {-1, 0, 1} | |
2145 otherwise | |
16766
7268845c0a1e
avoid backquote in error messages, some uses in doc strings
John W. Eaton <jwe@octave.org>
parents:
16734
diff
changeset
|
2146 error ("gallery: unknown K '%d' for smoke matrix.", k); |
16634 | 2147 endswitch |
2148 | |
2149 endfunction | |
2150 | |
20296
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2151 function A = randsvd (n, kappa = sqrt (1/eps), mode = 3, kl = max (n) -1, |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2152 ku = kl) |
16634 | 2153 ## RANDSVD Random matrix with pre-assigned singular values. |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2154 ## RANDSVD(N, KAPPA, MODE, KL, KU) is a (banded) random matrix of order N |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2155 ## with COND(A) = KAPPA and singular values from the distribution MODE. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2156 ## N may be a 2-vector, in which case the matrix is N(1)-by-N(2). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2157 ## Available types: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2158 ## MODE = 1: one large singular value, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2159 ## MODE = 2: one small singular value, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2160 ## MODE = 3: geometrically distributed singular values, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2161 ## MODE = 4: arithmetically distributed singular values, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2162 ## MODE = 5: random singular values with unif. dist. logarithm. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2163 ## If omitted, MODE defaults to 3, and KAPPA defaults to SQRT(1/EPS). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2164 ## If MODE < 0 then the effect is as for ABS(MODE) except that in the |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2165 ## original matrix of singular values the order of the diagonal entries |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2166 ## is reversed: small to large instead of large to small. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2167 ## KL and KU are the lower and upper bandwidths respectively; if they |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2168 ## are omitted a full matrix is produced. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2169 ## If only KL is present, KU defaults to KL. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2170 ## Special case: if KAPPA < 0 then a random full symmetric positive |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2171 ## definite matrix is produced with COND(A) = -KAPPA and |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2172 ## eigenvalues distributed according to MODE. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2173 ## KL and KU, if present, are ignored. |
16634 | 2174 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2175 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2176 ## N.J. Higham, Accuracy and Stability of Numerical Algorithms, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2177 ## Society for Industrial and Applied Mathematics, Philadelphia, PA, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2178 ## USA, 1996; sec. 26.3. |
16634 | 2179 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2180 ## This routine is similar to the more comprehensive Fortran routine xLATMS |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2181 ## in the following reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2182 ## J.W. Demmel and A. McKenney, A test matrix generation suite, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2183 ## LAPACK Working Note #9, Courant Institute of Mathematical Sciences, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2184 ## New York, 1989. |
16634 | 2185 |
2186 if (nargin < 1 || nargin > 5) | |
2187 error ("gallery: 1 to 5 arguments are required for randsvd matrix."); | |
2188 elseif (! isnumeric (n) || all (numel (n) != [1 2]) || fix (n) != n) | |
2189 error ("gallery: N must be a 1 or 2 element integer vector for randsvd matrix."); | |
2190 elseif (! isnumeric (kappa) || ! isscalar (kappa)) | |
2191 error ("gallery: KAPPA must be a numeric scalar for randsvd matrix."); | |
2192 elseif (abs (kappa) < 1) | |
2193 error ("gallery: KAPPA must larger than or equal to 1 for randsvd matrix."); | |
2194 elseif (! isnumeric (mode) || ! isscalar (mode)) | |
2195 error ("gallery: MODE must be a numeric scalar for randsvd matrix."); | |
2196 elseif (! isnumeric (kl) || ! isscalar (kl)) | |
2197 error ("gallery: KL must be a numeric scalar for randsvd matrix."); | |
2198 elseif (! isnumeric (ku) || ! isscalar (ku)) | |
2199 error ("gallery: KU must be a numeric scalar for randsvd matrix."); | |
2200 endif | |
2201 | |
2202 posdef = 0; | |
2203 if (kappa < 0) | |
2204 posdef = 1; | |
2205 kappa = -kappa; | |
2206 endif | |
2207 | |
2208 ## Parameter n specifies dimension: m-by-n. | |
2209 m = n(1); | |
2210 n = n(end); | |
2211 p = min ([m n]); | |
2212 | |
2213 ## If A will be a vector | |
2214 if (p == 1) | |
2215 A = randn (m, n); | |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
20162
diff
changeset
|
2216 A /= norm (A); |
17306
09543e9c8f40
Use explicit form of end (endif, endfor, etc.) in core m-files.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
2217 return; |
09543e9c8f40
Use explicit form of end (endif, endfor, etc.) in core m-files.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
2218 endif |
16634 | 2219 |
2220 ## Set up vector sigma of singular values. | |
2221 switch (abs (mode)) | |
2222 case (1) | |
2223 sigma = ones (p, 1) ./ kappa; | |
2224 sigma(1) = 1; | |
2225 case (2) | |
2226 sigma = ones (p, 1); | |
2227 sigma(p) = 1 / kappa; | |
2228 case (3) | |
2229 factor = kappa^(-1/(p-1)); | |
2230 sigma = factor.^[0:p-1]; | |
2231 case (4) | |
2232 sigma = ones (p, 1) - (0:p-1)'/(p-1)*(1-1/kappa); | |
2233 case (5) | |
2234 ## In this case cond (A) <= kappa. | |
2235 rand ("uniform"); | |
2236 sigma = exp (-rand (p, 1) * log (kappa)); | |
2237 otherwise | |
16766
7268845c0a1e
avoid backquote in error messages, some uses in doc strings
John W. Eaton <jwe@octave.org>
parents:
16734
diff
changeset
|
2238 error ("gallery: unknown MODE '%d' for randsvd matrix.", mode); |
16634 | 2239 endswitch |
2240 | |
2241 ## Convert to diagonal matrix of singular values. | |
2242 if (mode < 0) | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2243 sigma = sigma(p:-1:1); |
17306
09543e9c8f40
Use explicit form of end (endif, endfor, etc.) in core m-files.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
2244 endif |
16634 | 2245 sigma = diag (sigma); |
2246 | |
2247 if (posdef) | |
2248 ## handle case where KAPPA was negative | |
2249 Q = qmult (p); | |
2250 A = Q' * sigma * Q; | |
2251 A = (A + A') / 2; # Ensure matrix is symmetric. | |
17312
088d014a7fe2
Use semicolon after "return" statement in core m-files.
Rik <rik@octave.org>
parents:
17306
diff
changeset
|
2252 return; |
16634 | 2253 endif |
2254 | |
2255 if (m != n) | |
2256 ## Expand to m-by-n diagonal matrix | |
2257 sigma(m, n) = 0; | |
17306
09543e9c8f40
Use explicit form of end (endif, endfor, etc.) in core m-files.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
2258 endif |
16634 | 2259 |
2260 if (kl == 0 && ku == 0) | |
2261 ## Diagonal matrix requested - nothing more to do. | |
2262 A = sigma; | |
2263 else | |
2264 ## A = U*sigma*V, where U, V are random orthogonal matrices from the | |
2265 ## Haar distribution. | |
2266 A = qmult (sigma'); | |
2267 A = qmult (A'); | |
2268 | |
2269 if (kl < n-1 || ku < n-1) | |
2270 ## Bandwidth reduction | |
2271 A = bandred (A, kl, ku); | |
2272 endif | |
2273 endif | |
2274 endfunction | |
2275 | |
2276 function A = redheff (n) | |
2277 ## REDHEFF A (0,1) matrix of Redheffer associated with the Riemann hypothesis. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2278 ## A = REDHEFF(N) is an N-by-N matrix of 0s and 1s defined by |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2279 ## A(i,j) = 1 if j = 1 or if i divides j, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2280 ## A(i,j) = 0 otherwise. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2281 ## It has N - FLOOR(LOG2(N)) - 1 eigenvalues equal to 1, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2282 ## a real eigenvalue (the spectral radius) approximately SQRT(N), |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2283 ## a negative eigenvalue approximately -SQRT(N), |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2284 ## and the remaining eigenvalues are provably ``small''. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2285 ## Barrett and Jarvis (1992) conjecture that |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2286 ## ``the small eigenvalues all lie inside the unit circle |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2287 ## ABS(Z) = 1'', |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2288 ## and a proof of this conjecture, together with a proof that some |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2289 ## eigenvalue tends to zero as N tends to infinity, would yield |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2290 ## a new proof of the prime number theorem. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2291 ## The Riemann hypothesis is true if and only if |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2292 ## DET(A) = O( N^(1/2+epsilon) ) for every epsilon > 0 |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2293 ## (`!' denotes factorial). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2294 ## See also RIEMANN. |
16634 | 2295 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2296 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2297 ## W.W. Barrett and T.J. Jarvis, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2298 ## Spectral Properties of a Matrix of Redheffer, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2299 ## Linear Algebra and Appl., 162 (1992), pp. 673-683. |
16634 | 2300 |
2301 if (nargin != 1) | |
2302 error ("gallery: 1 argument is required for redheff matrix."); | |
2303 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
2304 error ("gallery: N must be an integer for redheff matrix."); | |
2305 endif | |
2306 | |
2307 i = (1:n)' * ones (1, n); | |
2308 A = ! rem (i', i); | |
2309 A(:,1) = ones (n, 1); | |
2310 endfunction | |
2311 | |
2312 function A = riemann (n) | |
2313 ## RIEMANN A matrix associated with the Riemann hypothesis. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2314 ## A = RIEMANN(N) is an N-by-N matrix for which the |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2315 ## Riemann hypothesis is true if and only if |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2316 ## DET(A) = O( N! N^(-1/2+epsilon) ) for every epsilon > 0 |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2317 ## (`!' denotes factorial). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2318 ## A = B(2:N+1, 2:N+1), where |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2319 ## B(i,j) = i-1 if i divides j and -1 otherwise. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2320 ## Properties include, with M = N+1: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2321 ## Each eigenvalue E(i) satisfies ABS(E(i)) <= M - 1/M. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2322 ## i <= E(i) <= i+1 with at most M-SQRT(M) exceptions. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2323 ## All integers in the interval (M/3, M/2] are eigenvalues. |
16634 | 2324 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2325 ## See also REDHEFF. |
16634 | 2326 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2327 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2328 ## F. Roesler, Riemann's hypothesis as an eigenvalue problem, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2329 ## Linear Algebra and Appl., 81 (1986), pp. 153-198. |
16634 | 2330 |
2331 if (nargin != 1) | |
2332 error ("gallery: 1 argument is required for riemann matrix."); | |
2333 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
2334 error ("gallery: N must be an integer for riemann matrix."); | |
2335 endif | |
2336 | |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
20162
diff
changeset
|
2337 n += 1; |
16634 | 2338 i = (2:n)' * ones (1, n-1); |
2339 j = i'; | |
2340 A = i .* (! rem (j, i)) - ones (n-1); | |
2341 endfunction | |
2342 | |
2343 function A = ris (n) | |
2344 ## NOTE: this function was named dingdong in the original Test Matrix Toolbox | |
2345 ## RIS Dingdong matrix - a symmetric Hankel matrix. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2346 ## A = RIS(N) is the symmetric N-by-N Hankel matrix with |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2347 ## A(i,j) = 0.5/(N-i-j+1.5). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2348 ## The eigenvalues of A cluster around PI/2 and -PI/2. |
16634 | 2349 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2350 ## Invented by F.N. Ris. |
16634 | 2351 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2352 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2353 ## J.C. Nash, Compact Numerical Methods for Computers: Linear |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2354 ## Algebra and Function Minimisation, second edition, Adam Hilger, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2355 ## Bristol, 1990 (Appendix 1). |
16634 | 2356 |
2357 if (nargin != 1) | |
2358 error ("gallery: 1 argument is required for ris matrix."); | |
2359 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
2360 error ("gallery: N must be an integer for ris matrix."); | |
2361 endif | |
2362 | |
2363 p = -2*(1:n) + (n+1.5); | |
2364 A = cauchy (p); | |
2365 endfunction | |
2366 | |
2367 function A = smoke (n, k = 0) | |
2368 ## SMOKE Smoke matrix - complex, with a `smoke ring' pseudospectrum. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2369 ## SMOKE(N) is an N-by-N matrix with 1s on the |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2370 ## superdiagonal, 1 in the (N,1) position, and powers of |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2371 ## roots of unity along the diagonal. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2372 ## SMOKE(N, 1) is the same except for a zero (N,1) element. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2373 ## The eigenvalues of SMOKE(N, 1) are the N'th roots of unity; |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2374 ## those of SMOKE(N) are the N'th roots of unity times 2^(1/N). |
16634 | 2375 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2376 ## Try PS(SMOKE(32)). For SMOKE(N, 1) the pseudospectrum looks |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2377 ## like a sausage folded back on itself. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2378 ## GERSH(SMOKE(N, 1)) is interesting. |
16634 | 2379 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2380 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2381 ## L. Reichel and L.N. Trefethen, Eigenvalues and pseudo-eigenvalues of |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2382 ## Toeplitz matrices, Linear Algebra and Appl., 162-164:153-185, 1992. |
16634 | 2383 |
2384 if (nargin < 1 || nargin > 2) | |
2385 error ("gallery: 1 to 2 arguments are required for smoke matrix."); | |
2386 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
2387 error ("gallery: N must be an integer for smoke matrix."); | |
2388 elseif (! isnumeric (n) || ! isscalar (n)) | |
2389 error ("gallery: K must be a numeric scalar for smoke matrix."); | |
2390 endif | |
2391 | |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
2392 w = exp (2*pi*i/n); |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
2393 A = diag ( [w.^(1:n-1) 1] ) + diag (ones (n-1,1), 1); |
16634 | 2394 |
2395 switch (k) | |
2396 case (0), A(n,1) = 1; | |
2397 case (1), # do nothing | |
2398 otherwise, | |
2399 error ("gallery: K must have a value of 0 or 1 for smoke matrix."); | |
2400 endswitch | |
2401 endfunction | |
2402 | |
2403 function T = toeppd (n, m = n, w = rand (m,1), theta = rand (m,1)) | |
2404 ## NOTE: this function was named pdtoep in the original Test Matrix Toolbox | |
2405 ## TOEPPD Symmetric positive definite Toeplitz matrix. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2406 ## TOEPPD(N, M, W, THETA) is an N-by-N symmetric positive (semi-) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2407 ## definite (SPD) Toeplitz matrix, comprised of the sum of M rank 2 |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2408 ## (or, for certain THETA, rank 1) SPD Toeplitz matrices. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2409 ## Specifically, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2410 ## T = W(1)*T(THETA(1)) + ... + W(M)*T(THETA(M)), |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2411 ## where T(THETA(k)) has (i,j) element COS(2*PI*THETA(k)*(i-j)). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2412 ## Defaults: M = N, W = RAND(M,1), THETA = RAND(M,1). |
16634 | 2413 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2414 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2415 ## G. Cybenko and C.F. Van Loan, Computing the minimum eigenvalue of |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2416 ## a symmetric positive definite Toeplitz matrix, SIAM J. Sci. Stat. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2417 ## Comput., 7 (1986), pp. 123-131. |
16634 | 2418 |
2419 if (nargin < 1 || nargin > 4) | |
2420 error ("gallery: 1 to 4 arguments are required for toeppd matrix."); | |
2421 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
2422 error ("gallery: N must be a numeric integer for toeppd matrix."); | |
2423 elseif (! isnumeric (m) || ! isscalar (m) || fix (m) != m) | |
2424 error ("gallery: M must be a numeric integer for toeppd matrix."); | |
2425 elseif (numel (w) != m || numel (theta) != m) | |
2426 error ("gallery: W and THETA must be vectors of length M for toeppd matrix."); | |
2427 endif | |
2428 | |
2429 T = zeros (n); | |
2430 E = 2*pi * ((1:n)' * ones (1, n) - ones (n, 1) * (1:n)); | |
2431 | |
2432 for i = 1:m | |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
20162
diff
changeset
|
2433 T += w(i) * cos (theta(i)*E); |
16634 | 2434 endfor |
2435 endfunction | |
2436 | |
2437 function P = toeppen (n, a = 1, b = -10, c = 0, d = 10, e = 1) | |
2438 ## NOTE: this function was named pentoep in the original Test Matrix Toolbox | |
2439 ## TOEPPEN Pentadiagonal Toeplitz matrix (sparse). | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2440 ## P = TOEPPEN(N, A, B, C, D, E) is the N-by-N pentadiagonal |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2441 ## Toeplitz matrix with diagonals composed of the numbers |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2442 ## A =: P(3,1), B =: P(2,1), C =: P(1,1), D =: P(1,2), E =: P(1,3). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2443 ## Default: (A,B,C,D,E) = (1,-10,0,10,1) (a matrix of Rutishauser). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2444 ## This matrix has eigenvalues lying approximately on |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2445 ## the line segment 2*cos(2*t) + 20*i*sin(t). |
16634 | 2446 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2447 ## Interesting plots are |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2448 ## PS(FULL(TOEPPEN(32,0,1,0,0,1/4))) - `triangle' |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2449 ## PS(FULL(TOEPPEN(32,0,1/2,0,0,1))) - `propeller' |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2450 ## PS(FULL(TOEPPEN(32,0,1/2,1,1,1))) - `fish' |
16634 | 2451 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2452 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2453 ## R.M. Beam and R.F. Warming, The asymptotic spectra of |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2454 ## banded Toeplitz and quasi-Toeplitz matrices, SIAM J. Sci. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2455 ## Comput. 14 (4), 1993, pp. 971-1006. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2456 ## H. Rutishauser, On test matrices, Programmation en Mathematiques |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2457 ## Numeriques, Editions Centre Nat. Recherche Sci., Paris, 165, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2458 ## 1966, pp. 349-365. |
16634 | 2459 |
2460 if (nargin < 1 || nargin > 6) | |
2461 error ("gallery: 1 to 6 arguments are required for toeppen matrix."); | |
2462 elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) | |
2463 error ("gallery: N must be a numeric integer for toeppen matrix."); | |
17386
6dbc866379e2
Replace cellfun() occurrences with faster code where possible.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
2464 elseif (any (! cellfun ("isnumeric", {a b c d e})) || any (cellfun ("numel", {a b c d e}) != 1)) |
16634 | 2465 error ("gallery: A, B, C, D and E must be numeric scalars for toeppen matrix."); |
2466 endif | |
2467 | |
2468 P = spdiags ([a*ones(n,1) b*ones(n,1) c*ones(n,1) d*ones(n,1) e*ones(n,1)], | |
2469 -2:2, n, n); | |
2470 endfunction | |
2471 | |
2472 function T = tridiag (n, x = -1, y = 2, z = -1) | |
2473 ## TRIDIAG Tridiagonal matrix (sparse). | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2474 ## TRIDIAG(X, Y, Z) is the tridiagonal matrix with subdiagonal X, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2475 ## diagonal Y, and superdiagonal Z. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2476 ## X and Z must be vectors of dimension one less than Y. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2477 ## Alternatively TRIDIAG(N, C, D, E), where C, D, and E are all |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2478 ## scalars, yields the Toeplitz tridiagonal matrix of order N |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2479 ## with subdiagonal elements C, diagonal elements D, and superdiagonal |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2480 ## elements E. This matrix has eigenvalues (Todd 1977) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2481 ## D + 2*SQRT(C*E)*COS(k*PI/(N+1)), k=1:N. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2482 ## TRIDIAG(N) is the same as TRIDIAG(N,-1,2,-1), which is |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2483 ## a symmetric positive definite M-matrix (the negative of the |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2484 ## second difference matrix). |
16634 | 2485 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2486 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2487 ## J. Todd, Basic Numerical Mathematics, Vol. 2: Numerical Algebra, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2488 ## Birkhauser, Basel, and Academic Press, New York, 1977, p. 155. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2489 ## D.E. Rutherford, Some continuant determinants arising in physics and |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2490 ## chemistry---II, Proc. Royal Soc. Edin., 63, A (1952), pp. 232-241. |
16634 | 2491 |
2492 if (nargin != 1 && nargin != 3 && nargin != 4) | |
2493 error ("gallery: 1, 3, or 4 arguments are required for tridiag matrix."); | |
2494 elseif (nargin == 3) | |
2495 z = y; | |
2496 y = x; | |
2497 x = n; | |
2498 endif | |
2499 | |
2500 ## Force column vectors | |
2501 x = x(:); | |
2502 y = y(:); | |
2503 z = z(:); | |
2504 | |
2505 if (isscalar (x) && isscalar (y) && isscalar (z)) | |
2506 x *= ones (n-1, 1); | |
2507 z *= ones (n-1, 1); | |
2508 y *= ones (n, 1); | |
2509 elseif (numel (y) != numel (x) + 1) | |
2510 error ("gallery: X must have one element less than Y for tridiag matrix."); | |
2511 elseif (numel (y) != numel (z) + 1) | |
2512 error ("gallery: Z must have one element less than Y for tridiag matrix."); | |
2513 endif | |
2514 | |
2515 ## T = diag (x, -1) + diag (y) + diag (z, 1); # For non-sparse matrix. | |
2516 n = numel (y); | |
2517 T = spdiags ([[x;0] y [0;z]], -1:1, n, n); | |
2518 endfunction | |
2519 | |
18846
3d33fe79816c
gallery.m: Return correct matrix if 3rd argument is not specified.
Rik <rik@octave.org>
parents:
18812
diff
changeset
|
2520 function t = triw (n, alpha = -1, k = n(end) - 1) |
16634 | 2521 ## TRIW Upper triangular matrix discussed by Wilkinson and others. |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2522 ## TRIW(N, ALPHA, K) is the upper triangular matrix with ones on |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2523 ## the diagonal and ALPHAs on the first K >= 0 superdiagonals. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2524 ## N may be a 2-vector, in which case the matrix is N(1)-by-N(2) and |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2525 ## upper trapezoidal. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2526 ## Defaults: ALPHA = -1, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2527 ## K = N - 1 (full upper triangle). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2528 ## TRIW(N) is a matrix discussed by Kahan, Golub and Wilkinson. |
16634 | 2529 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2530 ## Ostrowski (1954) shows that |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2531 ## COND(TRIW(N,2)) = COT(PI/(4*N))^2, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2532 ## and for large ABS(ALPHA), |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2533 ## COND(TRIW(N,ALPHA)) is approximately ABS(ALPHA)^N*SIN(PI/(4*N-2)). |
16634 | 2534 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2535 ## Adding -2^(2-N) to the (N,1) element makes TRIW(N) singular, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2536 ## as does adding -2^(1-N) to all elements in the first column. |
16634 | 2537 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2538 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2539 ## G.H. Golub and J.H. Wilkinson, Ill-conditioned eigensystems and the |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2540 ## computation of the Jordan canonical form, SIAM Review, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2541 ## 18(4), 1976, pp. 578-619. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2542 ## W. Kahan, Numerical linear algebra, Canadian Math. Bulletin, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2543 ## 9 (1966), pp. 757-801. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2544 ## A.M. Ostrowski, On the spectrum of a one-parametric family of |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2545 ## matrices, J. Reine Angew. Math., 193 (3/4), 1954, pp. 143-160. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2546 ## J.H. Wilkinson, Singular-value decomposition---basic aspects, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2547 ## in D.A.H. Jacobs, ed., Numerical Software---Needs and Availability, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2548 ## Academic Press, London, 1978, pp. 109-135. |
16634 | 2549 |
2550 if (nargin < 1 || nargin > 3) | |
2551 error ("gallery: 1 to 3 arguments are required for triw matrix."); | |
2552 elseif (! isnumeric (n) || all (numel (n) != [1 2])) | |
2553 error ("gallery: N must be a 1 or 2 elements vector for triw matrix."); | |
2554 elseif (! isscalar (alpha)) | |
2555 error ("gallery: ALPHA must be a scalar for triw matrix."); | |
18846
3d33fe79816c
gallery.m: Return correct matrix if 3rd argument is not specified.
Rik <rik@octave.org>
parents:
18812
diff
changeset
|
2556 elseif (! isscalar (k) || ! isnumeric (k) || fix (k) != k || k < 0) |
3d33fe79816c
gallery.m: Return correct matrix if 3rd argument is not specified.
Rik <rik@octave.org>
parents:
18812
diff
changeset
|
2557 error ("gallery: K must be a numeric integer >= 0 for triw matrix."); |
16634 | 2558 endif |
2559 | |
2560 m = n(1); # Parameter n specifies dimension: m-by-n. | |
2561 n = n(end); | |
2562 | |
2563 t = tril (eye (m, n) + alpha * triu (ones (m, n), 1), k); | |
2564 endfunction | |
2565 | |
16978
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2566 function A = uniformdata (varargin) |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2567 |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2568 if (nargin < 2) |
16979
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
2569 error ("gallery: At least 2 arguments required for uniformdata matrix."); |
16978
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2570 endif |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2571 if (isnumeric (varargin{end})) |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2572 jidx = varargin{end}; |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2573 svec = [varargin{:}]; |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2574 varargin(end) = []; |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2575 elseif (ischar (varargin{end})) |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2576 if (nargin < 3) |
16979
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
2577 error (["gallery: CLASS argument requires 3 inputs " ... |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
2578 "for uniformdata matrix."]); |
16978
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2579 endif |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2580 jidx = varargin{end-1}; |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2581 svec = [varargin{1:end-1}]; |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2582 varargin(end-1) = []; |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17386
diff
changeset
|
2583 else |
16979
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
2584 error (["gallery: J must be an integer in the range [0, 2^32-1] " ... |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
2585 "for uniformdata matrix"]); |
16978
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2586 endif |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2587 |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2588 if (! (isnumeric (jidx) && isscalar (jidx) |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2589 && jidx == fix (jidx) |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2590 && jidx >= 0 && jidx <= 0xFFFFFFFF)) |
16979
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
2591 error (["gallery: J must be an integer in the range [0, 2^32-1] " ... |
9aa293e00475
gallery.m: Add 'normaldata' matrix to function.
Rik <rik@octave.org>
parents:
16978
diff
changeset
|
2592 "for uniformdata matrix"]); |
16978
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2593 endif |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2594 |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2595 ## Save and restore random state. Initialization done so that reproducible |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2596 ## data is available from gallery depending on the jidx and size vector. |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17386
diff
changeset
|
2597 randstate = rand ("state"); |
16978
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2598 unwind_protect |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2599 rand ("state", svec); |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2600 A = rand (varargin{:}); |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2601 unwind_protect_cleanup |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2602 rand ("state", randstate); |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2603 end_unwind_protect |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2604 |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2605 endfunction |
00379f9f8773
gallery.m: Add 'uniformdata' matrix to function.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
2606 |
16634 | 2607 function A = wathen (nx, ny, k = 0) |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2608 ## WATHEN returns the Wathen matrix. |
16634 | 2609 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2610 ## Discussion: |
16634 | 2611 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2612 ## The Wathen matrix is a finite element matrix which is sparse. |
16634 | 2613 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2614 ## The entries of the matrix depend in part on a physical quantity |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2615 ## related to density. That density is here assigned random values between |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2616 ## 0 and 100. |
16634 | 2617 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2618 ## A = WATHEN ( NX, NY ) is a sparse random N-by-N finite element matrix |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2619 ## where N = 3*NX*NY + 2*NX + 2*NY + 1. |
16634 | 2620 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2621 ## A is the consistent mass matrix for a regular NX-by-NY |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2622 ## grid of 8-node (serendipity) elements in 2 space dimensions. |
16634 | 2623 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2624 ## Here is an illustration for NX = 3, NX = 2: |
16634 | 2625 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2626 ## 23-24-25-26-27-28-29 |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2627 ## | | | | |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2628 ## 19 20 21 22 |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2629 ## | | | | |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2630 ## 12-13-14-15-16-17-18 |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2631 ## | | | | |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2632 ## 8 9 10 11 |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2633 ## | | | | |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2634 ## 1--2--3--4--5--6--7 |
16634 | 2635 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2636 ## For this example, the total number of nodes is, as expected, |
16634 | 2637 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2638 ## N = 3 * 3 * 2 + 2 * 2 + 2 * 3 + 1 = 29. |
16634 | 2639 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2640 ## A is symmetric positive definite for any (positive) values of |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2641 ## the density, RHO(NX,NY), which is chosen randomly in this routine. |
16634 | 2642 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2643 ## In particular, if D = DIAG(DIAG(A)), then |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2644 ## 0.25 <= EIG(INV(D)*A) <= 4.5 |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2645 ## for any positive integers NX and NY and any densities RHO(NX,NY). |
16634 | 2646 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2647 ## A = WATHEN ( NX, NY, 1 ) returns the diagonally scaled matrix. |
16634 | 2648 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2649 ## Modified: |
16634 | 2650 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2651 ## 17 September 2007 |
16634 | 2652 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2653 ## Author: |
16634 | 2654 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2655 ## Nicholas Higham |
16634 | 2656 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2657 ## Reference: |
16634 | 2658 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2659 ## Nicholas Higham, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2660 ## Algorithm 694: A Collection of Test Matrices in MATLAB, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2661 ## ACM Transactions on Mathematical Software, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2662 ## Volume 17, Number 3, September 1991, pages 289-305. |
16634 | 2663 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2664 ## Andrew Wathen, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2665 ## Realistic eigenvalue bounds for the Galerkin mass matrix, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2666 ## IMA Journal of Numerical Analysis, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2667 ## Volume 7, 1987, pages 449-457. |
16634 | 2668 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2669 ## Parameters: |
16634 | 2670 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2671 ## Input, integer NX, NY, the number of elements in the X and Y directions |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2672 ## of the finite element grid. NX and NY must each be at least 1. |
16634 | 2673 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2674 ## Optional input, integer K, is used to request that the diagonally scaled |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2675 ## version of the matrix be returned. This happens if K is specified with |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2676 ## the value 1. |
16634 | 2677 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2678 ## Output, sparse real A(N,N), the matrix. The dimension N is determined by |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2679 ## NX and NY, as described above. A is stored in the MATLAB sparse matrix |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2680 ## format. |
16634 | 2681 |
2682 if (nargin < 2 || nargin > 3) | |
2683 error ("gallery: 2 or 3 arguments are required for wathen matrix."); | |
2684 elseif (! isnumeric (nx) || ! isscalar (nx) || nx < 1) | |
2685 error ("gallery: NX must be a positive scalar for wathen matrix."); | |
2686 elseif (! isnumeric (ny) || ! isscalar (ny) || ny < 1) | |
2687 error ("gallery: NY must be a positive scalar for wathen matrix."); | |
2688 elseif (! isscalar (k)) | |
2689 error ("gallery: K must be a scalar for wathen matrix."); | |
2690 endif | |
2691 | |
2692 e1 = [ 6 -6 2 -8 | |
2693 -6 32 -6 20 | |
2694 2 -6 6 -6 | |
2695 -8 20 -6 32 ]; | |
2696 | |
2697 e2 = [ 3 -8 2 -6 | |
2698 -8 16 -8 20 | |
2699 2 -8 3 -8 | |
2700 -6 20 -8 16 ]; | |
2701 | |
2702 e = [ e1 e2 | |
2703 e2' e1] / 45; | |
2704 | |
2705 n = 3*nx*ny + 2*nx + 2*ny + 1; | |
2706 | |
2707 A = sparse (n, n); | |
2708 | |
2709 rho = 100 * rand (nx, ny); | |
2710 | |
2711 for j = 1:ny | |
2712 for i = 1:nx | |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17386
diff
changeset
|
2713 ## |
16634 | 2714 ## For the element (I,J), determine the indices of the 8 nodes. |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17386
diff
changeset
|
2715 ## |
16634 | 2716 nn(1) = 3*j*nx + 2*i + 2*j + 1; |
2717 nn(2) = nn(1) - 1; | |
2718 nn(3) = nn(2) - 1; | |
2719 nn(4) = (3*j - 1) * nx + 2*j + i - 1; | |
2720 nn(5) = 3 * (j-1) * nx + 2*i + 2*j - 3; | |
2721 nn(6) = nn(5) + 1; | |
2722 nn(7) = nn(6) + 1; | |
2723 nn(8) = nn(4) + 1; | |
2724 | |
2725 em = e * rho(i,j); | |
2726 | |
2727 for krow = 1:8 | |
2728 for kcol = 1:8 | |
2729 A(nn(krow),nn(kcol)) = A(nn(krow),nn(kcol)) + em(krow,kcol); | |
2730 endfor | |
2731 endfor | |
2732 | |
2733 endfor | |
2734 endfor | |
2735 | |
2736 ## If requested, return A with diagonal scaling. | |
2737 if (k) | |
2738 A = diag (diag (A)) \ A; | |
2739 endif | |
2740 endfunction | |
2741 | |
2742 function [A, b] = wilk (n) | |
2743 ## WILK Various specific matrices devised/discussed by Wilkinson. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2744 ## [A, b] = WILK(N) is the matrix or system of order N. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2745 ## N = 3: upper triangular system Ux=b illustrating inaccurate solution. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2746 ## N = 4: lower triangular system Lx=b, ill-conditioned. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2747 ## N = 5: HILB(6)(1:5,2:6)*1.8144. Symmetric positive definite. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2748 ## N = 21: W21+, tridiagonal. Eigenvalue problem. |
16634 | 2749 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2750 ## References: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2751 ## J.H. Wilkinson, Error analysis of direct methods of matrix inversion, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2752 ## J. Assoc. Comput. Mach., 8 (1961), pp. 281-330. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2753 ## J.H. Wilkinson, Rounding Errors in Algebraic Processes, Notes on Applied |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2754 ## Science No. 32, Her Majesty's Stationery Office, London, 1963. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2755 ## J.H. Wilkinson, The Algebraic Eigenvalue Problem, Oxford University |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2756 ## Press, 1965. |
16634 | 2757 |
2758 if (nargin != 1) | |
2759 error ("gallery: 1 argument is required for wilk matrix."); | |
2760 elseif (! isnumeric (n) || ! isscalar (n)) | |
2761 error ("gallery: N must be a numeric scalar for wilk matrix."); | |
2762 endif | |
2763 | |
2764 if (n == 3) | |
2765 ## Wilkinson (1961) p.323. | |
2766 A = [ 1e-10 0.9 -0.4 | |
2767 0 0.9 -0.4 | |
2768 0 0 1e-10 ]; | |
2769 | |
2770 b = [ 0 | |
2771 0 | |
2772 1]; | |
2773 | |
2774 elseif (n == 4) | |
2775 ## Wilkinson (1963) p.105. | |
2776 A = [0.9143e-4 0 0 0 | |
2777 0.8762 0.7156e-4 0 0 | |
2778 0.7943 0.8143 0.9504e-4 0 | |
2779 0.8017 0.6123 0.7165 0.7123e-4]; | |
2780 | |
2781 b = [0.6524 | |
2782 0.3127 | |
2783 0.4186 | |
2784 0.7853]; | |
2785 | |
2786 elseif (n == 5) | |
2787 ## Wilkinson (1965), p.234. | |
2788 A = hilb (6); | |
2789 A = A(1:5, 2:6) * 1.8144; | |
2790 | |
2791 elseif (n == 21) | |
2792 ## Wilkinson (1965), p.308. | |
2793 E = diag (ones (n-1, 1), 1); | |
2794 m = (n-1)/2; | |
2795 A = diag (abs (-m:m)) + E + E'; | |
2796 | |
2797 else | |
16766
7268845c0a1e
avoid backquote in error messages, some uses in doc strings
John W. Eaton <jwe@octave.org>
parents:
16734
diff
changeset
|
2798 error ("gallery: unknown N '%d' for wilk matrix.", n); |
16634 | 2799 endif |
2800 endfunction | |
2801 | |
2802 ## NOTE: bandred is part of the Test Matrix Toolbox and is used by randsvd() | |
2803 function A = bandred (A, kl, ku) | |
2804 ## BANDRED Band reduction by two-sided unitary transformations. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2805 ## B = BANDRED(A, KL, KU) is a matrix unitarily equivalent to A |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2806 ## with lower bandwidth KL and upper bandwidth KU |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2807 ## (i.e. B(i,j) = 0 if i > j+KL or j > i+KU). |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2808 ## The reduction is performed using Householder transformations. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2809 ## If KU is omitted it defaults to KL. |
16634 | 2810 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2811 ## Called by RANDSVD. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2812 ## This is a `standard' reduction. Cf. reduction to bidiagonal form |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2813 ## prior to computing the SVD. This code is a little wasteful in that |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2814 ## it computes certain elements which are immediately set to zero! |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17386
diff
changeset
|
2815 ## |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2816 ## Reference: |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2817 ## G.H. Golub and C.F. Van Loan, Matrix Computations, second edition, |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2818 ## Johns Hopkins University Press, Baltimore, Maryland, 1989. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2819 ## Section 5.4.3. |
16634 | 2820 |
2821 ## Check for special case where order of left/right transformations matters. | |
2822 ## Easiest approach is to work on the transpose, flipping back at the end. | |
2823 flip = false; | |
2824 if (ku == 0) | |
2825 flip = true; | |
2826 A = A'; | |
2827 [ku, kl] = deal (kl, ku); | |
2828 endif | |
2829 | |
2830 [m, n] = size (A); | |
2831 | |
2832 for j = 1:min (min (m, n), max (m-kl-1, n-ku-1)) | |
2833 if (j+kl+1 <= m) | |
2834 [v, beta] = house (A(j+kl:m,j)); | |
2835 temp = A(j+kl:m,j:n); | |
2836 A(j+kl:m,j:n) = temp - beta*v*(v'*temp); | |
2837 A(j+kl+1:m,j) = zeros (m-j-kl, 1); | |
2838 endif | |
2839 | |
2840 if (j+ku+1 <= n) | |
2841 [v, beta] = house (A(j,j+ku:n)'); | |
2842 temp = A(j:m,j+ku:n); | |
2843 A(j:m,j+ku:n) = temp - beta*(temp*v)*v'; | |
2844 A(j,j+ku+1:n) = zeros (1, n-j-ku); | |
2845 endif | |
2846 endfor | |
2847 | |
2848 if (flip) | |
2849 A = A'; | |
2850 endif | |
2851 endfunction | |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
17312
diff
changeset
|
2852 |
20296
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2853 ## NOTE: qmult is part of the Test Matrix Toolbox and is used by randsvd() |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2854 function B = qmult (A) |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2855 ## QMULT Pre-multiply by random orthogonal matrix. |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2856 ## QMULT(A) is Q*A where Q is a random real orthogonal matrix from |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2857 ## the Haar distribution, of dimension the number of rows in A. |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2858 ## Special case: if A is a scalar then QMULT(A) is the same as |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2859 ## QMULT(EYE(A)). |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2860 ## |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2861 ## Called by RANDSVD. |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2862 ## |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2863 ## Reference: |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2864 ## G.W. Stewart, The efficient generation of random |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2865 ## orthogonal matrices with an application to condition estimators, |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2866 ## SIAM J. Numer. Anal., 17 (1980), 403-409. |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2867 |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2868 [n, m] = size (A); |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2869 |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2870 ## Handle scalar A |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2871 if (isscalar (A)) |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2872 n = A; |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2873 A = eye (n); |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2874 endif |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2875 |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2876 d = zeros (n); |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2877 |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2878 for k = n-1:-1:1 |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2879 ## Generate random Householder transformation. |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2880 x = randn (n-k+1, 1); |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2881 s = norm (x); |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2882 sgn = sign (x(1)) + (x(1) == 0); # Modification for sign(1)=1. |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2883 s = sgn*s; |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2884 d(k) = -sgn; |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2885 x(1) = x(1) + s; |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2886 beta = s*x(1); |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2887 |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2888 ## Apply the transformation to A. |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2889 y = x'*A(k:n,:); |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2890 A(k:n,:) = A(k:n,:) - x*(y/beta); |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2891 endfor |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2892 |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2893 ## Tidy up signs |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2894 for i = 1:n-1 |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2895 A(i,:) = d(i)*A(i,:); |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2896 endfor |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2897 A(n,:) = A(n,:) * sign (randn); |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2898 B = A; |
0b9d23557506
gallery: fix randsvd by adding missing dependency qmult().
Carnë Draug <carandraug@octave.org>
parents:
20295
diff
changeset
|
2899 endfunction |
19226
cdfc8bc9ab62
gallery.m: Add BIST tests for central dispatch function.
Rik <rik@octave.org>
parents:
19040
diff
changeset
|
2900 |
21759
b002b4331a12
maint: Use two newlines after endfunction and start of BIST tests.
Rik <rik@octave.org>
parents:
21751
diff
changeset
|
2901 |
19226
cdfc8bc9ab62
gallery.m: Add BIST tests for central dispatch function.
Rik <rik@octave.org>
parents:
19040
diff
changeset
|
2902 ## BIST testing for just a few functions to verify that the main gallery |
cdfc8bc9ab62
gallery.m: Add BIST tests for central dispatch function.
Rik <rik@octave.org>
parents:
19040
diff
changeset
|
2903 ## dispatch function works. |
20929
45a64a6c7273
fix comment character style in most .m files to be consistent
John W. Eaton <jwe@octave.org>
parents:
20852
diff
changeset
|
2904 %!assert (gallery ("clement", 3), [0 1 0; 2 0 2; 0 1 0]) |
45a64a6c7273
fix comment character style in most .m files to be consistent
John W. Eaton <jwe@octave.org>
parents:
20852
diff
changeset
|
2905 %!assert (gallery ("invhess", 2), [1 -1; 1 2]) |
19226
cdfc8bc9ab62
gallery.m: Add BIST tests for central dispatch function.
Rik <rik@octave.org>
parents:
19040
diff
changeset
|
2906 |
cdfc8bc9ab62
gallery.m: Add BIST tests for central dispatch function.
Rik <rik@octave.org>
parents:
19040
diff
changeset
|
2907 ## Test input validation of main dispatch function only |
cdfc8bc9ab62
gallery.m: Add BIST tests for central dispatch function.
Rik <rik@octave.org>
parents:
19040
diff
changeset
|
2908 %!error gallery () |
cdfc8bc9ab62
gallery.m: Add BIST tests for central dispatch function.
Rik <rik@octave.org>
parents:
19040
diff
changeset
|
2909 %!error <NAME must be a string> gallery (123) |
cdfc8bc9ab62
gallery.m: Add BIST tests for central dispatch function.
Rik <rik@octave.org>
parents:
19040
diff
changeset
|
2910 %!error <matrix binomial not implemented> gallery ("binomial") |
cdfc8bc9ab62
gallery.m: Add BIST tests for central dispatch function.
Rik <rik@octave.org>
parents:
19040
diff
changeset
|
2911 %!error <unknown matrix with NAME foobar> gallery ("foobar") |
cdfc8bc9ab62
gallery.m: Add BIST tests for central dispatch function.
Rik <rik@octave.org>
parents:
19040
diff
changeset
|
2912 |
21759
b002b4331a12
maint: Use two newlines after endfunction and start of BIST tests.
Rik <rik@octave.org>
parents:
21751
diff
changeset
|
2913 ## BIST testing for individual gallery functions |
19944
941e782d0429
gallery: performance increase for minij matrix.
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
2914 %!assert (gallery ("minij", 4), [1 1 1 1; 1 2 2 2; 1 2 3 3; 1 2 3 4]) |
941e782d0429
gallery: performance increase for minij matrix.
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
2915 %!assert (gallery ("minij", 1), 1) |
941e782d0429
gallery: performance increase for minij matrix.
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
2916 %!assert (gallery ("minij", 0), []) |
941e782d0429
gallery: performance increase for minij matrix.
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
2917 %!assert (gallery ("minij", -1), []) |
20299
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2918 |
23381
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2919 %!test |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2920 %! exp = 1 ./ [ |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2921 %! 2 3 4 5 6 |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2922 %! 3 4 5 6 7 |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2923 %! 4 5 6 7 8 |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2924 %! 5 6 7 8 9 |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2925 %! 6 7 8 9 10]; |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2926 %! assert (gallery ("cauchy", 5), exp) |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2927 %! assert (gallery ("cauchy", 1:5), exp) |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2928 %! assert (gallery ("cauchy", 1:5, 1:5), exp) |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2929 %! |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2930 %! exp = 1 ./ [ |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2931 %! 1 2 3 4 5 |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2932 %! 2 3 4 5 6 |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2933 %! 3 4 5 6 7 |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2934 %! 4 5 6 7 8 |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2935 %! 5 6 7 8 9]; |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2936 %! assert (gallery ("cauchy", 0:4, 1:5), exp) |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2937 %! assert (gallery ("cauchy", 1:5, 0:4), exp) |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2938 %! assert (gallery ("cauchy", 1:5, 4:-1:0), fliplr (exp)) |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2939 %! |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2940 %! exp = 1 ./ [ |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2941 %! -1 0 1 2 3 |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2942 %! 0 1 2 3 4 |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2943 %! 1 2 3 4 5 |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2944 %! 2 3 4 5 6 |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2945 %! 3 4 5 6 7]; |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2946 %! assert (gallery ("cauchy", 1:5, -2:2), exp) |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2947 %! |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2948 %! exp = 1 ./ [ |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2949 %! 8 18 -4 2 |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2950 %! 13 23 1 7 |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2951 %! 9 19 -3 3 |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2952 %! 15 25 3 9]; |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2953 %! assert (gallery ("cauchy", [-2 3 -1 5], [10 20 -2 4]), exp) |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2954 %! assert (gallery ("cauchy", [-2 3 -1 5], [10 20 -2 4]'), exp) |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2955 %! assert (gallery ("cauchy", [-2 3 -1 5]', [10 20 -2 4]), exp) |
20299
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2956 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2957 %!assert (size (gallery ("chebspec", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2958 %!assert (size (gallery ("chebspec", 5, 1)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2959 %!assert (size (gallery ("chebspec", 5, 0)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2960 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2961 %!assert (size (gallery ("chebvand", 7)), [7 7]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2962 %!assert (size (gallery ("chebvand", 1:7)), [7 7]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2963 %!assert (size (gallery ("chebvand", 5, 7)), [5 7]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2964 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2965 %!assert (size (gallery ("chow", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2966 %!assert (size (gallery ("chow", 5, 6)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2967 %!assert (size (gallery ("chow", 5, 6, 7)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2968 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2969 %!assert (gallery ("circul", 3), [1 2 3; 3 1 2; 2 3 1]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2970 %!assert (gallery ("circul", [1 3 6]), [1 3 6; 6 1 3; 3 6 1]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2971 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2972 %!assert (size (gallery ("clement", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2973 %!assert (size (gallery ("clement", 5, 1)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2974 %!assert (size (gallery ("clement", 5, 0)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2975 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2976 %!assert (size (gallery ("compar", ones (5))), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2977 %!assert (size (gallery ("compar", ones (5), 0)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2978 %!assert (size (gallery ("compar", ones (5), 1)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2979 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2980 %!assert (size (gallery ("condex", 4)), [4 4]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2981 %!assert (size (gallery ("condex", 4, 1)), [4 4]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2982 %!assert (size (gallery ("condex", 4, 1, 50)), [4 4]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2983 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2984 %!assert (size (gallery ("cycol", [4 5])), [4 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2985 %!assert (size (gallery ("cycol", [4 5], 1)), [4 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2986 %!assert (size (gallery ("cycol", 4)), [4 4]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2987 %!assert (size (gallery ("cycol", 4, 1)), [4 4]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2988 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2989 %!assert (size (gallery ("dorr", 4)), [4 4]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2990 %!assert (cellfun (@rows, nthargout (1:3, @gallery, "dorr", 4)), [3 4 3]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2991 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2992 %!assert (size (gallery ("dramadah", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2993 %!assert (size (gallery ("dramadah", 5, 2)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
2994 |
23381
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2995 %!test |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2996 %! exp = [ |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2997 %! 0 1 2 3 4 |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2998 %! 1 0 1 2 3 |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
2999 %! 2 1 0 1 2 |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
3000 %! 3 2 1 0 1 |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
3001 %! 4 3 2 1 0]; |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
3002 %! assert (gallery ("fiedler", 5), exp) |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
3003 %! assert (gallery ("fiedler", 1:5), exp) |
e15ffa2b2262
gallery: use broadcasting to generate cauchy and fiedler matrices
Carnë Draug <carandraug@octave.org>
parents:
23084
diff
changeset
|
3004 %! assert (gallery ("fiedler", -2:2), exp) |
23384
d20b385d8c99
gallery.m: fix failing test due to typo on test unit.
Carnë Draug <carandraug@octave.org>
parents:
23381
diff
changeset
|
3005 %! assert (gallery ("fiedler", 2:5), exp(1:4,1:4)) |
20299
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3006 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3007 %!assert (size (gallery ("forsythe", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3008 %!assert (size (gallery ("forsythe", 5, 1, 0.5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3009 %!assert (size (gallery ("forsythe", 5, 4, 7)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3010 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3011 %!assert (size (gallery ("frank", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3012 %!assert (size (gallery ("frank", 5, 1)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3013 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3014 %!assert (size (gallery ("gcdmat", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3015 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3016 %!assert (size (gallery ("gearmat", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3017 %!assert (size (gallery ("gearmat", 5, 4)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3018 %!assert (size (gallery ("gearmat", 5, 4, 3)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3019 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3020 %!assert (size (gallery ("grcar", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3021 %!assert (size (gallery ("grcar", 5, 2)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3022 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3023 %!error <N must be even> gallery ("hanowa", 5) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3024 %!assert (size (gallery ("hanowa", 6, 5)), [6 6]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3025 %!assert (size (gallery ("hanowa", 6, 5)), [6 6]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3026 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3027 %!assert (size (gallery ("house", [1:5]')), [5 1]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3028 %!assert (cellfun (@rows, nthargout (1:2, @gallery, "house", [1:5]')), [5 1]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3029 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3030 %!assert (size (gallery ("integerdata", 5, [3 2], 5)), [3 2]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3031 %!assert (size (gallery ("integerdata", 5, [3 2 6], 5)), [3 2 6]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3032 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3033 %!assert (size (gallery ("invhess", 1:4, 1:3)), [4 4]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3034 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3035 %!assert (size (gallery ("invol", 4)), [4 4]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3036 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3037 %!assert (size (gallery ("ipjfact", 4)), [4 4]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3038 %!assert (size (gallery ("ipjfact", 4, 0)), [4 4]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3039 %!assert (size (gallery ("ipjfact", 4, 1)), [4 4]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3040 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3041 %!assert (size (gallery ("jordbloc", 4)), [4 4]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3042 %!assert (size (gallery ("jordbloc", 4, 1)), [4 4]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3043 %!assert (size (gallery ("jordbloc", 4, 3)), [4 4]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3044 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3045 %!assert (size (gallery ("kahan", 4)), [4 4]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3046 %!assert (size (gallery ("kahan", [4 5])), [4 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3047 %!assert (size (gallery ("kahan", [4 5], 1)), [4 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3048 %!assert (size (gallery ("kahan", [4 5], 1, 30)), [4 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3049 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3050 %!assert (size (gallery ("kms", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3051 %!assert (size (gallery ("kms", 5, 0.2)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3052 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3053 %!assert (size (gallery ("krylov", 4)), [4 4]) |
22021
e67ff2b11147
Check that second argument to size () is a scalar (bug #48368).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21759
diff
changeset
|
3054 %!assert (size (gallery ("krylov", ones (4))), [4 4]) |
e67ff2b11147
Check that second argument to size () is a scalar (bug #48368).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21759
diff
changeset
|
3055 %!assert (size (gallery ("krylov", ones (4), [.2 .3 .4 .5], 3)), [4 3]) |
20299
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3056 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3057 %!assert (size (gallery ("lauchli", 5)), [6 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3058 %!assert (size (gallery ("lauchli", 5, 3)), [6 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3059 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3060 %!assert (size (gallery ("lehmer", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3061 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3062 %!assert (size (gallery ("lesp", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3063 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3064 %!assert (size (gallery ("lotkin", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3065 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3066 %!assert (size (gallery ("minij", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3067 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3068 %!assert (size (gallery ("moler", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3069 %!assert (size (gallery ("moler", 5, 0.2)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3070 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3071 %!assert (size (gallery ("neumann", 4)), [4 4]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3072 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3073 %!assert (size (gallery ("normaldata", [5 4 6], 3)), [5 4 6]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3074 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3075 %!assert (size (gallery ("orthog", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3076 %!assert (size (gallery ("orthog", 5, 2)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3077 %!assert (size (gallery ("orthog", 5, -2)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3078 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3079 %!assert (size (gallery ("parter", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3080 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3081 %!assert (size (gallery ("pei", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3082 %!assert (size (gallery ("pei", 5, 4)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3083 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3084 %!assert (size (gallery ("poisson", 1)), [1 1]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3085 %!assert (size (gallery ("poisson", 4)), [16 16]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3086 %!assert (size (gallery ("poisson", 5)), [25 25]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3087 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3088 %!assert (size (gallery ("prolate", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3089 %!assert (size (gallery ("prolate", 5, 0.5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3090 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3091 %!assert (size (gallery ("randhess", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3092 %!assert (size (gallery ("randhess", 2:5)), [4 4]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3093 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3094 %!assert (size (gallery ("rando", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3095 %!assert (size (gallery ("rando", 5, 2)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3096 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3097 %!assert (size (gallery ("randsvd", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3098 %!assert (size (gallery ("randsvd", [5 3])), [5 3]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3099 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3100 %!assert (size (gallery ("redheff", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3101 %!assert (size (gallery ("riemann", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3102 %!assert (size (gallery ("ris", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3103 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3104 %!assert (size (gallery ("smoke", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3105 %!assert (size (gallery ("smoke", 5, 1)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3106 %!assert (gallery ("smoke", 5, 1)(5, 1), 0) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3107 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3108 %!assert (size (gallery ("toeppd", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3109 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3110 %!assert (size (gallery ("toeppen", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3111 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3112 %!assert (size (gallery ("tridiag", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3113 %!assert (size (gallery ("tridiag", 1:4, 1:5, 1:4)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3114 %!assert (gallery ("tridiag", 5), gallery ("tridiag", 5, -1, 2, -1)) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3115 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3116 %!assert (size (gallery ("triw", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3117 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3118 %!assert (size (gallery ("uniformdata", [5 3 4], 3)), [5 3 4]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3119 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3120 %!assert (size (gallery ("wathen", 2, 3)), [29 29]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3121 |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3122 %!assert (cellfun (@rows, nthargout (1:2, @gallery, "wilk", 3)), [3 3]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3123 %!assert (cellfun (@rows, nthargout (1:2, @gallery, "wilk", 4)), [4 4]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3124 %!assert (size (gallery ("wilk", 5)), [5 5]) |
c5a8eff5a05d
gallery: add very basic tests (check output size) for all matrix types.
Carnë Draug <carandraug@octave.org>
parents:
20298
diff
changeset
|
3125 %!assert (size (gallery ("wilk", 21)), [21 21]) |