annotate libinterp/octave-value/ov-re-mat.cc @ 22407:34ce5be04942

maint: Style check C++ code in libinterp/. * build-env.h, build-env.in.cc, builtins.h, Cell.cc, Cell.h, __contourc__.cc, __dispatch__.cc, __dsearchn__.cc, __ilu__.cc, __lin_interpn__.cc, __luinc__.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, balance.cc, base-text-renderer.h, besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h, cdisplay.c, cdisplay.h, cellfun.cc, coct-hdf5-types.c, comment-list.cc, comment-list.h, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc, debug.h, defaults.cc, defaults.in.h, defun-dld.h, defun-int.h, defun.h, det.cc, dirfns.cc, dirfns.h, display.cc, display.h, dlmread.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc, error.cc, error.h, errwarn.h, event-queue.cc, event-queue.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, file-io.h, filter.cc, find.cc, ft-text-renderer.cc, ft-text-renderer.h, gammainc.cc, gcd.cc, getgrent.cc, getpwent.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc, gl2ps-print.h, graphics.cc, graphics.in.h, gripes.h, gsvd.cc, hash.cc, help.cc, help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h, interpreter.cc, interpreter.h, inv.cc, jit-ir.cc, jit-ir.h, jit-typeinfo.cc, jit-typeinfo.h, jit-util.cc, jit-util.h, kron.cc, load-path.cc, load-path.h, load-save.cc, load-save.h, lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-hdf5.cc, ls-hdf5.h, ls-mat-ascii.cc, ls-mat-ascii.h, ls-mat4.cc, ls-mat4.h, ls-mat5.h, ls-oct-binary.cc, ls-oct-binary.h, ls-oct-text.cc, ls-oct-text.h, ls-utils.cc, ls-utils.h, lsode.cc, lu.cc, matrix_type.cc, max.cc, mex.cc, mex.h, mexproto.h, mgorth.cc, mxarray.in.h, nproc.cc, oct-errno.h, oct-errno.in.cc, oct-fstrm.cc, oct-fstrm.h, oct-handle.h, oct-hdf5-types.cc, oct-hdf5-types.h, oct-hdf5.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h, oct-lvalue.cc, oct-lvalue.h, oct-map.h, oct-obj.h, oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.cc, oct-strstrm.h, oct.h, octave-default-image.h, octave-link.h, octave-preserve-stream-state.h, ordschur.cc, pager.cc, pager.h, pinv.cc, pr-output.cc, pr-output.h, procstream.cc, procstream.h, profiler.h, psi.cc, pt-jit.cc, pt-jit.h, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc, sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h, text-renderer.cc, text-renderer.h, time.cc, toplev.cc, toplev.h, tril.cc, tsearch.cc, txt-eng.cc, txt-eng.h, typecast.cc, urlwrite.cc, utils.cc, utils.h, variables.cc, variables.h, workspace-element.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h, zfstream.cc, zfstream.h, deprecated-config.h, __delaunayn__.cc, __eigs__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __osmesa_print__.cc, __voronoi__.cc, amd.cc, audiodevinfo.cc, audioread.cc, ccolamd.cc, chol.cc, colamd.cc, convhulln.cc, dmperm.cc, fftw.cc, gzip.cc, oct-qhull.h, qr.cc, symbfact.cc, symrcm.cc, liboctinterp-build-info.h, liboctinterp-build-info.in.cc, ov-base-diag.h, ov-base-int.cc, ov-base-int.h, ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.h, ov-base-sparse.cc, ov-base-sparse.h, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-bool-mat.h, ov-bool-sparse.cc, ov-bool-sparse.h, ov-bool.cc, ov-bool.h, ov-builtin.cc, ov-builtin.h, ov-cell.cc, ov-cell.h, ov-ch-mat.cc, ov-ch-mat.h, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-colon.cc, ov-colon.h, ov-complex.cc, ov-complex.h, ov-cs-list.h, ov-cx-diag.cc, ov-cx-diag.h, ov-cx-mat.cc, ov-cx-mat.h, ov-cx-sparse.cc, ov-cx-sparse.h, ov-dld-fcn.cc, ov-dld-fcn.h, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn-inline.cc, ov-fcn-inline.h, ov-fcn.cc, ov-fcn.h, ov-float.cc, ov-float.h, ov-flt-complex.cc, ov-flt-complex.h, ov-flt-cx-diag.cc, ov-flt-cx-diag.h, ov-flt-cx-mat.cc, ov-flt-cx-mat.h, ov-flt-re-diag.cc, ov-flt-re-diag.h, ov-flt-re-mat.cc, ov-flt-re-mat.h, ov-int-traits.h, ov-int16.cc, ov-int16.h, ov-int32.cc, ov-int32.h, ov-int64.cc, ov-int64.h, ov-int8.cc, ov-int8.h, ov-intx.h, ov-java.cc, ov-java.h, ov-lazy-idx.cc, ov-lazy-idx.h, ov-mex-fcn.cc, ov-mex-fcn.h, ov-null-mat.cc, ov-null-mat.h, ov-oncleanup.cc, ov-oncleanup.h, ov-perm.cc, ov-perm.h, ov-range.cc, ov-range.h, ov-re-diag.cc, ov-re-diag.h, ov-re-mat.cc, ov-re-mat.h, ov-re-sparse.cc, ov-re-sparse.h, ov-scalar.cc, ov-scalar.h, ov-str-mat.cc, ov-str-mat.h, ov-struct.cc, ov-struct.h, ov-typeinfo.cc, ov-typeinfo.h, ov-uint16.cc, ov-uint16.h, ov-uint32.cc, ov-uint32.h, ov-uint64.cc, ov-uint64.h, ov-uint8.cc, ov-uint8.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.h, ovl.cc, ovl.h, octave.cc, octave.h, op-b-b.cc, op-b-bm.cc, op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc, op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-pm.cc, op-cm-s.cc, op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc, op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc, op-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcm-pm.cc, op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fm-pm.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-int-concat.cc, op-int.h, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-pm.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc, op-pm-cm.cc, op-pm-fcm.cc, op-pm-fm.cc, op-pm-m.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-pm-template.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc, op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, ops.h, options-usage.h, lex.h, parse.h, pt-all.h, pt-arg-list.cc, pt-arg-list.h, pt-array-list.h, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.cc, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-funcall.cc, pt-funcall.h, pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.cc, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-stmt.cc, pt-stmt.h, pt-unop.cc, pt-unop.h, pt-walk.h, pt.cc, pt.h, token.cc, token.h, Array-jit.cc, Array-tc.cc, version.cc, version.in.h: Style check C++ code in libinterp/
author Rik <rik@octave.org>
date Tue, 30 Aug 2016 21:46:47 -0700
parents d0562b3159c7
children 6bf1cbb90705
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1 /*
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22296
diff changeset
3 Copyright (C) 1996-2016 John W. Eaton
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 11129
diff changeset
4 Copyright (C) 2009-2010 VZLU Prague
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
5
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
7
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7004
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7004
diff changeset
11 option) any later version.
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
12
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
16 for more details.
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
17
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7004
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7004
diff changeset
20 <http://www.gnu.org/licenses/>.
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
21
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
22 */
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
23
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
24 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21231
diff changeset
25 # include "config.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
26 #endif
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
27
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3418
diff changeset
28 #include <iostream>
15215
9020dddc925a use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
29 #include <limits>
4726
14dc2267c343 [project @ 2004-01-23 20:04:35 by jwe]
jwe
parents: 4699
diff changeset
30 #include <vector>
2901
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents: 2847
diff changeset
31
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
32 #include "dNDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
33 #include "fNDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
34 #include "int8NDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
35 #include "int16NDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
36 #include "int32NDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
37 #include "int64NDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
38 #include "uint8NDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
39 #include "uint16NDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
40 #include "uint32NDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
41 #include "uint64NDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
42
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4901
diff changeset
43 #include "data-conv.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
44 #include "lo-ieee.h"
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
45 #include "lo-utils.h"
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
46 #include "lo-specfun.h"
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
47 #include "lo-mappers.h"
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4901
diff changeset
48 #include "mach-info.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
49 #include "mx-base.h"
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4102
diff changeset
50 #include "quit.h"
8377
25bc2d31e1bf improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
51 #include "oct-locbuf.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
52
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4844
diff changeset
53 #include "defun.h"
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21024
diff changeset
54 #include "errwarn.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
55 #include "mxarray.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20939
diff changeset
56 #include "ovl.h"
2979
a3556d2adec9 [project @ 1997-05-15 22:35:37 by jwe]
jwe
parents: 2974
diff changeset
57 #include "oct-lvalue.h"
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19861
diff changeset
58 #include "oct-hdf5.h"
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4901
diff changeset
59 #include "oct-stream.h"
2410
367485171742 [project @ 1996-10-15 16:50:27 by jwe]
jwe
parents: 2407
diff changeset
60 #include "ops.h"
3219
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3109
diff changeset
61 #include "ov-base.h"
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3109
diff changeset
62 #include "ov-base-mat.h"
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3109
diff changeset
63 #include "ov-base-mat.cc"
2410
367485171742 [project @ 1996-10-15 16:50:27 by jwe]
jwe
parents: 2407
diff changeset
64 #include "ov-scalar.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
65 #include "ov-re-mat.h"
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
66 #include "ov-flt-re-mat.h"
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
67 #include "ov-complex.h"
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
68 #include "ov-cx-mat.h"
7004
45d6cc5a0359 [project @ 2007-10-10 18:51:45 by jwe]
jwe
parents: 6974
diff changeset
69 #include "ov-re-sparse.h"
8399
c1bada868690 alow single/double conversion of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
70 #include "ov-re-diag.h"
c1bada868690 alow single/double conversion of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
71 #include "ov-cx-diag.h"
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
72 #include "ov-lazy-idx.h"
8399
c1bada868690 alow single/double conversion of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
73 #include "ov-perm.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
74 #include "pr-output.h"
2948
56be458e237f [project @ 1997-05-09 13:37:35 by jwe]
jwe
parents: 2916
diff changeset
75 #include "variables.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
76
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
77 #include "byte-swap.h"
20447
c6224b4e7774 maint: Rename instances of LS_ASCII to LS_TEXT for clarity.
Rik <rik@octave.org>
parents: 20228
diff changeset
78 #include "ls-oct-text.h"
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
79 #include "ls-utils.h"
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4758
diff changeset
80 #include "ls-hdf5.h"
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
81
22022
278fc29b69ca maint: Eliminate unnecessary double newline blocks (only whitespace changes).
Rik <rik@octave.org>
parents: 21966
diff changeset
82
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
83 template class octave_base_matrix<NDArray>;
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
84
4612
d44675070f1a [project @ 2003-11-14 19:49:56 by jwe]
jwe
parents: 4513
diff changeset
85 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_matrix, "matrix", "double");
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
86
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
87 static octave_base_value *
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
88 default_numeric_demotion_function (const octave_base_value& a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
89 {
21647
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
90 const octave_matrix& v = dynamic_cast<const octave_matrix&> (a);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
91
8754
900a5bf52309 Fix invalid conversion error on implicit demotion of n-d arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
92 return new octave_float_matrix (v.float_array_value ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
93 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
94
8345
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 7922
diff changeset
95 octave_base_value::type_conv_info
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
96 octave_matrix::numeric_demotion_function (void) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
97 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
98 return octave_base_value::type_conv_info
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
99 (default_numeric_demotion_function,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
100 octave_float_matrix::static_type_id ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
101 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
102
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5307
diff changeset
103 octave_base_value *
2410
367485171742 [project @ 1996-10-15 16:50:27 by jwe]
jwe
parents: 2407
diff changeset
104 octave_matrix::try_narrowing_conversion (void)
367485171742 [project @ 1996-10-15 16:50:27 by jwe]
jwe
parents: 2407
diff changeset
105 {
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5307
diff changeset
106 octave_base_value *retval = 0;
2410
367485171742 [project @ 1996-10-15 16:50:27 by jwe]
jwe
parents: 2407
diff changeset
107
20228
00cf2847355d Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
108 if (matrix.numel () == 1)
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
109 retval = new octave_scalar (matrix (0));
2410
367485171742 [project @ 1996-10-15 16:50:27 by jwe]
jwe
parents: 2407
diff changeset
110
367485171742 [project @ 1996-10-15 16:50:27 by jwe]
jwe
parents: 2407
diff changeset
111 return retval;
367485171742 [project @ 1996-10-15 16:50:27 by jwe]
jwe
parents: 2407
diff changeset
112 }
367485171742 [project @ 1996-10-15 16:50:27 by jwe]
jwe
parents: 2407
diff changeset
113
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
114 double
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
115 octave_matrix::double_value (bool) const
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
116 {
4102
cbac6756967e [project @ 2002-10-14 20:16:44 by jwe]
jwe
parents: 4100
diff changeset
117 double retval = lo_ieee_nan_value ();
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
118
21885
0806871e3e1e maint: Prefer is_empty() rather than "length () == 0".
Rik <rik@octave.org>
parents: 21786
diff changeset
119 if (is_empty ())
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
120 err_invalid_conversion ("real matrix", "real scalar");
4455
abbf63293766 [project @ 2003-07-11 01:01:16 by jwe]
jwe
parents: 4452
diff changeset
121
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
122 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: 21102
diff changeset
123 "real matrix", "real scalar");
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
124
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
125 retval = matrix(0, 0);
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
126
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
127 return retval;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
128 }
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
129
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
130 float
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
131 octave_matrix::float_value (bool) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
132 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
133 float retval = lo_ieee_float_nan_value ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
134
21885
0806871e3e1e maint: Prefer is_empty() rather than "length () == 0".
Rik <rik@octave.org>
parents: 21786
diff changeset
135 if (is_empty ())
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
136 err_invalid_conversion ("real matrix", "real scalar");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
137
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
138 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: 21102
diff changeset
139 "real matrix", "real scalar");
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
140
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
141 retval = matrix(0, 0);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
142
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
143 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
144 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
145
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5760
diff changeset
146 // FIXME
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
147
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
148 Matrix
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
149 octave_matrix::matrix_value (bool) const
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
150 {
19320
d0c73e23a505 Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents: 18200
diff changeset
151 return Matrix (matrix);
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
152 }
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
153
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
154 FloatMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
155 octave_matrix::float_matrix_value (bool) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
156 {
19320
d0c73e23a505 Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents: 18200
diff changeset
157 return FloatMatrix (Matrix (matrix));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
158 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
159
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
160 Complex
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
161 octave_matrix::complex_value (bool) const
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
162 {
4102
cbac6756967e [project @ 2002-10-14 20:16:44 by jwe]
jwe
parents: 4100
diff changeset
163 double tmp = lo_ieee_nan_value ();
cbac6756967e [project @ 2002-10-14 20:16:44 by jwe]
jwe
parents: 4100
diff changeset
164
cbac6756967e [project @ 2002-10-14 20:16:44 by jwe]
jwe
parents: 4100
diff changeset
165 Complex retval (tmp, tmp);
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
166
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
167 if (rows () == 0 || columns () == 0)
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
168 err_invalid_conversion ("real matrix", "complex scalar");
4455
abbf63293766 [project @ 2003-07-11 01:01:16 by jwe]
jwe
parents: 4452
diff changeset
169
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
170 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: 21102
diff changeset
171 "real matrix", "complex scalar");
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
172
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
173 retval = matrix(0, 0);
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
174
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
175 return retval;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
176 }
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
177
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
178 FloatComplex
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
179 octave_matrix::float_complex_value (bool) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
180 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
181 float tmp = lo_ieee_float_nan_value ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
182
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
183 FloatComplex retval (tmp, tmp);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
184
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
185 if (rows () == 0 || columns () == 0)
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
186 err_invalid_conversion ("real matrix", "complex scalar");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
187
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
188 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: 21102
diff changeset
189 "real matrix", "complex scalar");
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
190
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
191 retval = matrix(0, 0);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
192
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
193 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
194 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
195
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5760
diff changeset
196 // FIXME
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
197
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
198 ComplexMatrix
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
199 octave_matrix::complex_matrix_value (bool) const
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
200 {
19320
d0c73e23a505 Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents: 18200
diff changeset
201 return ComplexMatrix (Matrix (matrix));
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
202 }
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
203
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
204 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
205 octave_matrix::float_complex_matrix_value (bool) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
206 {
19320
d0c73e23a505 Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents: 18200
diff changeset
207 return FloatComplexMatrix (Matrix (matrix));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
208 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
209
4699
5e2c68946f30 [project @ 2004-01-20 23:04:46 by jwe]
jwe
parents: 4687
diff changeset
210 ComplexNDArray
5e2c68946f30 [project @ 2004-01-20 23:04:46 by jwe]
jwe
parents: 4687
diff changeset
211 octave_matrix::complex_array_value (bool) const
5e2c68946f30 [project @ 2004-01-20 23:04:46 by jwe]
jwe
parents: 4687
diff changeset
212 {
5e2c68946f30 [project @ 2004-01-20 23:04:46 by jwe]
jwe
parents: 4687
diff changeset
213 return ComplexNDArray (matrix);
5e2c68946f30 [project @ 2004-01-20 23:04:46 by jwe]
jwe
parents: 4687
diff changeset
214 }
5e2c68946f30 [project @ 2004-01-20 23:04:46 by jwe]
jwe
parents: 4687
diff changeset
215
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
216 FloatComplexNDArray
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
217 octave_matrix::float_complex_array_value (bool) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
218 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
219 return FloatComplexNDArray (matrix);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
220 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7740
diff changeset
221
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5862
diff changeset
222 boolNDArray
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
223 octave_matrix::bool_array_value (bool warn) const
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5862
diff changeset
224 {
7922
935be827eaf8 error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents: 7885
diff changeset
225 if (matrix.any_element_is_nan ())
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
226 octave::err_nan_to_logical_conversion ();
21120
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21118
diff changeset
227 if (warn && matrix.any_element_not_one_or_zero ())
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21024
diff changeset
228 warn_logical_conversion ();
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
229
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5862
diff changeset
230 return boolNDArray (matrix);
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5862
diff changeset
231 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
232
4758
a308566c8b42 [project @ 2004-02-13 23:01:34 by jwe]
jwe
parents: 4726
diff changeset
233 charNDArray
a308566c8b42 [project @ 2004-02-13 23:01:34 by jwe]
jwe
parents: 4726
diff changeset
234 octave_matrix::char_array_value (bool) const
a308566c8b42 [project @ 2004-02-13 23:01:34 by jwe]
jwe
parents: 4726
diff changeset
235 {
a308566c8b42 [project @ 2004-02-13 23:01:34 by jwe]
jwe
parents: 4726
diff changeset
236 charNDArray retval (dims ());
a308566c8b42 [project @ 2004-02-13 23:01:34 by jwe]
jwe
parents: 4726
diff changeset
237
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
238 octave_idx_type nel = numel ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
239
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
240 for (octave_idx_type i = 0; i < nel; i++)
4758
a308566c8b42 [project @ 2004-02-13 23:01:34 by jwe]
jwe
parents: 4726
diff changeset
241 retval.elem (i) = static_cast<char>(matrix.elem (i));
a308566c8b42 [project @ 2004-02-13 23:01:34 by jwe]
jwe
parents: 4726
diff changeset
242
a308566c8b42 [project @ 2004-02-13 23:01:34 by jwe]
jwe
parents: 4726
diff changeset
243 return retval;
a308566c8b42 [project @ 2004-02-13 23:01:34 by jwe]
jwe
parents: 4726
diff changeset
244 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
245
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
246 SparseMatrix
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5157
diff changeset
247 octave_matrix::sparse_matrix_value (bool) const
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5157
diff changeset
248 {
19320
d0c73e23a505 Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents: 18200
diff changeset
249 return SparseMatrix (Matrix (matrix));
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5157
diff changeset
250 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5157
diff changeset
251
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
252 SparseComplexMatrix
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5157
diff changeset
253 octave_matrix::sparse_complex_matrix_value (bool) const
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5157
diff changeset
254 {
17861
870f3e12e163 maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents: 17787
diff changeset
255 // FIXME: Need a SparseComplexMatrix (Matrix) constructor to make
870f3e12e163 maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents: 17787
diff changeset
256 // this function more efficient. Then this should become
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5157
diff changeset
257 // return SparseComplexMatrix (matrix.matrix_value ());
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5157
diff changeset
258 return SparseComplexMatrix (sparse_matrix_value ());
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5157
diff changeset
259 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5157
diff changeset
260
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
261 octave_value
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
262 octave_matrix::as_double (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
263 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
264 return NDArray (matrix);
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
265 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
266
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
267 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
268 octave_matrix::as_single (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
269 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
270 return FloatNDArray (matrix);
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
271 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
272
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
273 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
274 octave_matrix::as_int8 (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
275 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
276 return int8NDArray (matrix);
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
277 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
278
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
279 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
280 octave_matrix::as_int16 (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
281 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
282 return int16NDArray (matrix);
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
283 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
284
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
285 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
286 octave_matrix::as_int32 (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
287 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
288 return int32NDArray (matrix);
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
289 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
290
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
291 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
292 octave_matrix::as_int64 (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
293 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
294 return int64NDArray (matrix);
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
295 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
297 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
298 octave_matrix::as_uint8 (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
299 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
300 return uint8NDArray (matrix);
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
301 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
302
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
303 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
304 octave_matrix::as_uint16 (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
305 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
306 return uint16NDArray (matrix);
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
307 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
308
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
309 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
310 octave_matrix::as_uint32 (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
311 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
312 return uint32NDArray (matrix);
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
313 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
314
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
315 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
316 octave_matrix::as_uint64 (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
317 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
318 return uint64NDArray (matrix);
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
319 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
320
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22283
diff changeset
321 octave_value
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
322 octave_matrix::diag (octave_idx_type k) const
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
323 {
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
324 octave_value retval;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
325 if (k == 0 && matrix.ndims () == 2
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
326 && (matrix.rows () == 1 || matrix.columns () == 1))
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
327 retval = DiagMatrix (DiagArray2<double> (matrix));
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
328 else
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
329 retval = octave_base_matrix<NDArray>::diag (k);
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
330
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
331 return retval;
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
332 }
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
333
14557
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14469
diff changeset
334 octave_value
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14469
diff changeset
335 octave_matrix::diag (octave_idx_type m, octave_idx_type n) const
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14469
diff changeset
336 {
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
337 if (matrix.ndims () != 2
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
338 || (matrix.rows () != 1 && matrix.columns () != 1))
14557
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14469
diff changeset
339 error ("diag: expecting vector argument");
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14469
diff changeset
340
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
341 Matrix mat (matrix);
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
342
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
343 return mat.diag (m, n);
14557
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14469
diff changeset
344 }
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14469
diff changeset
345
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
346 // We override these two functions to allow reshaping both
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
347 // the matrix and the index cache.
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
348 octave_value
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
349 octave_matrix::reshape (const dim_vector& new_dims) const
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
350 {
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
351 if (idx_cache)
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
352 {
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
353 return new octave_matrix (matrix.reshape (new_dims),
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
354 idx_vector (idx_cache->as_array ().reshape (new_dims),
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
355 idx_cache->extent (0)));
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
356 }
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
357 else
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
358 return octave_base_matrix<NDArray>::reshape (new_dims);
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
359 }
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
360
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
361 octave_value
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
362 octave_matrix::squeeze (void) const
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
363 {
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
364 if (idx_cache)
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
365 {
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
366 return new octave_matrix (matrix.squeeze (),
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
367 idx_vector (idx_cache->as_array ().squeeze (),
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
368 idx_cache->extent (0)));
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
369 }
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
370 else
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
371 return octave_base_matrix<NDArray>::squeeze ();
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
372 }
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
373
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
374 octave_value
10273
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
375 octave_matrix::sort (octave_idx_type dim, sortmode mode) const
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
376 {
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
377 if (idx_cache)
10273
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
378 {
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
379 // This is a valid index matrix, so sort via integers because it's
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
380 // generally more efficient.
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
381 return octave_lazy_index (*idx_cache).sort (dim, mode);
10273
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
382 }
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
383 else
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
384 return octave_base_matrix<NDArray>::sort (dim, mode);
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
385 }
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
386
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
387 octave_value
10273
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
388 octave_matrix::sort (Array<octave_idx_type> &sidx, octave_idx_type dim,
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
389 sortmode mode) const
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
390 {
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
391 if (idx_cache)
10273
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
392 {
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
393 // This is a valid index matrix, so sort via integers because it's
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
394 // generally more efficient.
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
395 return octave_lazy_index (*idx_cache).sort (sidx, dim, mode);
10273
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
396 }
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
397 else
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
398 return octave_base_matrix<NDArray>::sort (sidx, dim, mode);
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
399 }
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
400
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
401 sortmode
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
402 octave_matrix::is_sorted (sortmode mode) const
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
403 {
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
404 if (idx_cache)
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
405 {
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
406 // This is a valid index matrix, so check via integers because it's
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
407 // generally more efficient.
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
408 return idx_cache->as_array ().is_sorted (mode);
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
409 }
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
410 else
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
411 return octave_base_matrix<NDArray>::is_sorted (mode);
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
412 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
413 Array<octave_idx_type>
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
414 octave_matrix::sort_rows_idx (sortmode mode) const
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
415 {
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
416 if (idx_cache)
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
417 {
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
418 // This is a valid index matrix, so sort via integers because it's
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
419 // generally more efficient.
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
420 return octave_lazy_index (*idx_cache).sort_rows_idx (mode);
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
421 }
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
422 else
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
423 return octave_base_matrix<NDArray>::sort_rows_idx (mode);
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
424 }
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
425
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
426 sortmode
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
427 octave_matrix::is_sorted_rows (sortmode mode) const
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
428 {
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
429 if (idx_cache)
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
430 {
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
431 // This is a valid index matrix, so check via integers because it's
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
432 // generally more efficient.
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
433 return idx_cache->as_array ().is_sorted_rows (mode);
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
434 }
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
435 else
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
436 return octave_base_matrix<NDArray>::is_sorted_rows (mode);
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
437 }
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
438
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
439 octave_value
5279
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5275
diff changeset
440 octave_matrix::convert_to_str_internal (bool, bool, char type) const
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
441 {
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
442 octave_value retval;
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4837
diff changeset
443 dim_vector dv = dims ();
5862
2b35a7fe9302 [project @ 2006-06-20 04:31:56 by jwe]
jwe
parents: 5828
diff changeset
444 octave_idx_type nel = dv.numel ();
2b35a7fe9302 [project @ 2006-06-20 04:31:56 by jwe]
jwe
parents: 5828
diff changeset
445
2b35a7fe9302 [project @ 2006-06-20 04:31:56 by jwe]
jwe
parents: 5828
diff changeset
446 charNDArray chm (dv);
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
447
5862
2b35a7fe9302 [project @ 2006-06-20 04:31:56 by jwe]
jwe
parents: 5828
diff changeset
448 bool warned = false;
2b35a7fe9302 [project @ 2006-06-20 04:31:56 by jwe]
jwe
parents: 5828
diff changeset
449
2b35a7fe9302 [project @ 2006-06-20 04:31:56 by jwe]
jwe
parents: 5828
diff changeset
450 for (octave_idx_type i = 0; i < nel; i++)
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
451 {
10142
829e69ec3110 make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents: 9892
diff changeset
452 octave_quit ();
5862
2b35a7fe9302 [project @ 2006-06-20 04:31:56 by jwe]
jwe
parents: 5828
diff changeset
453
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
454 double d = matrix(i);
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4837
diff changeset
455
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21739
diff changeset
456 if (octave::math::isnan (d))
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
457 octave::err_nan_to_character_conversion ();
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
458
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21739
diff changeset
459 int ival = octave::math::nint (d);
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4837
diff changeset
460
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
461 if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
462 {
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
463 // FIXME: is there something better we could do?
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
464
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
465 ival = 0;
5862
2b35a7fe9302 [project @ 2006-06-20 04:31:56 by jwe]
jwe
parents: 5828
diff changeset
466
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
467 if (! warned)
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
468 {
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
469 ::warning ("range error for conversion to character value");
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
470 warned = true;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
471 }
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
472 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
473
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
474 chm(i) = static_cast<char> (ival);
5862
2b35a7fe9302 [project @ 2006-06-20 04:31:56 by jwe]
jwe
parents: 5828
diff changeset
475 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
476
9689
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9470
diff changeset
477 retval = octave_value (chm, type);
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
478
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
479 return retval;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
480 }
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
481
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
482 bool
6974
9e32bb109980 [project @ 2007-10-08 11:06:47 by jwe]
jwe
parents: 6717
diff changeset
483 octave_matrix::save_ascii (std::ostream& os)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
484 {
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
485 dim_vector dv = dims ();
5958
85c7dc4afe6b [project @ 2006-08-23 18:35:38 by jwe]
jwe
parents: 5956
diff changeset
486
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
487 if (dv.ndims () > 2)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
488 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
489 NDArray tmp = array_value ();
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
490
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
491 os << "# ndims: " << dv.ndims () << "\n";
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
492
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
493 for (int i=0; i < dv.ndims (); i++)
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
494 os << " " << dv(i);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
495
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
496 os << "\n" << tmp;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
497 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
498 else
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
499 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
500 // Keep this case, rather than use generic code above for backward
20449
df4165dfc676 maint: Fix misspelled word compatibility in code comments.
Rik <rik@octave.org>
parents: 20447
diff changeset
501 // compatibility. Makes load_ascii much more complex!!
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
502 os << "# rows: " << rows () << "\n"
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
503 << "# columns: " << columns () << "\n";
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
504
5958
85c7dc4afe6b [project @ 2006-08-23 18:35:38 by jwe]
jwe
parents: 5956
diff changeset
505 os << matrix_value ();
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
506 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
507
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
508 return true;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
509 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
510
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
511 bool
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
512 octave_matrix::load_ascii (std::istream& is)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
513 {
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4944
diff changeset
514 string_vector keywords(2);
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4944
diff changeset
515
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4944
diff changeset
516 keywords[0] = "ndims";
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4944
diff changeset
517 keywords[1] = "rows";
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
518
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4944
diff changeset
519 std::string kw;
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
520 octave_idx_type val = 0;
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4944
diff changeset
521
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
522 if (! extract_keyword (is, keywords, kw, val, true))
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
523 error ("load: failed to extract number of rows and columns");
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
524
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
525 if (kw == "ndims")
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
526 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
527 int mdims = static_cast<int> (val);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
528
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
529 if (mdims < 0)
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
530 error ("load: failed to extract number of dimensions");
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4944
diff changeset
531
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
532 dim_vector dv;
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
533 dv.resize (mdims);
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
534
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
535 for (int i = 0; i < mdims; i++)
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
536 is >> dv(i);
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4944
diff changeset
537
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
538 if (! is)
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
539 error ("load: failed to read dimensions");
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
540
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
541 NDArray tmp(dv);
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
542
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
543 is >> tmp;
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
544
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
545 if (! is)
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
546 error ("load: failed to load matrix constant");
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
547
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
548 matrix = tmp;
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
549 }
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
550 else if (kw == "rows")
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
551 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
552 octave_idx_type nr = val;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
553 octave_idx_type nc = 0;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
554
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
555 if (nr < 0 || ! extract_keyword (is, "columns", nc) || nc < 0)
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
556 error ("load: failed to extract number of rows and columns");
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
557
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
558 if (nr > 0 && nc > 0)
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
559 {
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
560 Matrix tmp (nr, nc);
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
561 is >> tmp;
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
562 if (! is)
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
563 error ("load: failed to load matrix constant");
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
564
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
565 matrix = tmp;
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
566 }
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
567 else if (nr == 0 || nc == 0)
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
568 matrix = Matrix (nr, nc);
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
569 else
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
570 panic_impossible ();
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4944
diff changeset
571 }
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4944
diff changeset
572 else
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
573 panic_impossible ();
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
574
21124
95f8c8cdbffe maint: Eliminate 'bool success' variable where possible.
Rik <rik@octave.org>
parents: 21120
diff changeset
575 return true;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
576 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
577
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
578 bool
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
579 octave_matrix::save_binary (std::ostream& os, bool& save_as_floats)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
580 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
581
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
582 dim_vector dv = dims ();
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
583 if (dv.ndims () < 1)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
584 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
585
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
586 // Use negative value for ndims to differentiate with old format!!
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
587 int32_t tmp = - dv.ndims ();
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
588 os.write (reinterpret_cast<char *> (&tmp), 4);
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
589 for (int i = 0; i < dv.ndims (); i++)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
590 {
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
591 tmp = dv(i);
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
592 os.write (reinterpret_cast<char *> (&tmp), 4);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
593 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
594
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
595 NDArray m = array_value ();
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
596 save_type st = LS_DOUBLE;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
597 if (save_as_floats)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
598 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
599 if (m.too_large_for_float ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
600 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
601 warning ("save: some values too large to save as floats --");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
602 warning ("save: saving as doubles instead");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
603 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
604 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
605 st = LS_FLOAT;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
606 }
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
607 else if (dv.numel () > 8192) // FIXME: make this configurable.
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
608 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
609 double max_val, min_val;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
610 if (m.all_integers (max_val, min_val))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
611 st = get_save_type (max_val, min_val);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
612 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
613
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
614 const double *mtmp = m.data ();
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
615 write_doubles (os, mtmp, st, dv.numel ());
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
616
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
617 return true;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
618 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
619
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
620 bool
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
621 octave_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
622 octave::mach_info::float_format fmt)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
623 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
624 char tmp;
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5781
diff changeset
625 int32_t mdims;
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
626 if (! is.read (reinterpret_cast<char *> (&mdims), 4))
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
627 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
628 if (swap)
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4901
diff changeset
629 swap_bytes<4> (&mdims);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
630 if (mdims < 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
631 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
632 mdims = - mdims;
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5781
diff changeset
633 int32_t di;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
634 dim_vector dv;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
635 dv.resize (mdims);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
636
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
637 for (int i = 0; i < mdims; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
638 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
639 if (! is.read (reinterpret_cast<char *> (&di), 4))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
640 return false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
641 if (swap)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
642 swap_bytes<4> (&di);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
643 dv(i) = di;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
644 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
645
5157
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
646 // Convert an array with a single dimension to be a row vector.
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
647 // Octave should never write files like this, other software
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
648 // might.
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
649
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
650 if (mdims == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
651 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
652 mdims = 2;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
653 dv.resize (mdims);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
654 dv(1) = dv(0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
655 dv(0) = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
656 }
5157
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
657
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
658 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
659 return false;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
660
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
661 NDArray m(dv);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
662 double *re = m.fortran_vec ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
663 read_doubles (is, re, static_cast<save_type> (tmp), dv.numel (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
664 swap, fmt);
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20449
diff changeset
665
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20449
diff changeset
666 if (! is)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
667 return false;
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20449
diff changeset
668
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
669 matrix = m;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
670 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
671 else
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
672 {
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5781
diff changeset
673 int32_t nr, nc;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
674 nr = mdims;
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
675 if (! is.read (reinterpret_cast<char *> (&nc), 4))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
676 return false;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
677 if (swap)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
678 swap_bytes<4> (&nc);
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
679 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
680 return false;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
681 Matrix m (nr, nc);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
682 double *re = m.fortran_vec ();
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
683 octave_idx_type len = nr * nc;
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
684 read_doubles (is, re, static_cast<save_type> (tmp), len, swap, fmt);
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20449
diff changeset
685
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20449
diff changeset
686 if (! is)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
687 return false;
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20449
diff changeset
688
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
689 matrix = m;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
690 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
691 return true;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
692 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
693
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19861
diff changeset
694 bool
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
695 octave_matrix::save_hdf5 (octave_hdf5_id loc_id, const char *name,
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
696 bool save_as_floats)
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19861
diff changeset
697 {
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19861
diff changeset
698 bool retval = false;
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19861
diff changeset
699
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
700 #if defined (HAVE_HDF5)
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4901
diff changeset
701
4837
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
702 dim_vector dv = dims ();
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
703 int empty = save_hdf5_empty (loc_id, name, dv);
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
704 if (empty)
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4758
diff changeset
705 return (empty > 0);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4758
diff changeset
706
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
707 int rank = dv.ndims ();
18100
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
708 hid_t space_hid, data_hid;
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
709 space_hid = data_hid = -1;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
710 NDArray m = array_value ();
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
711
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4758
diff changeset
712 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4758
diff changeset
713
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
714 // Octave uses column-major, while HDF5 uses row-major ordering
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4758
diff changeset
715 for (int i = 0; i < rank; i++)
20218
b2100e1659ac maint: Use cuddled parentheses when indexing dimension_vectors.
Rik <rik@octave.org>
parents: 19863
diff changeset
716 hdims[i] = dv(rank-i-1);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
717
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4805
diff changeset
718 space_hid = H5Screate_simple (rank, hdims, 0);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
719
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
720 if (space_hid < 0) return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
721
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
722 hid_t save_type_hid = H5T_NATIVE_DOUBLE;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
723
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
724 if (save_as_floats)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
725 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
726 if (m.too_large_for_float ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
727 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
728 warning ("save: some values too large to save as floats --");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
729 warning ("save: saving as doubles instead");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
730 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
731 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
732 save_type_hid = H5T_NATIVE_FLOAT;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
733 }
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
734 #if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
735 // hdf5 currently doesn't support float/integer conversions
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
736 else
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
737 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
738 double max_val, min_val;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
739
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
740 if (m.all_integers (max_val, min_val))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
741 save_type_hid
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
742 = save_type_to_hdf5 (get_save_type (max_val, min_val));
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
743 }
20945
9d9270e2f98f eliminate comments after preprocessor conditionals
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
744 #endif
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
745
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
746 #if defined (HAVE_HDF5_18)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
747 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 21013
diff changeset
748 octave_H5P_DEFAULT, octave_H5P_DEFAULT, octave_H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
749 #else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
750 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 21013
diff changeset
751 octave_H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
752 #endif
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
753 if (data_hid < 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
754 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
755 H5Sclose (space_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
756 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
757 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
758
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
759 double *mtmp = m.fortran_vec ();
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 21013
diff changeset
760 retval = H5Dwrite (data_hid, H5T_NATIVE_DOUBLE, octave_H5S_ALL, octave_H5S_ALL,
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 21013
diff changeset
761 octave_H5P_DEFAULT, mtmp) >= 0;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
762
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
763 H5Dclose (data_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
764 H5Sclose (space_hid);
4837
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
765
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19861
diff changeset
766 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
767 octave_unused_parameter (loc_id);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
768 octave_unused_parameter (name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
769 octave_unused_parameter (save_as_floats);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
770
21102
dfcb9d74b253 Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents: 21100
diff changeset
771 warn_save ("hdf5");
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19861
diff changeset
772 #endif
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19861
diff changeset
773
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
774 return retval;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
775 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
776
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
777 bool
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19861
diff changeset
778 octave_matrix::load_hdf5 (octave_hdf5_id loc_id, const char *name)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
779 {
4837
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
780 bool retval = false;
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
781
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19861
diff changeset
782 #if defined (HAVE_HDF5)
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19861
diff changeset
783
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4758
diff changeset
784 dim_vector dv;
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4758
diff changeset
785 int empty = load_hdf5_empty (loc_id, name, dv);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4758
diff changeset
786 if (empty > 0)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
787 matrix.resize (dv);
4837
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
788 if (empty)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
789 return (empty > 0);
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4758
diff changeset
790
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
791 #if defined (HAVE_HDF5_18)
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 21013
diff changeset
792 hid_t data_hid = H5Dopen (loc_id, name, octave_H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
793 #else
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
794 hid_t data_hid = H5Dopen (loc_id, name);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
795 #endif
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
796 hid_t space_id = H5Dget_space (data_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
797
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
798 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
799
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
800 if (rank < 1)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
801 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
802 H5Sclose (space_id);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
803 H5Dclose (data_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
804 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
805 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
806
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
807 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
808 OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
809
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
810 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
811
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
812 // Octave uses column-major, while HDF5 uses row-major ordering
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
813 if (rank == 1)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
814 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
815 dv.resize (2);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
816 dv(0) = 1;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
817 dv(1) = hdims[0];
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
818 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
819 else
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
820 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
821 dv.resize (rank);
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4805
diff changeset
822 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
823 dv(j) = hdims[i];
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
824 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
825
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
826 NDArray m (dv);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
827 double *re = m.fortran_vec ();
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 21013
diff changeset
828 if (H5Dread (data_hid, H5T_NATIVE_DOUBLE, octave_H5S_ALL, octave_H5S_ALL,
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 21013
diff changeset
829 octave_H5P_DEFAULT, re) >= 0)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
830 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
831 retval = true;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
832 matrix = m;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
833 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
834
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
835 H5Sclose (space_id);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
836 H5Dclose (data_hid);
4837
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
837
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19861
diff changeset
838 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
839 octave_unused_parameter (loc_id);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
840 octave_unused_parameter (name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
841
21102
dfcb9d74b253 Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents: 21100
diff changeset
842 warn_load ("hdf5");
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19861
diff changeset
843 #endif
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19861
diff changeset
844
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
845 return retval;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4645
diff changeset
846 }
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4901
diff changeset
847
4643
ef3a14fb6847 [project @ 2003-11-22 12:25:44 by jwe]
jwe
parents: 4612
diff changeset
848 void
ef3a14fb6847 [project @ 2003-11-22 12:25:44 by jwe]
jwe
parents: 4612
diff changeset
849 octave_matrix::print_raw (std::ostream& os,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
850 bool pr_as_read_syntax) const
4643
ef3a14fb6847 [project @ 2003-11-22 12:25:44 by jwe]
jwe
parents: 4612
diff changeset
851 {
ef3a14fb6847 [project @ 2003-11-22 12:25:44 by jwe]
jwe
parents: 4612
diff changeset
852 octave_print_internal (os, matrix, pr_as_read_syntax,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10273
diff changeset
853 current_print_indent_level ());
4643
ef3a14fb6847 [project @ 2003-11-22 12:25:44 by jwe]
jwe
parents: 4612
diff changeset
854 }
ef3a14fb6847 [project @ 2003-11-22 12:25:44 by jwe]
jwe
parents: 4612
diff changeset
855
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
856 mxArray *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
857 octave_matrix::as_mxArray (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
858 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
859 mxArray *retval = new mxArray (mxDOUBLE_CLASS, dims (), mxREAL);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
860
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
861 double *pr = static_cast<double *> (retval->get_data ());
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
862
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 5958
diff changeset
863 mwSize nel = numel ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
864
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
865 const double *p = matrix.data ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
866
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 5958
diff changeset
867 for (mwIndex i = 0; i < nel; i++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
868 pr[i] = p[i];
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
869
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
870 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
871 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
872
9823
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
873 // This uses a smarter strategy for doing the complex->real mappers. We
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
874 // allocate an array for a real result and keep filling it until a complex
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
875 // result is produced.
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
876 static octave_value
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
877 do_rc_map (const NDArray& a, Complex (&fcn) (double))
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
878 {
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
879 octave_idx_type n = a.numel ();
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
880 NoAlias<NDArray> rr (a.dims ());
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
881
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
882 for (octave_idx_type i = 0; i < n; i++)
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
883 {
10142
829e69ec3110 make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents: 9892
diff changeset
884 octave_quit ();
9823
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
885
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
886 Complex tmp = fcn (a(i));
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
887 if (tmp.imag () == 0.0)
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
888 rr(i) = tmp.real ();
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
889 else
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
890 {
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
891 NoAlias<ComplexNDArray> rc (a.dims ());
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
892
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
893 for (octave_idx_type j = 0; j < i; j++)
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
894 rc(j) = rr(j);
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
895
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
896 rc(i) = tmp;
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
897
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
898 for (octave_idx_type j = i+1; j < n; j++)
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
899 {
10142
829e69ec3110 make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents: 9892
diff changeset
900 octave_quit ();
9823
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
901
9824
6631c61a4a4e fix typos in previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9823
diff changeset
902 rc(j) = fcn (a(j));
9823
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
903 }
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
904
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
905 return new octave_complex_matrix (rc);
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
906 }
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
907 }
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
908
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
909 return rr;
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
910 }
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
911
8650
a1ae2aae903e abs,real,imag,conj: use code from mx-inlines rather than the generic map
Jaroslav Hajek <highegg@gmail.com>
parents: 8437
diff changeset
912 octave_value
9812
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9689
diff changeset
913 octave_matrix::map (unary_mapper_t umap) const
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
914 {
9812
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9689
diff changeset
915 switch (umap)
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9689
diff changeset
916 {
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9689
diff changeset
917 case umap_imag:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9689
diff changeset
918 return NDArray (matrix.dims (), 0.0);
8650
a1ae2aae903e abs,real,imag,conj: use code from mx-inlines rather than the generic map
Jaroslav Hajek <highegg@gmail.com>
parents: 8437
diff changeset
919
9812
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9689
diff changeset
920 case umap_real:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9689
diff changeset
921 case umap_conj:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9689
diff changeset
922 return matrix;
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
923
9812
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9689
diff changeset
924 // Mappers handled specially.
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
925 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
926 case umap_ ## UMAP: \
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
927 return octave_value (matrix.FCN ())
8998
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
928
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
929 ARRAY_METHOD_MAPPER (abs, abs);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
930 ARRAY_METHOD_MAPPER (isnan, isnan);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
931 ARRAY_METHOD_MAPPER (isinf, isinf);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
932 ARRAY_METHOD_MAPPER (isfinite, isfinite);
8998
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
933
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
934 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
935 case umap_ ## UMAP: \
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
936 return octave_value (matrix.map<TYPE> (FCN))
8998
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
937
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
938 #define RC_ARRAY_MAPPER(UMAP, TYPE, FCN) \
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
939 case umap_ ## UMAP: \
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
940 return do_rc_map (matrix, FCN)
9823
9b62f2d8de6d improve r->c mapper strategy
Jaroslav Hajek <highegg@gmail.com>
parents: 9813
diff changeset
941
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
942 RC_ARRAY_MAPPER (acos, Complex, octave::math::rc_acos);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
943 RC_ARRAY_MAPPER (acosh, Complex, octave::math::rc_acosh);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
944 ARRAY_MAPPER (angle, double, octave::math::arg);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
945 ARRAY_MAPPER (arg, double,octave::math ::arg);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
946 RC_ARRAY_MAPPER (asin, Complex, octave::math::rc_asin);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
947 ARRAY_MAPPER (asinh, double, octave::math::asinh);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
948 ARRAY_MAPPER (atan, double, ::atan);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
949 RC_ARRAY_MAPPER (atanh, Complex, octave::math::rc_atanh);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
950 ARRAY_MAPPER (erf, double, octave::math::erf);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
951 ARRAY_MAPPER (erfinv, double, octave::math::erfinv);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
952 ARRAY_MAPPER (erfcinv, double, octave::math::erfcinv);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
953 ARRAY_MAPPER (erfc, double, octave::math::erfc);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
954 ARRAY_MAPPER (erfcx, double, octave::math::erfcx);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
955 ARRAY_MAPPER (erfi, double, octave::math::erfi);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
956 ARRAY_MAPPER (dawson, double, octave::math::dawson);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
957 ARRAY_MAPPER (gamma, double, octave::math::gamma);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
958 RC_ARRAY_MAPPER (lgamma, Complex, octave::math::rc_lgamma);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
959 ARRAY_MAPPER (cbrt, double, octave::math::cbrt);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
960 ARRAY_MAPPER (ceil, double, ::ceil);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
961 ARRAY_MAPPER (cos, double, ::cos);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
962 ARRAY_MAPPER (cosh, double, ::cosh);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
963 ARRAY_MAPPER (exp, double, ::exp);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
964 ARRAY_MAPPER (expm1, double, octave::math::expm1);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
965 ARRAY_MAPPER (fix, double, octave::math::fix);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
966 ARRAY_MAPPER (floor, double, ::floor);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
967 RC_ARRAY_MAPPER (log, Complex, octave::math::rc_log);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
968 RC_ARRAY_MAPPER (log2, Complex, octave::math::rc_log2);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
969 RC_ARRAY_MAPPER (log10, Complex, octave::math::rc_log10);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
970 RC_ARRAY_MAPPER (log1p, Complex, octave::math::rc_log1p);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
971 ARRAY_MAPPER (round, double, octave::math::round);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
972 ARRAY_MAPPER (roundb, double, octave::math::roundb);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
973 ARRAY_MAPPER (signum, double, octave::math::signum);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
974 ARRAY_MAPPER (sin, double, ::sin);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
975 ARRAY_MAPPER (sinh, double, ::sinh);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
976 RC_ARRAY_MAPPER (sqrt, Complex, octave::math::rc_sqrt);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
977 ARRAY_MAPPER (tan, double, ::tan);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
978 ARRAY_MAPPER (tanh, double, ::tanh);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
979 ARRAY_MAPPER (isna, bool, octave::math::is_NA);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
980 ARRAY_MAPPER (xsignbit, double, octave::math::signbit);
9812
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9689
diff changeset
981
18196
1b6db9303933 allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents: 18100
diff changeset
982 // Special cases for Matlab compatibility.
1b6db9303933 allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents: 18100
diff changeset
983 case umap_xtolower:
1b6db9303933 allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents: 18100
diff changeset
984 case umap_xtoupper:
1b6db9303933 allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents: 18100
diff changeset
985 return matrix;
1b6db9303933 allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents: 18100
diff changeset
986
18197
0d5721873d6b avoid some tests that rely on ordering of enum values
John W. Eaton <jwe@octave.org>
parents: 18196
diff changeset
987 case umap_xisalnum:
0d5721873d6b avoid some tests that rely on ordering of enum values
John W. Eaton <jwe@octave.org>
parents: 18196
diff changeset
988 case umap_xisalpha:
0d5721873d6b avoid some tests that rely on ordering of enum values
John W. Eaton <jwe@octave.org>
parents: 18196
diff changeset
989 case umap_xisascii:
0d5721873d6b avoid some tests that rely on ordering of enum values
John W. Eaton <jwe@octave.org>
parents: 18196
diff changeset
990 case umap_xiscntrl:
0d5721873d6b avoid some tests that rely on ordering of enum values
John W. Eaton <jwe@octave.org>
parents: 18196
diff changeset
991 case umap_xisdigit:
0d5721873d6b avoid some tests that rely on ordering of enum values
John W. Eaton <jwe@octave.org>
parents: 18196
diff changeset
992 case umap_xisgraph:
0d5721873d6b avoid some tests that rely on ordering of enum values
John W. Eaton <jwe@octave.org>
parents: 18196
diff changeset
993 case umap_xislower:
0d5721873d6b avoid some tests that rely on ordering of enum values
John W. Eaton <jwe@octave.org>
parents: 18196
diff changeset
994 case umap_xisprint:
0d5721873d6b avoid some tests that rely on ordering of enum values
John W. Eaton <jwe@octave.org>
parents: 18196
diff changeset
995 case umap_xispunct:
0d5721873d6b avoid some tests that rely on ordering of enum values
John W. Eaton <jwe@octave.org>
parents: 18196
diff changeset
996 case umap_xisspace:
0d5721873d6b avoid some tests that rely on ordering of enum values
John W. Eaton <jwe@octave.org>
parents: 18196
diff changeset
997 case umap_xisupper:
0d5721873d6b avoid some tests that rely on ordering of enum values
John W. Eaton <jwe@octave.org>
parents: 18196
diff changeset
998 case umap_xisxdigit:
0d5721873d6b avoid some tests that rely on ordering of enum values
John W. Eaton <jwe@octave.org>
parents: 18196
diff changeset
999 case umap_xtoascii:
0d5721873d6b avoid some tests that rely on ordering of enum values
John W. Eaton <jwe@octave.org>
parents: 18196
diff changeset
1000 {
0d5721873d6b avoid some tests that rely on ordering of enum values
John W. Eaton <jwe@octave.org>
parents: 18196
diff changeset
1001 octave_value str_conv = convert_to_str (true, true);
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20449
diff changeset
1002 return str_conv.map (umap);
18197
0d5721873d6b avoid some tests that rely on ordering of enum values
John W. Eaton <jwe@octave.org>
parents: 18196
diff changeset
1003 }
0d5721873d6b avoid some tests that rely on ordering of enum values
John W. Eaton <jwe@octave.org>
parents: 18196
diff changeset
1004
9812
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9689
diff changeset
1005 default:
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
1006 return octave_base_value::map (umap);
9812
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9689
diff changeset
1007 }
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9689
diff changeset
1008 }
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
1009