annotate libinterp/octave-value/ov-perm.cc @ 31771:21f9b34eb893

maint: Eliminate "(void)" in C++ function prototypes/declarations. * mk-opts.pl, external.txi, embedded.cc, make_int.cc, standalone.cc, standalonebuiltin.cc, 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, ListBoxControl.cc, ListBoxControl.h, Logger.cc, Logger.h, Menu.cc, Menu.h, MenuContainer.h, Object.cc, Object.h, ObjectProxy.cc, ObjectProxy.h, Panel.cc, Panel.h, PopupMenuControl.cc, PopupMenuControl.h, PushButtonControl.cc, PushButtonControl.h, PushTool.cc, PushTool.h, RadioButtonControl.cc, RadioButtonControl.h, SliderControl.cc, SliderControl.h, Table.cc, Table.h, TextControl.cc, TextControl.h, TextEdit.h, ToggleButtonControl.cc, ToggleButtonControl.h, ToggleTool.cc, ToggleTool.h, ToolBar.cc, ToolBar.h, ToolBarButton.cc, ToolBarButton.h, gl-select.cc, gl-select.h, qopengl-functions.h, qt-graphics-toolkit.h, qdialog.cpp, qfontdialog.cpp, qprintdialog_win.cpp, liboctgui-build-info.h, liboctgui-build-info.in.cc, color-picker.cc, color-picker.h, command-widget.cc, command-widget.h, community-news.cc, community-news.h, dialog.cc, dialog.h, documentation-bookmarks.cc, documentation-bookmarks.h, documentation-dock-widget.cc, documentation-dock-widget.h, documentation.cc, documentation.h, dw-main-window.cc, dw-main-window.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, gui-preferences.cc, gui-preferences.h, gui-settings.cc, gui-settings.h, history-dock-widget.cc, history-dock-widget.h, interpreter-qobject.cc, interpreter-qobject.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, news-reader.cc, news-reader.h, octave-dock-widget.cc, octave-dock-widget.h, octave-qobject.cc, octave-qobject.h, qt-application.cc, qt-application.h, qt-interpreter-events.cc, qt-interpreter-events.h, release-notes.cc, release-notes.h, set-path-dialog.cc, set-path-dialog.h, set-path-model.cc, set-path-model.h, settings-dialog.cc, settings-dialog.h, shortcuts-tree-widget.cc, shortcuts-tree-widget.h, tab-bar.cc, tab-bar.h, terminal-dock-widget.cc, terminal-dock-widget.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, Cell.cc, Cell.h, __contourc__.cc, __magick_read__.cc, auto-shlib.cc, auto-shlib.h, base-text-renderer.h, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h, debug.cc, defaults.cc, defaults.h, defun.cc, display.cc, display.h, dynamic-ld.cc, dynamic-ld.h, environment.cc, environment.h, error.cc, error.h, errwarn.cc, errwarn.h, event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc, fcn-info.h, ft-text-renderer.cc, ft-text-renderer.h, genprops.awk, gh-manager.cc, gh-manager.h, gl-render.cc, gl-render.h, gl2ps-print.cc, graphics-toolkit.h, graphics.cc, graphics.in.h, gtk-manager.cc, gtk-manager.h, help.cc, help.h, hook-fcn.h, input.cc, input.h, interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h, jsondecode.cc, latex-text-renderer.cc, latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h, ls-hdf5.cc, ls-hdf5.h, mxarray.h, oct-errno.h, oct-errno.in.cc, oct-fstrm.cc, oct-fstrm.h, oct-handle.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h, oct-map.cc, oct-map.h, oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, pager.cc, pager.h, pr-flt-fmt.cc, pr-flt-fmt.h, pr-output.cc, pr-output.h, procstream.cc, procstream.h, settings.cc, settings.h, sighandlers.cc, sighandlers.h, stack-frame.cc, stack-frame.h, svd.cc, syminfo.cc, syminfo.h, symrec.cc, symrec.h, symscope.cc, symscope.h, symtab.cc, symtab.h, sysdep.cc, sysdep.h, text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, toplev.cc, url-handle-manager.cc, url-handle-manager.h, variables.cc, xpow.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc, audiodevinfo.cc, gzip.cc, liboctinterp-build-info.h, liboctinterp-build-info.in.cc, mk-build-env-features.sh, mk-builtins.pl, cdef-class.cc, cdef-class.h, cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h, cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h, cdef-utils.cc, cdef-utils.h, 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.h, ov-complex.cc, ov-complex.h, 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.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-intx.h, ov-java.cc, ov-java.h, ov-lazy-idx.cc, ov-lazy-idx.h, ov-legacy-range.cc, ov-legacy-range.h, ov-magic-int.cc, ov-magic-int.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-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, ovl.cc, ovl.h, octave.cc, octave.h, anon-fcn-validator.h, bp-table.cc, bp-table.h, comment-list.cc, comment-list.h, filepos.h, lex.h, lex.ll, oct-lvalue.cc, oct-lvalue.h, oct-parse.yy, parse.h, profiler.cc, profiler.h, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h, pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.h, pt-cbinop.h, pt-cell.h, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.h, 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-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc, pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-walk.h, pt.cc, pt.h, token.cc, token.h, usage.h, Array-base.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.cc, MArray.h, MDiagArray2.h, MSparse.h, MatrixType.cc, MatrixType.h, PermMatrix.cc, PermMatrix.h, Range.cc, Range.h, Sparse-b.cc, Sparse.cc, Sparse.h, boolMatrix.cc, boolMatrix.h, boolNDArray.cc, boolNDArray.h, boolSparse.cc, boolSparse.h, chMatrix.h, 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, intNDArray.cc, intNDArray.h, liboctave-build-info.h, liboctave-build-info.in.cc, CollocWt.cc, CollocWt.h, DAE.h, DAEFunc.h, DAERT.h, DAERTFunc.h, DASPK.cc, DASPK.h, DASRT.cc, DASRT.h, DASSL.cc, DASSL.h, DET.h, EIG.h, LSODE.cc, LSODE.h, ODE.h, ODEFunc.h, ODES.h, ODESFunc.h, Quad.h, aepbalance.cc, aepbalance.h, base-dae.h, base-de.h, chol.cc, chol.h, eigs-base.cc, fEIG.h, gepbalance.h, gsvd.cc, gsvd.h, hess.h, lu.cc, lu.h, oct-fftw.cc, oct-fftw.h, oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc, qrp.h, randmtzig.cc, randmtzig.h, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc, child-list.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, lo-sysinfo.cc, lo-sysinfo.h, mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h, oct-password.cc, oct-password.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, caseless-str.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, data-conv.cc, file-info.h, glob-match.cc, glob-match.h, kpse.cc, kpse.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc, lo-hash.h, lo-ieee.cc, lo-ieee.h, lo-regexp.cc, lo-regexp.h, oct-inttypes.cc, oct-inttypes.h, oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h, oct-sort.cc, oct-sort.h, oct-sparse.cc, octave-preserve-stream-state.h, pathsearch.cc, pathsearch.h, quit.cc, singleton-cleanup.cc, singleton-cleanup.h, str-vec.cc, str-vec.h, unwind-prot.cc, unwind-prot.h, url-transfer.cc, url-transfer.h, version.cc, version.in.h, cxx-signal-helpers.cc, acinclude.m4, 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, octave-svgconvert.cc, shared-fcns.h: maint: Eliminate "(void)" in C++ function prototypes/declarations.
author Rik <rik@octave.org>
date Tue, 24 Jan 2023 17:19:44 -0800
parents 597f3ee61a48
children 53c10d69a9be
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
31706
597f3ee61a48 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 31607
diff changeset
3 // Copyright (C) 2008-2023 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21647
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
27 # include "config.h"
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
28 #endif
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
29
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
30 #include "byte-swap.h"
15149
62a35ae7d6a2 use forward decls for mxArray in ov.h and ov-base.h
John W. Eaton <jwe@octave.org>
parents: 15057
diff changeset
31 #include "dim-vector.h"
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
32
15149
62a35ae7d6a2 use forward decls for mxArray in ov.h and ov-base.h
John W. Eaton <jwe@octave.org>
parents: 15057
diff changeset
33 #include "mxarray.h"
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
34 #include "ov-perm.h"
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
35 #include "ov-re-mat.h"
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
36 #include "ov-scalar.h"
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
37 #include "error.h"
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 20979
diff changeset
38 #include "errwarn.h"
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
39 #include "ops.h"
8891
d077c590eb88 indicate diag & perm matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 8459
diff changeset
40 #include "pr-output.h"
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
41
20447
c6224b4e7774 maint: Rename instances of LS_ASCII to LS_TEXT for clarity.
Rik <rik@octave.org>
parents: 20232
diff changeset
42 #include "ls-oct-text.h"
8376
c43481a19bfe implement ASCII saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
43
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
44 octave_value
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
45 octave_perm_matrix::subsref (const std::string& type,
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
46 const std::list<octave_value_list>& idx)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
47 {
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
48 octave_value retval;
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
49
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
50 switch (type[0])
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
51 {
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
52 case '(':
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
53 retval = do_index_op (idx.front ());
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
54 break;
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
55
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
56 case '{':
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
57 case '.':
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
58 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 9812
diff changeset
59 std::string nm = type_name ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 9812
diff changeset
60 error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
61 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
62 break;
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
63
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
64 default:
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
65 panic_impossible ();
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
66 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
67
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
68 return retval.next_subsref (type, idx);
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
69 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
70
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
71 octave_value
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
72 octave_perm_matrix::do_index_op (const octave_value_list& idx,
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
73 bool resize_ok)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
74 {
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
75 octave_value retval;
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
76 octave_idx_type nidx = idx.length ();
29569
29a1f8fd8ee6 move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
77 octave::idx_vector idx0, idx1;
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
78 if (nidx == 2)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
79 {
20542
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20447
diff changeset
80 int k = 0; // index we're processing when index_vector throws
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20447
diff changeset
81 try
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20447
diff changeset
82 {
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20447
diff changeset
83 idx0 = idx(0).index_vector ();
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20447
diff changeset
84 k = 1;
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20447
diff changeset
85 idx1 = idx(1).index_vector ();
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20447
diff changeset
86 }
29163
8f67ad8b3103 maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents: 28631
diff changeset
87 catch (octave::index_exception& ie)
20542
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20447
diff changeset
88 {
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20447
diff changeset
89 // Rethrow to allow more info to be reported later.
29163
8f67ad8b3103 maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents: 28631
diff changeset
90 ie.set_pos_if_unset (2, k+1);
20542
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20447
diff changeset
91 throw;
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20447
diff changeset
92 }
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
93 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
94
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
95 // This hack is to allow constructing permutation matrices using
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
96 // eye(n)(p,:), eye(n)(:,q) && eye(n)(p,q) where p & q are permutation
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
97 // vectors.
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
98 // Note that, for better consistency, eye(n)(:,:) still converts to a full
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
99 // matrix.
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
100 if (nidx == 2)
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
101 {
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
102 bool left = idx0.is_permutation (m_matrix.rows ());
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
103 bool right = idx1.is_permutation (m_matrix.cols ());
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
104
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
105 if (left && right)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
106 {
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
107 if (idx0.is_colon ()) left = false;
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
108 if (idx1.is_colon ()) right = false;
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
109 if (left || right)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
110 {
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
111 PermMatrix p = m_matrix;
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
112 if (left)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
113 p = PermMatrix (idx0, false) * p;
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
114 if (right)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
115 p = p * PermMatrix (idx1, true);
8960
93f18f166aba remove float perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
116 retval = p;
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
117 }
8459
d17874a6f161 improve indexing of diagonal & permutation matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8437
diff changeset
118 else
d17874a6f161 improve indexing of diagonal & permutation matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8437
diff changeset
119 {
d17874a6f161 improve indexing of diagonal & permutation matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8437
diff changeset
120 retval = this;
30139
c789e728d57a Backed out changeset 938794bc82b7
John W. Eaton <jwe@octave.org>
parents: 30133
diff changeset
121 this->count++;
8459
d17874a6f161 improve indexing of diagonal & permutation matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8437
diff changeset
122 }
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
123 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
124 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
125
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
126 if (! retval.is_defined ())
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
127 {
19864
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
128 if (nidx == 2 && ! resize_ok && idx0.is_scalar () && idx1.is_scalar ())
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
129 retval = m_matrix.checkelem (idx0(0), idx1(0));
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
130 else
28631
70cdf8de553d move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents: 28126
diff changeset
131 retval = to_dense ().index_op (idx, resize_ok);
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
132 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
133
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
134 return retval;
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
135 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
136
21990
efce657ceb86 Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21885
diff changeset
137 // Return true if this matrix has all true elements (non-zero, not NaN/NA).
efce657ceb86 Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21885
diff changeset
138 // A permutation cannot have NaN/NA.
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
139 bool
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
140 octave_perm_matrix::is_true () const
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
141 {
21990
efce657ceb86 Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21885
diff changeset
142 if (dims ().numel () > 1)
efce657ceb86 Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21885
diff changeset
143 {
efce657ceb86 Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21885
diff changeset
144 warn_array_as_logical (dims ());
efce657ceb86 Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21885
diff changeset
145 return false; // > 1x1 permutation always has zeros, and no NaN.
efce657ceb86 Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21885
diff changeset
146 }
efce657ceb86 Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21885
diff changeset
147 else
efce657ceb86 Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21885
diff changeset
148 return dims ().numel (); // 1x1 is [1] == true, 0x0 == false.
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
149 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
150
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
151 double
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
152 octave_perm_matrix::double_value (bool) const
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
153 {
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23457
diff changeset
154 if (isempty ())
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
155 err_invalid_conversion (type_name (), "real scalar");
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
156
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
157 warn_implicit_conversion ("Octave:array-to-scalar",
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
158 type_name (), "real scalar");
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
159
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
160 return m_matrix(0, 0);
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
161 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
162
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
163 float
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
164 octave_perm_matrix::float_value (bool) const
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
165 {
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23457
diff changeset
166 if (isempty ())
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
167 err_invalid_conversion (type_name (), "real scalar");
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
168
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
169 warn_implicit_conversion ("Octave:array-to-scalar",
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
170 type_name (), "real scalar");
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
171
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
172 return m_matrix(0, 0);
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
173 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
174
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
175 Complex
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
176 octave_perm_matrix::complex_value (bool) const
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
177 {
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
178 if (rows () == 0 || columns () == 0)
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
179 err_invalid_conversion (type_name (), "complex scalar");
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
180
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
181 warn_implicit_conversion ("Octave:array-to-scalar",
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
182 type_name (), "complex scalar");
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
183
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
184 return Complex (m_matrix(0, 0), 0);
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
185 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
186
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
187 FloatComplex
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
188 octave_perm_matrix::float_complex_value (bool) const
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
189 {
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
190 float tmp = lo_ieee_float_nan_value ();
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
191
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
192 FloatComplex retval (tmp, tmp);
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
193
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
194 if (rows () == 0 || columns () == 0)
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
195 err_invalid_conversion (type_name (), "complex scalar");
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
196
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
197 warn_implicit_conversion ("Octave:array-to-scalar",
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
198 type_name (), "complex scalar");
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
199
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
200 retval = m_matrix(0, 0);
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
201
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
202 return retval;
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
203 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
204
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
205 #define FORWARD_MATRIX_VALUE(TYPE, PREFIX) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
206 TYPE \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
207 octave_perm_matrix::PREFIX ## _value (bool frc_str_conv) const \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
208 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
209 return to_dense ().PREFIX ## _value (frc_str_conv); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
210 }
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
211
8910
6e9f26506804 optimize diag -> sparse and perm -> sparse conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 8891
diff changeset
212 SparseMatrix
6e9f26506804 optimize diag -> sparse and perm -> sparse conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 8891
diff changeset
213 octave_perm_matrix::sparse_matrix_value (bool) const
6e9f26506804 optimize diag -> sparse and perm -> sparse conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 8891
diff changeset
214 {
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
215 return SparseMatrix (m_matrix);
8910
6e9f26506804 optimize diag -> sparse and perm -> sparse conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 8891
diff changeset
216 }
6e9f26506804 optimize diag -> sparse and perm -> sparse conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 8891
diff changeset
217
13030
b646413c3d0e Make operators do smarter sparse conversions on permutation matrices.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 11586
diff changeset
218 SparseBoolMatrix
b646413c3d0e Make operators do smarter sparse conversions on permutation matrices.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 11586
diff changeset
219 octave_perm_matrix::sparse_bool_matrix_value (bool) const
b646413c3d0e Make operators do smarter sparse conversions on permutation matrices.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 11586
diff changeset
220 {
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
221 return SparseBoolMatrix (m_matrix);
13030
b646413c3d0e Make operators do smarter sparse conversions on permutation matrices.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 11586
diff changeset
222 }
b646413c3d0e Make operators do smarter sparse conversions on permutation matrices.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 11586
diff changeset
223
8910
6e9f26506804 optimize diag -> sparse and perm -> sparse conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 8891
diff changeset
224 SparseComplexMatrix
6e9f26506804 optimize diag -> sparse and perm -> sparse conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 8891
diff changeset
225 octave_perm_matrix::sparse_complex_matrix_value (bool) const
6e9f26506804 optimize diag -> sparse and perm -> sparse conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 8891
diff changeset
226 {
6e9f26506804 optimize diag -> sparse and perm -> sparse conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 8891
diff changeset
227 return SparseComplexMatrix (sparse_matrix_value ());
6e9f26506804 optimize diag -> sparse and perm -> sparse conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 8891
diff changeset
228 }
6e9f26506804 optimize diag -> sparse and perm -> sparse conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 8891
diff changeset
229
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
230 FORWARD_MATRIX_VALUE (Matrix, matrix)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
231 FORWARD_MATRIX_VALUE (FloatMatrix, float_matrix)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
232 FORWARD_MATRIX_VALUE (ComplexMatrix, complex_matrix)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
233 FORWARD_MATRIX_VALUE (FloatComplexMatrix, float_complex_matrix)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
234
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
235 FORWARD_MATRIX_VALUE (NDArray, array)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
236 FORWARD_MATRIX_VALUE (FloatNDArray, float_array)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
237 FORWARD_MATRIX_VALUE (ComplexNDArray, complex_array)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
238 FORWARD_MATRIX_VALUE (FloatComplexNDArray, float_complex_array)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
239
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
240 FORWARD_MATRIX_VALUE (boolNDArray, bool_array)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
241 FORWARD_MATRIX_VALUE (charNDArray, char_array)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
242
29569
29a1f8fd8ee6 move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
243 octave::idx_vector
18130
e473c4853afc enable non-integer ranges as indices by default and deprecate preference
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
244 octave_perm_matrix::index_vector (bool require_integers) const
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
245 {
18130
e473c4853afc enable non-integer ranges as indices by default and deprecate preference
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
246 return to_dense ().index_vector (require_integers);
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
247 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
248
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
249 octave_value
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
250 octave_perm_matrix::convert_to_str_internal (bool pad, bool force,
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 30564
diff changeset
251 char type) const
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
252 {
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
253 return to_dense ().convert_to_str_internal (pad, force, type);
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
254 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
255
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
256 octave_value
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
257 octave_perm_matrix::as_double () const
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
258 {
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
259 return m_matrix;
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
260 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
261
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
262 octave_value
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
263 octave_perm_matrix::as_single () const
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
264 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
265 return float_array_value ();
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
266 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
267
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
268 octave_value
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
269 octave_perm_matrix::as_int8 () const
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
270 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
271 return int8_array_value ();
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
272 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
273
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
274 octave_value
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
275 octave_perm_matrix::as_int16 () const
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
276 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
277 return int16_array_value ();
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
278 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
279
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
280 octave_value
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
281 octave_perm_matrix::as_int32 () const
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
282 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
283 return int32_array_value ();
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
284 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
285
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
286 octave_value
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
287 octave_perm_matrix::as_int64 () const
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
288 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
289 return int64_array_value ();
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
290 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
291
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
292 octave_value
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
293 octave_perm_matrix::as_uint8 () const
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
294 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
295 return uint8_array_value ();
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
296 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
297
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
298 octave_value
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
299 octave_perm_matrix::as_uint16 () const
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
300 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
301 return uint16_array_value ();
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
302 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
303
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
304 octave_value
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
305 octave_perm_matrix::as_uint32 () const
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
306 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
307 return uint32_array_value ();
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
308 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
309
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
310 octave_value
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
311 octave_perm_matrix::as_uint64 () const
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
312 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
313 return uint64_array_value ();
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
314 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
315
24745
d2467914ce33 enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents: 24700
diff changeset
316 float_display_format
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
317 octave_perm_matrix::get_edit_display_format () const
24745
d2467914ce33 enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents: 24700
diff changeset
318 {
d2467914ce33 enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents: 24700
diff changeset
319 return float_display_format (float_format (1, 0, 0));
d2467914ce33 enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents: 24700
diff changeset
320 }
d2467914ce33 enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents: 24700
diff changeset
321
d2467914ce33 enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents: 24700
diff changeset
322 std::string
d2467914ce33 enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents: 24700
diff changeset
323 octave_perm_matrix::edit_display (const float_display_format& fmt,
d2467914ce33 enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents: 24700
diff changeset
324 octave_idx_type i,
d2467914ce33 enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents: 24700
diff changeset
325 octave_idx_type j) const
d2467914ce33 enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents: 24700
diff changeset
326 {
d2467914ce33 enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents: 24700
diff changeset
327 std::ostringstream buf;
30390
a61e1a0f6024 maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30139
diff changeset
328 octave_print_internal (buf, fmt, octave_int<octave_idx_type> (m_matrix(i, j)));
24745
d2467914ce33 enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents: 24700
diff changeset
329 return buf.str ();
d2467914ce33 enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents: 24700
diff changeset
330 }
d2467914ce33 enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents: 24700
diff changeset
331
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
332 bool
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
333 octave_perm_matrix::save_ascii (std::ostream& os)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
334 {
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
335 os << "# size: " << m_matrix.rows () << "\n";
18849
aa9ca67f09fb make all permutation matrices column permutations (bug #42418)
David Spies <dnspies@gmail.com>
parents: 18678
diff changeset
336 os << "# orient: c\n";
8376
c43481a19bfe implement ASCII saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
337
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
338 Array<octave_idx_type> pvec = m_matrix.col_perm_vec ();
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20228
diff changeset
339 octave_idx_type n = pvec.numel ();
8376
c43481a19bfe implement ASCII saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
340 ColumnVector tmp (n);
c43481a19bfe implement ASCII saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
341 for (octave_idx_type i = 0; i < n; i++) tmp(i) = pvec(i) + 1;
c43481a19bfe implement ASCII saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
342 os << tmp;
c43481a19bfe implement ASCII saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
343
c43481a19bfe implement ASCII saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
344 return true;
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
345 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
346
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
347 bool
8376
c43481a19bfe implement ASCII saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
348 octave_perm_matrix::load_ascii (std::istream& is)
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
349 {
8376
c43481a19bfe implement ASCII saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
350 octave_idx_type n;
c43481a19bfe implement ASCII saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
351 char orient;
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
352
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
353 if (! extract_keyword (is, "size", n, true)
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
354 || ! extract_keyword (is, "orient", orient, true))
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
355 error ("load: failed to extract size & orientation");
8376
c43481a19bfe implement ASCII saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
356
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
357 bool colp = orient == 'c';
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
358 ColumnVector tmp (n);
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
359 is >> tmp;
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
360 if (! is)
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
361 error ("load: failed to load permutation matrix constant");
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
362
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
363 Array<octave_idx_type> pvec (dim_vector (n, 1));
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
364 for (octave_idx_type i = 0; i < n; i++) pvec(i) = tmp(i) - 1;
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
365 m_matrix = PermMatrix (pvec, colp);
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
366
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21739
diff changeset
367 // Invalidate cache. Probably not necessary, but safe.
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
368 m_dense_cache = octave_value ();
8376
c43481a19bfe implement ASCII saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
369
21124
95f8c8cdbffe maint: Eliminate 'bool success' variable where possible.
Rik <rik@octave.org>
parents: 21118
diff changeset
370 return true;
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
371 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
372
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
373 bool
26399
586413770c7f pass save_as_floats by value in octave_value save_binary functions
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
374 octave_perm_matrix::save_binary (std::ostream& os, bool)
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
375 {
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
376
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
377 int32_t sz = m_matrix.rows ();
18849
aa9ca67f09fb make all permutation matrices column permutations (bug #42418)
David Spies <dnspies@gmail.com>
parents: 18678
diff changeset
378 bool colp = true;
9605
dfc68e6d8741 avoid some gcc warnings
John W. Eaton <jwe@octave.org>
parents: 8960
diff changeset
379 os.write (reinterpret_cast<char *> (&sz), 4);
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
380 os.write (reinterpret_cast<char *> (&colp), 1);
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
381 const Array<octave_idx_type>& col_perm = m_matrix.col_perm_vec ();
18849
aa9ca67f09fb make all permutation matrices column permutations (bug #42418)
David Spies <dnspies@gmail.com>
parents: 18678
diff changeset
382 os.write (reinterpret_cast<const char *> (col_perm.data ()),
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 30564
diff changeset
383 col_perm.byte_size ());
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
384
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
385 return true;
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
386 }
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
387
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
388 bool
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
389 octave_perm_matrix::load_binary (std::istream& is, bool swap,
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
390 octave::mach_info::float_format)
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
391 {
9605
dfc68e6d8741 avoid some gcc warnings
John W. Eaton <jwe@octave.org>
parents: 8960
diff changeset
392 int32_t sz;
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
393 bool colp;
9605
dfc68e6d8741 avoid some gcc warnings
John W. Eaton <jwe@octave.org>
parents: 8960
diff changeset
394 if (! (is.read (reinterpret_cast<char *> (&sz), 4)
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
395 && is.read (reinterpret_cast<char *> (&colp), 1)))
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
396 return false;
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
397
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
398 MArray<octave_idx_type> m (dim_vector (sz, 1));
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
399
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
400 if (! is.read (reinterpret_cast<char *> (m.fortran_vec ()), m.byte_size ()))
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
401 return false;
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
402
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
403 if (swap)
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
404 {
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
405 int nel = m.numel ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
406 for (int i = 0; i < nel; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 9812
diff changeset
407 switch (sizeof (octave_idx_type))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 9812
diff changeset
408 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 9812
diff changeset
409 case 8:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 9812
diff changeset
410 swap_bytes<8> (&m(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 9812
diff changeset
411 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 9812
diff changeset
412 case 4:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 9812
diff changeset
413 swap_bytes<4> (&m(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 9812
diff changeset
414 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 9812
diff changeset
415 case 2:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 9812
diff changeset
416 swap_bytes<2> (&m(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 9812
diff changeset
417 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 9812
diff changeset
418 case 1:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 9812
diff changeset
419 default:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 9812
diff changeset
420 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 9812
diff changeset
421 }
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
422 }
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
423
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
424 m_matrix = PermMatrix (m, colp);
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
425 return true;
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
426 }
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
427
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
428 void
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
429 octave_perm_matrix::print_raw (std::ostream& os,
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8376
diff changeset
430 bool pr_as_read_syntax) const
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
431 {
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
432 return octave_print_internal (os, m_matrix, pr_as_read_syntax,
8891
d077c590eb88 indicate diag & perm matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 8459
diff changeset
433 current_print_indent_level ());
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
434 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
435
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
436 mxArray *
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
437 octave_perm_matrix::as_mxArray (bool interleaved) const
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
438 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
439 return to_dense ().as_mxArray (interleaved);
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
440 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
441
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
442 bool
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
443 octave_perm_matrix::print_as_scalar () const
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
444 {
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
445 dim_vector dv = dims ();
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
446
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
447 return (dv.all_ones () || dv.any_zero ());
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
448 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
449
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
450 void
18416
bcd71a2531d3 Support disp/display overloading in classdef
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18130
diff changeset
451 octave_perm_matrix::print (std::ostream& os, bool pr_as_read_syntax)
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
452 {
8891
d077c590eb88 indicate diag & perm matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 8459
diff changeset
453 print_raw (os, pr_as_read_syntax);
d077c590eb88 indicate diag & perm matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 8459
diff changeset
454 newline (os);
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
455 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
456
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
457 int
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
458 octave_perm_matrix::write (octave::stream& os, int block_size,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
459 oct_data_conv::data_type output_type, int skip,
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
460 octave::mach_info::float_format flt_fmt) const
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
461 {
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
462 return to_dense ().write (os, block_size, output_type, skip, flt_fmt);
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
463 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
464
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
465 void
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
466 octave_perm_matrix::print_info (std::ostream& os,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
467 const std::string& prefix) const
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
468 {
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
469 m_matrix.print_info (os, prefix);
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
470 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
471
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
472 octave_value
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
473 octave_perm_matrix::to_dense () const
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
474 {
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
475 if (! m_dense_cache.is_defined ())
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
476 m_dense_cache = Matrix (m_matrix);
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
477
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
478 return m_dense_cache;
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
479 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
480
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
481 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_perm_matrix,
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
482 "permutation matrix", "double");
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
483
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
484 static octave_base_value *
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
485 default_numeric_conversion_function (const octave_base_value& a)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
486 {
21647
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
487 const octave_perm_matrix& v = dynamic_cast<const octave_perm_matrix&> (a);
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
488
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
489 return new octave_matrix (v.matrix_value ());
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
490 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
491
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
492 octave_base_value::type_conv_info
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
493 octave_perm_matrix::numeric_conversion_function () const
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
494 {
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
495 return octave_base_value::type_conv_info (default_numeric_conversion_function,
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 30564
diff changeset
496 octave_matrix::static_type_id ());
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
497 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
498
24646
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
499 // FIXME: This is duplicated from octave_base_matrix<T>. Could
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
500 // octave_perm_matrix be derived from octave_base_matrix<T>?
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
501
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
502 void
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
503 octave_perm_matrix::short_disp (std::ostream& os) const
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
504 {
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
505 if (m_matrix.isempty ())
24646
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
506 os << "[]";
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
507 else if (m_matrix.ndims () == 2)
24646
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
508 {
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
509 // FIXME: should this be configurable?
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
510 octave_idx_type max_elts = 10;
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
511 octave_idx_type elts = 0;
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
512
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
513 octave_idx_type nel = m_matrix.numel ();
24646
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
514
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
515 octave_idx_type nr = m_matrix.rows ();
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
516 octave_idx_type nc = m_matrix.columns ();
24646
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
517
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
518 os << '[';
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
519
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
520 for (octave_idx_type i = 0; i < nr; i++)
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
521 {
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
522 for (octave_idx_type j = 0; j < nc; j++)
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
523 {
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
524 std::ostringstream buf;
30390
a61e1a0f6024 maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30139
diff changeset
525 octave_int<octave_idx_type> tval (m_matrix(i, j));
24646
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
526 octave_print_internal (buf, tval);
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
527 std::string tmp = buf.str ();
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
528 std::size_t pos = tmp.find_first_not_of (' ');
24646
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
529 if (pos != std::string::npos)
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
530 os << tmp.substr (pos);
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
531 else if (! tmp.empty ())
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
532 os << tmp[0];
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
533
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
534 if (++elts >= max_elts)
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
535 goto done;
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
536
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
537 if (j < nc - 1)
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
538 os << ", ";
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
539 }
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
540
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
541 if (i < nr - 1 && elts < max_elts)
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
542 os << "; ";
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
543 }
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
544
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
545 done:
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
546
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
547 if (nel <= max_elts)
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
548 os << ']';
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
549 }
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
550 else
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
551 os << "...";
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
552 }
d36e1f768bfa allow diagonal and permutation matrices to be display in variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
553
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
554 octave_base_value *
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
555 octave_perm_matrix::try_narrowing_conversion ()
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
556 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23220
diff changeset
557 octave_base_value *retval = nullptr;
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
558
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
559 if (m_matrix.numel () == 1)
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
560 retval = new octave_scalar (m_matrix (0, 0));
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
561
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
562 return retval;
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
563 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
564
18650
491b0adfec95 compatibility fixes for printf integer format specifiers
John W. Eaton <jwe@octave.org>
parents: 18522
diff changeset
565 octave_value
491b0adfec95 compatibility fixes for printf integer format specifiers
John W. Eaton <jwe@octave.org>
parents: 18522
diff changeset
566 octave_perm_matrix::fast_elem_extract (octave_idx_type n) const
491b0adfec95 compatibility fixes for printf integer format specifiers
John W. Eaton <jwe@octave.org>
parents: 18522
diff changeset
567 {
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
568 if (n < m_matrix.numel ())
18650
491b0adfec95 compatibility fixes for printf integer format specifiers
John W. Eaton <jwe@octave.org>
parents: 18522
diff changeset
569 {
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
570 octave_idx_type nr = m_matrix.rows ();
18650
491b0adfec95 compatibility fixes for printf integer format specifiers
John W. Eaton <jwe@octave.org>
parents: 18522
diff changeset
571
491b0adfec95 compatibility fixes for printf integer format specifiers
John W. Eaton <jwe@octave.org>
parents: 18522
diff changeset
572 octave_idx_type r = n % nr;
491b0adfec95 compatibility fixes for printf integer format specifiers
John W. Eaton <jwe@octave.org>
parents: 18522
diff changeset
573 octave_idx_type c = n / nr;
491b0adfec95 compatibility fixes for printf integer format specifiers
John W. Eaton <jwe@octave.org>
parents: 18522
diff changeset
574
30077
b16e0d357437 maint: use "m_" prefix for member variables in some octave-value classes.
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
575 return octave_value (m_matrix.elem (r, c));
18650
491b0adfec95 compatibility fixes for printf integer format specifiers
John W. Eaton <jwe@octave.org>
parents: 18522
diff changeset
576 }
491b0adfec95 compatibility fixes for printf integer format specifiers
John W. Eaton <jwe@octave.org>
parents: 18522
diff changeset
577 else
491b0adfec95 compatibility fixes for printf integer format specifiers
John W. Eaton <jwe@octave.org>
parents: 18522
diff changeset
578 return octave_value ();
491b0adfec95 compatibility fixes for printf integer format specifiers
John W. Eaton <jwe@octave.org>
parents: 18522
diff changeset
579 }