Mercurial > octave
annotate libinterp/octave-value/ov.cc @ 31605:e88a07dec498 stable
maint: Use macros to begin/end C++ namespaces.
* oct-conf-post-public.in.h: Define two macros (OCTAVE_BEGIN_NAMESPACE,
OCTAVE_END_NAMESPACE) that can be used to start/end a namespace.
* mk-opts.pl, build-env.h, build-env.in.cc, __betainc__.cc, __contourc__.cc,
__dsearchn__.cc, __eigs__.cc, __expint__.cc, __ftp__.cc, __gammainc__.cc,
__ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __lin_interpn__.cc,
__magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, amd.cc, auto-shlib.cc,
auto-shlib.h, balance.cc, base-text-renderer.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, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc,
colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc,
defaults.cc, defaults.h, defun-int.h, defun.cc, det.cc, dirfns.cc, display.cc,
display.h, dlmread.cc, dmperm.cc, dot.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc,
ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h,
event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc,
fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc,
ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, getgrent.cc, getpwent.cc,
getrusage.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc,
gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc,
graphics.in.h, gsvd.cc, gtk-manager.cc, gtk-manager.h, hash.cc, help.cc,
help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h,
interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h,
inv.cc, jsondecode.cc, jsonencode.cc, kron.cc, latex-text-renderer.cc,
latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h,
lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-oct-text.cc, ls-utils.cc,
ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex-private.h,
mex.cc, mgorth.cc, nproc.cc, oct-fstrm.cc, oct-fstrm.h, oct-hdf5-types.cc,
oct-hdf5-types.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h,
oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h,
oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h,
oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, oct-tex-parser.yy,
ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-flt-fmt.cc,
pr-output.cc, procstream.cc, procstream.h, psi.cc, qr.cc, quad.cc, quadcc.cc,
qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, settings.cc, settings.h,
sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc,
sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, stack-frame.cc, stack-frame.h,
stream-euler.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc,
symbfact.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h,
symscope.cc, symscope.h, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h,
text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc,
toplev.cc, tril.cc, tsearch.cc, typecast.cc, url-handle-manager.cc,
url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc,
variables.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h,
__delaunayn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc,
__init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audiodevinfo.cc,
audioread.cc, convhulln.cc, fftw.cc, gzip.cc, mk-build-env-features.sh,
mk-builtins.pl, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc,
cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h,
cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h,
cdef-utils.cc, cdef-utils.h, ov-base.cc, ov-base.h, ov-bool-mat.cc,
ov-builtin.h, ov-cell.cc, ov-class.cc, ov-class.h, ov-classdef.cc,
ov-classdef.h, ov-complex.cc, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h,
ov-java.cc, ov-java.h, ov-mex-fcn.h, ov-null-mat.cc, ov-oncleanup.cc,
ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h,
ov.cc, ov.h, octave.cc, octave.h, mk-ops.sh, op-b-b.cc, op-b-bm.cc,
op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc,
op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.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-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-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-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc,
op-m-scm.cc, op-m-sm.cc, op-mi.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,
anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h,
comment-list.cc, comment-list.h, filepos.h, lex.h, lex.ll, oct-lvalue.cc,
oct-lvalue.h, oct-parse.yy, parse.h, profiler.cc, profiler.h,
pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h,
pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h,
pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h,
pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h,
pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc,
pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc,
pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc,
pt-id.h, pt-idx.cc, pt-idx.h, 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-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc,
pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-vm-eval.cc, pt-walk.cc, pt-walk.h,
pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h,
range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc,
chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h,
lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h,
oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h,
oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc,
qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc,
randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc,
sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc,
child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc,
file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h,
mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h,
oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc,
oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h,
base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h,
file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc,
lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h,
oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h,
oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h,
oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h,
pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h,
url-transfer.cc, url-transfer.h : Use new macros to begin/end C++ namespaces.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 01 Dec 2022 14:23:45 -0800 |
parents | 929c05cf2afa |
children | dfa5d9c3ae72 aac27ad79be6 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30423
diff
changeset
|
3 // Copyright (C) 1996-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
2376 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21295
diff
changeset
|
27 # include "config.h" |
2376 | 28 #endif |
29 | |
30142
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
30 #include <cmath> |
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
31 |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
32 #include <type_traits> |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
33 |
4970 | 34 #include "data-conv.h" |
35 #include "quit.h" | |
2942 | 36 #include "str-vec.h" |
2376 | 37 |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
38 #include "ovl.h" |
4944 | 39 #include "oct-stream.h" |
2376 | 40 #include "ov.h" |
41 #include "ov-base.h" | |
2825 | 42 #include "ov-bool.h" |
43 #include "ov-bool-mat.h" | |
3351 | 44 #include "ov-cell.h" |
2376 | 45 #include "ov-scalar.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
46 #include "ov-float.h" |
2376 | 47 #include "ov-re-mat.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
48 #include "ov-flt-re-mat.h" |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
49 #include "ov-re-diag.h" |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
50 #include "ov-flt-re-diag.h" |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
51 #include "ov-legacy-range.h" |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
52 #include "ov-perm.h" |
5164 | 53 #include "ov-bool-sparse.h" |
54 #include "ov-cx-sparse.h" | |
55 #include "ov-re-sparse.h" | |
4901 | 56 #include "ov-int8.h" |
57 #include "ov-int16.h" | |
58 #include "ov-int32.h" | |
59 #include "ov-int64.h" | |
60 #include "ov-uint8.h" | |
61 #include "ov-uint16.h" | |
62 #include "ov-uint32.h" | |
63 #include "ov-uint64.h" | |
2376 | 64 #include "ov-complex.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
65 #include "ov-flt-complex.h" |
2376 | 66 #include "ov-cx-mat.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
67 #include "ov-flt-cx-mat.h" |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
68 #include "ov-cx-diag.h" |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
69 #include "ov-flt-cx-diag.h" |
2376 | 70 #include "ov-ch-mat.h" |
71 #include "ov-str-mat.h" | |
72 #include "ov-range.h" | |
73 #include "ov-struct.h" | |
7336 | 74 #include "ov-class.h" |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14861
diff
changeset
|
75 #include "ov-classdef.h" |
14015 | 76 #include "ov-oncleanup.h" |
3977 | 77 #include "ov-cs-list.h" |
2376 | 78 #include "ov-colon.h" |
2974 | 79 #include "ov-builtin.h" |
4649 | 80 #include "ov-dld-fcn.h" |
2974 | 81 #include "ov-usr-fcn.h" |
4342 | 82 #include "ov-fcn-handle.h" |
2376 | 83 #include "ov-typeinfo.h" |
28588
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
84 #include "ov-magic-int.h" |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
85 #include "ov-null-mat.h" |
10325
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
86 #include "ov-lazy-idx.h" |
15754
bf77f7f66bdf
register octave_java type at Octave startup
John W. Eaton <jwe@octave.org>
parents:
15467
diff
changeset
|
87 #include "ov-java.h" |
2376 | 88 |
89 #include "defun.h" | |
2880 | 90 #include "error.h" |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21078
diff
changeset
|
91 #include "errwarn.h" |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23589
diff
changeset
|
92 #include "interpreter-private.h" |
2376 | 93 #include "pager.h" |
4005 | 94 #include "parse.h" |
24668
d4dd741b2794
new octave_value functions for formatting output
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
95 #include "pr-flt-fmt.h" |
2376 | 96 #include "pr-output.h" |
7336 | 97 #include "symtab.h" |
2376 | 98 #include "utils.h" |
99 #include "variables.h" | |
100 | |
2477 | 101 // We are likely to have a lot of octave_value objects to allocate, so |
102 // make the grow_size large. | |
103 | |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
104 // If TRUE, create special space-optimized diagonal matrix objects. |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
105 |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
106 static bool Voptimize_diagonal_matrix = true; |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
107 |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
108 // If TRUE, create special space-optimized permutation matrix objects. |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
109 |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
110 static bool Voptimize_permutation_matrix = true; |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
111 |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
112 // If TRUE, create special space-optimized range objects. |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
113 |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
114 static bool Voptimize_range = true; |
19394
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
115 |
5775 | 116 // FIXME |
2880 | 117 |
2376 | 118 // Octave's value type. |
119 | |
21573
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
120 octave_base_value * |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
121 octave_value::nil_rep (void) |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
122 { |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
123 static octave_base_value nr; |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
124 return &nr; |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
125 } |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
126 |
3536 | 127 std::string |
3203 | 128 octave_value::unary_op_as_string (unary_op op) |
129 { | |
130 switch (op) | |
131 { | |
3533 | 132 case op_not: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
133 return "!"; |
3203 | 134 |
4965 | 135 case op_uplus: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
136 return "+"; |
4965 | 137 |
3533 | 138 case op_uminus: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
139 return "-"; |
3203 | 140 |
3533 | 141 case op_transpose: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
142 return ".'"; |
3203 | 143 |
3533 | 144 case op_hermitian: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
145 return "'"; |
3203 | 146 |
3533 | 147 case op_incr: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
148 return "++"; |
3203 | 149 |
3533 | 150 case op_decr: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
151 return "--"; |
3203 | 152 |
153 default: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
154 return "<unknown>"; |
3203 | 155 } |
156 } | |
157 | |
3536 | 158 std::string |
7336 | 159 octave_value::unary_op_fcn_name (unary_op op) |
160 { | |
161 switch (op) | |
162 { | |
163 case op_not: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
164 return "not"; |
7336 | 165 |
166 case op_uplus: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
167 return "uplus"; |
7336 | 168 |
169 case op_uminus: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
170 return "uminus"; |
7336 | 171 |
172 case op_transpose: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
173 return "transpose"; |
7336 | 174 |
175 case op_hermitian: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
176 return "ctranspose"; |
7336 | 177 |
178 default: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
179 return "<unknown>"; |
7336 | 180 } |
181 } | |
182 | |
183 std::string | |
2376 | 184 octave_value::binary_op_as_string (binary_op op) |
185 { | |
186 switch (op) | |
187 { | |
3533 | 188 case op_add: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
189 return "+"; |
2376 | 190 |
3533 | 191 case op_sub: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
192 return "-"; |
2376 | 193 |
3533 | 194 case op_mul: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
195 return "*"; |
2376 | 196 |
3533 | 197 case op_div: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
198 return "/"; |
2376 | 199 |
3533 | 200 case op_pow: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
201 return "^"; |
2376 | 202 |
3533 | 203 case op_ldiv: |
23804
8057d3f0673d
Use C++11 raw string literals to avoid escaping backslashes in strings.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
204 return R"(\)"; |
2903 | 205 |
3533 | 206 case op_lt: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
207 return "<"; |
2376 | 208 |
3533 | 209 case op_le: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
210 return "<="; |
2376 | 211 |
3533 | 212 case op_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
213 return "=="; |
2376 | 214 |
3533 | 215 case op_ge: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
216 return ">="; |
2376 | 217 |
3533 | 218 case op_gt: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
219 return ">"; |
2376 | 220 |
3533 | 221 case op_ne: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
222 return "!="; |
2376 | 223 |
3533 | 224 case op_el_mul: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
225 return ".*"; |
2376 | 226 |
3533 | 227 case op_el_div: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
228 return "./"; |
2376 | 229 |
3533 | 230 case op_el_pow: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
231 return ".^"; |
2376 | 232 |
3533 | 233 case op_el_ldiv: |
23804
8057d3f0673d
Use C++11 raw string literals to avoid escaping backslashes in strings.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
234 return R"(.\)"; |
2376 | 235 |
3533 | 236 case op_el_and: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
237 return "&"; |
2376 | 238 |
3533 | 239 case op_el_or: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
240 return "|"; |
2376 | 241 |
3533 | 242 case op_struct_ref: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
243 return "."; |
2376 | 244 |
245 default: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
246 return "<unknown>"; |
2376 | 247 } |
248 } | |
249 | |
3536 | 250 std::string |
7336 | 251 octave_value::binary_op_fcn_name (binary_op op) |
252 { | |
253 switch (op) | |
254 { | |
255 case op_add: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
256 return "plus"; |
7336 | 257 |
258 case op_sub: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
259 return "minus"; |
7336 | 260 |
261 case op_mul: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
262 return "mtimes"; |
7336 | 263 |
264 case op_div: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
265 return "mrdivide"; |
7336 | 266 |
267 case op_pow: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
268 return "mpower"; |
7336 | 269 |
270 case op_ldiv: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
271 return "mldivide"; |
7336 | 272 |
273 case op_lt: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
274 return "lt"; |
7336 | 275 |
276 case op_le: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
277 return "le"; |
7336 | 278 |
279 case op_eq: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
280 return "eq"; |
7336 | 281 |
282 case op_ge: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
283 return "ge"; |
7336 | 284 |
285 case op_gt: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
286 return "gt"; |
7336 | 287 |
288 case op_ne: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
289 return "ne"; |
7336 | 290 |
291 case op_el_mul: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
292 return "times"; |
7336 | 293 |
294 case op_el_div: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
295 return "rdivide"; |
7336 | 296 |
297 case op_el_pow: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
298 return "power"; |
7336 | 299 |
300 case op_el_ldiv: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
301 return "ldivide"; |
7336 | 302 |
303 case op_el_and: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
304 return "and"; |
7336 | 305 |
306 case op_el_or: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
307 return "or"; |
7336 | 308 |
309 default: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
310 return "<unknown>"; |
7336 | 311 } |
312 } | |
313 | |
314 std::string | |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
315 octave_value::binary_op_fcn_name (compound_binary_op op) |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
316 { |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
317 switch (op) |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
318 { |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
319 case op_trans_mul: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
320 return "transtimes"; |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
321 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
322 case op_mul_trans: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
323 return "timestrans"; |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
324 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
325 case op_herm_mul: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
326 return "hermtimes"; |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
327 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
328 case op_mul_herm: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
329 return "timesherm"; |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
330 |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
331 case op_trans_ldiv: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
332 return "transldiv"; |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
333 |
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
334 case op_herm_ldiv: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
335 return "hermldiv"; |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
336 |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
337 case op_el_and_not: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
338 return "andnot"; |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
339 |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
340 case op_el_or_not: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
341 return "ornot"; |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
342 |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
343 case op_el_not_and: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
344 return "notand"; |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
345 |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
346 case op_el_not_or: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
347 return "notor"; |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
348 |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
349 default: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
350 return "<unknown>"; |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
351 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
352 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
353 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
354 std::string |
2880 | 355 octave_value::assign_op_as_string (assign_op op) |
356 { | |
357 switch (op) | |
358 { | |
3533 | 359 case op_asn_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
360 return "="; |
2880 | 361 |
3533 | 362 case op_add_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
363 return "+="; |
2880 | 364 |
3533 | 365 case op_sub_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
366 return "-="; |
2880 | 367 |
3533 | 368 case op_mul_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
369 return "*="; |
2880 | 370 |
3533 | 371 case op_div_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
372 return "/="; |
2880 | 373 |
3533 | 374 case op_ldiv_eq: |
23804
8057d3f0673d
Use C++11 raw string literals to avoid escaping backslashes in strings.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
375 return R"(\=)"; |
3204 | 376 |
4018 | 377 case op_pow_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
378 return "^="; |
2903 | 379 |
3533 | 380 case op_el_mul_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
381 return ".*="; |
2880 | 382 |
3533 | 383 case op_el_div_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
384 return "./="; |
2880 | 385 |
3533 | 386 case op_el_ldiv_eq: |
23804
8057d3f0673d
Use C++11 raw string literals to avoid escaping backslashes in strings.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
387 return R"(.\=)"; |
3204 | 388 |
4018 | 389 case op_el_pow_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
390 return ".^="; |
4018 | 391 |
3533 | 392 case op_el_and_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
393 return "&="; |
2880 | 394 |
3533 | 395 case op_el_or_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
396 return "|="; |
2880 | 397 |
398 default: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
399 return "<unknown>"; |
2880 | 400 } |
401 } | |
402 | |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
403 octave_value::binary_op |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
404 octave_value::assign_op_to_binary_op (assign_op op) |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
405 { |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
406 switch (op) |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
407 { |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
408 case op_add_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
409 return op_add; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
410 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
411 case op_sub_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
412 return op_sub; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
413 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
414 case op_mul_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
415 return op_mul; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
416 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
417 case op_div_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
418 return op_div; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
419 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
420 case op_ldiv_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
421 return op_ldiv; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
422 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
423 case op_pow_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
424 return op_pow; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
425 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
426 case op_el_mul_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
427 return op_el_mul; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
428 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
429 case op_el_div_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
430 return op_el_div; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
431 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
432 case op_el_ldiv_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
433 return op_el_ldiv; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
434 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
435 case op_el_pow_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
436 return op_el_pow; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
437 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
438 case op_el_and_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
439 return op_el_and; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
440 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
441 case op_el_or_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
442 return op_el_or; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
443 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
444 default: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
445 return unknown_binary_op; |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
446 } |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
447 } |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
448 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
449 octave_value::assign_op |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
450 octave_value::binary_op_to_assign_op (binary_op op) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
451 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
452 switch (op) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
453 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
454 case op_add: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
455 return op_add_eq; |
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
456 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
457 case op_sub: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
458 return op_sub_eq; |
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
459 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
460 case op_mul: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
461 return op_mul_eq; |
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
462 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
463 case op_div: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
464 return op_div_eq; |
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
465 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
466 case op_el_mul: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
467 return op_el_mul_eq; |
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
468 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
469 case op_el_div: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
470 return op_el_div_eq; |
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
471 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
472 case op_el_and: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
473 return op_el_and_eq; |
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
474 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
475 case op_el_or: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
476 return op_el_or_eq; |
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
477 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
478 default: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
479 return unknown_assign_op; |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
480 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
481 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
482 |
4254 | 483 octave_value::octave_value (short int i) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
484 : m_rep (new octave_scalar (i)) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
485 { } |
4254 | 486 |
487 octave_value::octave_value (unsigned short int i) | |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
488 : m_rep (new octave_scalar (i)) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
489 { } |
4254 | 490 |
4233 | 491 octave_value::octave_value (int i) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
492 : m_rep (new octave_scalar (i)) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
493 { } |
4233 | 494 |
4254 | 495 octave_value::octave_value (unsigned int i) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
496 : m_rep (new octave_scalar (i)) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
497 { } |
4254 | 498 |
499 octave_value::octave_value (long int i) | |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
500 : m_rep (new octave_scalar (i)) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
501 { } |
4254 | 502 |
503 octave_value::octave_value (unsigned long int i) | |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
504 : m_rep (new octave_scalar (i)) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
505 { } |
4254 | 506 |
21354
06d15e4e611a
move public data type macros to octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21317
diff
changeset
|
507 #if defined (OCTAVE_HAVE_LONG_LONG_INT) |
4353 | 508 octave_value::octave_value (long long int i) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
509 : m_rep (new octave_scalar (i)) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
510 { } |
4353 | 511 #endif |
512 | |
21354
06d15e4e611a
move public data type macros to octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21317
diff
changeset
|
513 #if defined (OCTAVE_HAVE_UNSIGNED_LONG_LONG_INT) |
4353 | 514 octave_value::octave_value (unsigned long long int i) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
515 : m_rep (new octave_scalar (i)) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
516 { } |
4353 | 517 #endif |
518 | |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
519 octave_value::octave_value (octave::sys::time t) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
520 : m_rep (new octave_scalar (t.double_value ())) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
521 { } |
4254 | 522 |
2376 | 523 octave_value::octave_value (double d) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
524 : m_rep (new octave_scalar (d)) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
525 { } |
2376 | 526 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
527 octave_value::octave_value (float d) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
528 : m_rep (new octave_float_scalar (d)) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
529 { } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
530 |
4587 | 531 octave_value::octave_value (const Cell& c, bool is_csl) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
532 : m_rep (is_csl |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
533 ? dynamic_cast<octave_base_value *> (new octave_cs_list (c)) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
534 : dynamic_cast<octave_base_value *> (new octave_cell (c))) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
535 { } |
3351 | 536 |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
537 octave_value::octave_value (const Array<octave_value>& a, bool is_csl) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
538 : m_rep (is_csl |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
539 ? dynamic_cast<octave_base_value *> (new octave_cs_list (Cell (a))) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
540 : dynamic_cast<octave_base_value *> (new octave_cell (Cell (a)))) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
541 { } |
5147 | 542 |
5785 | 543 octave_value::octave_value (const Matrix& m, const MatrixType& t) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
544 : m_rep (new octave_matrix (m, t)) |
2423 | 545 { |
546 maybe_mutate (); | |
547 } | |
2376 | 548 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
549 octave_value::octave_value (const FloatMatrix& m, const MatrixType& t) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
550 : m_rep (new octave_float_matrix (m, t)) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
551 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
552 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
553 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
554 |
4507 | 555 octave_value::octave_value (const NDArray& a) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
556 : m_rep (new octave_matrix (a)) |
4478 | 557 { |
558 maybe_mutate (); | |
559 } | |
560 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
561 octave_value::octave_value (const FloatNDArray& a) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
562 : m_rep (new octave_float_matrix (a)) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
563 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
564 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
565 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
566 |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
567 octave_value::octave_value (const Array<double>& a) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
568 : m_rep (new octave_matrix (a)) |
4911 | 569 { |
570 maybe_mutate (); | |
571 } | |
572 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
573 octave_value::octave_value (const Array<float>& a) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
574 : m_rep (new octave_float_matrix (a)) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
575 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
576 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
577 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
578 |
15428
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
579 octave_value::octave_value (const DiagArray2<double>& d) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
580 : m_rep (Voptimize_diagonal_matrix |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
581 ? dynamic_cast<octave_base_value *> (new octave_diag_matrix (d)) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
582 : dynamic_cast<octave_base_value *> (new octave_matrix (Matrix (d)))) |
15428
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
583 { |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
584 maybe_mutate (); |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
585 } |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
586 |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
587 octave_value::octave_value (const DiagArray2<float>& d) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
588 : m_rep (Voptimize_diagonal_matrix |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
589 ? dynamic_cast<octave_base_value *> (new octave_float_diag_matrix (d)) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
590 : dynamic_cast<octave_base_value *> (new octave_float_matrix (FloatMatrix (d)))) |
15428
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
591 { |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
592 maybe_mutate (); |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
593 } |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
594 |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
595 octave_value::octave_value (const DiagArray2<Complex>& d) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
596 : m_rep (Voptimize_diagonal_matrix |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
597 ? dynamic_cast<octave_base_value *> (new octave_complex_diag_matrix (d)) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
598 : dynamic_cast<octave_base_value *> (new octave_complex_matrix (ComplexMatrix (d)))) |
15428
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
599 { |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
600 maybe_mutate (); |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
601 } |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
602 |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
603 octave_value::octave_value (const DiagArray2<FloatComplex>& d) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
604 : m_rep (Voptimize_diagonal_matrix |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
605 ? dynamic_cast<octave_base_value *> (new octave_float_complex_diag_matrix (d)) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
606 : dynamic_cast<octave_base_value *> (new octave_float_complex_matrix (FloatComplexMatrix (d)))) |
15428
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
607 { |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
608 maybe_mutate (); |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
609 } |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
610 |
2376 | 611 octave_value::octave_value (const DiagMatrix& d) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
612 : m_rep (Voptimize_diagonal_matrix |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
613 ? dynamic_cast<octave_base_value *> (new octave_diag_matrix (d)) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
614 : dynamic_cast<octave_base_value *> (new octave_matrix (Matrix (d)))) |
2423 | 615 { |
616 maybe_mutate (); | |
617 } | |
2376 | 618 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
619 octave_value::octave_value (const FloatDiagMatrix& d) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
620 : m_rep (Voptimize_diagonal_matrix |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
621 ? dynamic_cast<octave_base_value *> (new octave_float_diag_matrix (d)) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
622 : dynamic_cast<octave_base_value *> (new octave_float_matrix (FloatMatrix (d)))) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
623 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
624 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
625 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
626 |
3418 | 627 octave_value::octave_value (const RowVector& v) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
628 : m_rep (new octave_matrix (v)) |
2423 | 629 { |
630 maybe_mutate (); | |
631 } | |
2376 | 632 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
633 octave_value::octave_value (const FloatRowVector& v) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
634 : m_rep (new octave_float_matrix (v)) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
635 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
636 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
637 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
638 |
3418 | 639 octave_value::octave_value (const ColumnVector& v) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
640 : m_rep (new octave_matrix (v)) |
2423 | 641 { |
642 maybe_mutate (); | |
643 } | |
2376 | 644 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
645 octave_value::octave_value (const FloatColumnVector& v) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
646 : m_rep (new octave_float_matrix (v)) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
647 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
648 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
649 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
650 |
2376 | 651 octave_value::octave_value (const Complex& C) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
652 : m_rep (new octave_complex (C)) |
2423 | 653 { |
654 maybe_mutate (); | |
655 } | |
2376 | 656 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
657 octave_value::octave_value (const FloatComplex& C) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
658 : m_rep (new octave_float_complex (C)) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
659 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
660 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
661 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
662 |
5785 | 663 octave_value::octave_value (const ComplexMatrix& m, const MatrixType& t) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
664 : m_rep (new octave_complex_matrix (m, t)) |
2423 | 665 { |
666 maybe_mutate (); | |
667 } | |
2376 | 668 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
669 octave_value::octave_value (const FloatComplexMatrix& m, const MatrixType& t) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
670 : m_rep (new octave_float_complex_matrix (m, t)) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
671 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
672 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
673 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
674 |
4513 | 675 octave_value::octave_value (const ComplexNDArray& a) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
676 : m_rep (new octave_complex_matrix (a)) |
4478 | 677 { |
678 maybe_mutate (); | |
679 } | |
680 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
681 octave_value::octave_value (const FloatComplexNDArray& a) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
682 : m_rep (new octave_float_complex_matrix (a)) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
683 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
684 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
685 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
686 |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
687 octave_value::octave_value (const Array<Complex>& a) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
688 : m_rep (new octave_complex_matrix (a)) |
4911 | 689 { |
690 maybe_mutate (); | |
691 } | |
692 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
693 octave_value::octave_value (const Array<FloatComplex>& a) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
694 : m_rep (new octave_float_complex_matrix (a)) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
695 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
696 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
697 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
698 |
2376 | 699 octave_value::octave_value (const ComplexDiagMatrix& d) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
700 : m_rep (Voptimize_diagonal_matrix |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
701 ? dynamic_cast<octave_base_value *> (new octave_complex_diag_matrix (d)) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
702 : dynamic_cast<octave_base_value *> (new octave_complex_matrix (ComplexMatrix (d)))) |
2423 | 703 { |
704 maybe_mutate (); | |
705 } | |
2376 | 706 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
707 octave_value::octave_value (const FloatComplexDiagMatrix& d) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
708 : m_rep (Voptimize_diagonal_matrix |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
709 ? dynamic_cast<octave_base_value *> (new octave_float_complex_diag_matrix (d)) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
710 : dynamic_cast<octave_base_value *> (new octave_float_complex_matrix (FloatComplexMatrix (d)))) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
711 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
712 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
713 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
714 |
3418 | 715 octave_value::octave_value (const ComplexRowVector& v) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
716 : m_rep (new octave_complex_matrix (v)) |
2423 | 717 { |
718 maybe_mutate (); | |
719 } | |
2376 | 720 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
721 octave_value::octave_value (const FloatComplexRowVector& v) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
722 : m_rep (new octave_float_complex_matrix (v)) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
723 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
724 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
725 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
726 |
3418 | 727 octave_value::octave_value (const ComplexColumnVector& v) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
728 : m_rep (new octave_complex_matrix (v)) |
2423 | 729 { |
730 maybe_mutate (); | |
731 } | |
2376 | 732 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
733 octave_value::octave_value (const FloatComplexColumnVector& v) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
734 : m_rep (new octave_float_complex_matrix (v)) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
735 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
736 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
737 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
738 |
8960
93f18f166aba
remove float perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
739 octave_value::octave_value (const PermMatrix& p) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
740 : m_rep (Voptimize_permutation_matrix |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
741 ? dynamic_cast<octave_base_value *> (new octave_perm_matrix (p)) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
742 : dynamic_cast<octave_base_value *> (new octave_matrix (Matrix (p)))) |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
743 { |
8960
93f18f166aba
remove float perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
744 maybe_mutate (); |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
745 } |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
746 |
2825 | 747 octave_value::octave_value (bool b) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
748 : m_rep (new octave_bool (b)) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
749 { } |
2825 | 750 |
5785 | 751 octave_value::octave_value (const boolMatrix& bm, const MatrixType& t) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
752 : m_rep (new octave_bool_matrix (bm, t)) |
2825 | 753 { |
754 maybe_mutate (); | |
755 } | |
756 | |
4513 | 757 octave_value::octave_value (const boolNDArray& bnda) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
758 : m_rep (new octave_bool_matrix (bnda)) |
4513 | 759 { |
760 maybe_mutate (); | |
761 } | |
762 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
763 octave_value::octave_value (const Array<bool>& bnda) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
764 : m_rep (new octave_bool_matrix (bnda)) |
7433 | 765 { |
766 maybe_mutate (); | |
767 } | |
768 | |
5279 | 769 octave_value::octave_value (char c, char type) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
770 : m_rep (type == '"' |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
771 ? new octave_char_matrix_dq_str (c) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
772 : new octave_char_matrix_sq_str (c)) |
3189 | 773 { |
774 maybe_mutate (); | |
775 } | |
776 | |
5279 | 777 octave_value::octave_value (const char *s, char type) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
778 : m_rep (type == '"' |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
779 ? new octave_char_matrix_dq_str (s) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
780 : new octave_char_matrix_sq_str (s)) |
2423 | 781 { |
782 maybe_mutate (); | |
783 } | |
2376 | 784 |
5279 | 785 octave_value::octave_value (const std::string& s, char type) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
786 : m_rep (type == '"' |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
787 ? new octave_char_matrix_dq_str (s) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
788 : new octave_char_matrix_sq_str (s)) |
2423 | 789 { |
790 maybe_mutate (); | |
791 } | |
2376 | 792 |
5279 | 793 octave_value::octave_value (const string_vector& s, char type) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
794 : m_rep (type == '"' |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
795 ? new octave_char_matrix_dq_str (s) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
796 : new octave_char_matrix_sq_str (s)) |
2423 | 797 { |
798 maybe_mutate (); | |
799 } | |
2376 | 800 |
9689
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
801 octave_value::octave_value (const charMatrix& chm, char type) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
802 : m_rep (type == '"' |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
803 ? new octave_char_matrix_dq_str (chm) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
804 : new octave_char_matrix_sq_str (chm)) |
9689
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
805 { |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
806 maybe_mutate (); |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
807 } |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
808 |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
809 octave_value::octave_value (const charNDArray& chm, char type) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
810 : m_rep (type == '"' |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
811 ? new octave_char_matrix_dq_str (chm) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
812 : new octave_char_matrix_sq_str (chm)) |
2409 | 813 { |
4513 | 814 maybe_mutate (); |
815 } | |
2376 | 816 |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
817 octave_value::octave_value (const Array<char>& chm, char type) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
818 : m_rep (type == '"' |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
819 ? new octave_char_matrix_dq_str (chm) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
820 : new octave_char_matrix_sq_str (chm)) |
4513 | 821 { |
2423 | 822 maybe_mutate (); |
2409 | 823 } |
2376 | 824 |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23352
diff
changeset
|
825 octave_value::octave_value (const SparseMatrix& m, const MatrixType& t) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
826 : m_rep (new octave_sparse_matrix (m, t)) |
5164 | 827 { |
828 maybe_mutate (); | |
829 } | |
830 | |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23352
diff
changeset
|
831 octave_value::octave_value (const Sparse<double>& m, const MatrixType& t) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
832 : m_rep (new octave_sparse_matrix (m, t)) |
6863 | 833 { |
834 maybe_mutate (); | |
835 } | |
836 | |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23352
diff
changeset
|
837 octave_value::octave_value (const SparseComplexMatrix& m, const MatrixType& t) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
838 : m_rep (new octave_sparse_complex_matrix (m, t)) |
5164 | 839 { |
840 maybe_mutate (); | |
841 } | |
842 | |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23352
diff
changeset
|
843 octave_value::octave_value (const Sparse<Complex>& m, const MatrixType& t) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
844 : m_rep (new octave_sparse_complex_matrix (m, t)) |
6863 | 845 { |
846 maybe_mutate (); | |
847 } | |
848 | |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23352
diff
changeset
|
849 octave_value::octave_value (const SparseBoolMatrix& bm, const MatrixType& t) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
850 : m_rep (new octave_sparse_bool_matrix (bm, t)) |
5164 | 851 { |
852 maybe_mutate (); | |
853 } | |
854 | |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23352
diff
changeset
|
855 octave_value::octave_value (const Sparse<bool>& bm, const MatrixType& t) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
856 : m_rep (new octave_sparse_bool_matrix (bm, t)) |
7433 | 857 { |
858 maybe_mutate (); | |
859 } | |
860 | |
4901 | 861 octave_value::octave_value (const octave_int8& i) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
862 : m_rep (new octave_int8_scalar (i)) |
4901 | 863 { |
864 maybe_mutate (); | |
865 } | |
866 | |
867 octave_value::octave_value (const octave_uint8& i) | |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
868 : m_rep (new octave_uint8_scalar (i)) |
4901 | 869 { |
870 maybe_mutate (); | |
871 } | |
872 | |
873 octave_value::octave_value (const octave_int16& i) | |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
874 : m_rep (new octave_int16_scalar (i)) |
4901 | 875 { |
876 maybe_mutate (); | |
877 } | |
878 | |
879 octave_value::octave_value (const octave_uint16& i) | |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
880 : m_rep (new octave_uint16_scalar (i)) |
4901 | 881 { |
882 maybe_mutate (); | |
883 } | |
884 | |
885 octave_value::octave_value (const octave_int32& i) | |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
886 : m_rep (new octave_int32_scalar (i)) |
4901 | 887 { |
888 maybe_mutate (); | |
889 } | |
890 | |
891 octave_value::octave_value (const octave_uint32& i) | |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
892 : m_rep (new octave_uint32_scalar (i)) |
4901 | 893 { |
894 maybe_mutate (); | |
895 } | |
896 | |
897 octave_value::octave_value (const octave_int64& i) | |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
898 : m_rep (new octave_int64_scalar (i)) |
4901 | 899 { |
900 maybe_mutate (); | |
901 } | |
902 | |
903 octave_value::octave_value (const octave_uint64& i) | |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
904 : m_rep (new octave_uint64_scalar (i)) |
4901 | 905 { |
906 maybe_mutate (); | |
907 } | |
908 | |
909 octave_value::octave_value (const int8NDArray& inda) | |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
910 : m_rep (new octave_int8_matrix (inda)) |
4901 | 911 { |
912 maybe_mutate (); | |
913 } | |
914 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
915 octave_value::octave_value (const Array<octave_int8>& inda) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
916 : m_rep (new octave_int8_matrix (inda)) |
7064 | 917 { |
918 maybe_mutate (); | |
919 } | |
920 | |
4901 | 921 octave_value::octave_value (const uint8NDArray& inda) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
922 : m_rep (new octave_uint8_matrix (inda)) |
4901 | 923 { |
924 maybe_mutate (); | |
925 } | |
926 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
927 octave_value::octave_value (const Array<octave_uint8>& inda) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
928 : m_rep (new octave_uint8_matrix (inda)) |
7064 | 929 { |
930 maybe_mutate (); | |
931 } | |
932 | |
4901 | 933 octave_value::octave_value (const int16NDArray& inda) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
934 : m_rep (new octave_int16_matrix (inda)) |
4901 | 935 { |
936 maybe_mutate (); | |
937 } | |
938 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
939 octave_value::octave_value (const Array<octave_int16>& inda) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
940 : m_rep (new octave_int16_matrix (inda)) |
7064 | 941 { |
942 maybe_mutate (); | |
943 } | |
944 | |
4901 | 945 octave_value::octave_value (const uint16NDArray& inda) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
946 : m_rep (new octave_uint16_matrix (inda)) |
4901 | 947 { |
948 maybe_mutate (); | |
949 } | |
950 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
951 octave_value::octave_value (const Array<octave_uint16>& inda) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
952 : m_rep (new octave_uint16_matrix (inda)) |
7064 | 953 { |
954 maybe_mutate (); | |
955 } | |
956 | |
4901 | 957 octave_value::octave_value (const int32NDArray& inda) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
958 : m_rep (new octave_int32_matrix (inda)) |
4901 | 959 { |
960 maybe_mutate (); | |
961 } | |
962 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
963 octave_value::octave_value (const Array<octave_int32>& inda) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
964 : m_rep (new octave_int32_matrix (inda)) |
7064 | 965 { |
966 maybe_mutate (); | |
967 } | |
968 | |
4901 | 969 octave_value::octave_value (const uint32NDArray& inda) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
970 : m_rep (new octave_uint32_matrix (inda)) |
4901 | 971 { |
972 maybe_mutate (); | |
973 } | |
974 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
975 octave_value::octave_value (const Array<octave_uint32>& inda) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
976 : m_rep (new octave_uint32_matrix (inda)) |
7064 | 977 { |
978 maybe_mutate (); | |
979 } | |
980 | |
4901 | 981 octave_value::octave_value (const int64NDArray& inda) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
982 : m_rep (new octave_int64_matrix (inda)) |
4901 | 983 { |
984 maybe_mutate (); | |
985 } | |
986 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
987 octave_value::octave_value (const Array<octave_int64>& inda) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
988 : m_rep (new octave_int64_matrix (inda)) |
7064 | 989 { |
990 maybe_mutate (); | |
991 } | |
992 | |
4901 | 993 octave_value::octave_value (const uint64NDArray& inda) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
994 : m_rep (new octave_uint64_matrix (inda)) |
4901 | 995 { |
996 maybe_mutate (); | |
997 } | |
998 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
999 octave_value::octave_value (const Array<octave_uint64>& inda) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1000 : m_rep (new octave_uint64_matrix (inda)) |
7064 | 1001 { |
1002 maybe_mutate (); | |
1003 } | |
1004 | |
9351
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
1005 octave_value::octave_value (const Array<octave_idx_type>& inda, bool zero_based, |
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
1006 bool cache_index) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1007 : m_rep (new octave_matrix (inda, zero_based, cache_index)) |
9351
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
1008 { |
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
1009 maybe_mutate (); |
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
1010 } |
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
1011 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29478
diff
changeset
|
1012 octave_value::octave_value (const octave::idx_vector& idx, bool lazy) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1013 : m_rep () |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1014 { |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1015 double scalar; |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
1016 octave::range<double> range; |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1017 NDArray array; |
9894
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9879
diff
changeset
|
1018 boolNDArray mask; |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29478
diff
changeset
|
1019 octave::idx_vector::idx_class_type idx_class; |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1020 |
10325
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1021 if (lazy) |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1022 { |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1023 // Only make lazy indices out of ranges and index vectors. |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1024 switch (idx.idx_class ()) |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1025 { |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29478
diff
changeset
|
1026 case octave::idx_vector::class_range: |
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29478
diff
changeset
|
1027 case octave::idx_vector::class_vector: |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1028 m_rep = new octave_lazy_index (idx); |
10325
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1029 maybe_mutate (); |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1030 return; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1031 |
10325
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1032 default: |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1033 break; |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1034 } |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1035 } |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1036 |
9894
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9879
diff
changeset
|
1037 idx.unconvert (idx_class, scalar, range, array, mask); |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1038 |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1039 switch (idx_class) |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1040 { |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29478
diff
changeset
|
1041 case octave::idx_vector::class_colon: |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1042 m_rep = new octave_magic_colon (); |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1043 break; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1044 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29478
diff
changeset
|
1045 case octave::idx_vector::class_range: |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1046 m_rep = new octave_range (range, idx); |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1047 break; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1048 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29478
diff
changeset
|
1049 case octave::idx_vector::class_scalar: |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1050 m_rep = new octave_scalar (scalar); |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1051 break; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1052 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29478
diff
changeset
|
1053 case octave::idx_vector::class_vector: |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1054 m_rep = new octave_matrix (array, idx); |
9894
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9879
diff
changeset
|
1055 break; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1056 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29478
diff
changeset
|
1057 case octave::idx_vector::class_mask: |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1058 m_rep = new octave_bool_matrix (mask, idx); |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1059 break; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1060 |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1061 default: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1062 panic_impossible (); |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1063 break; |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1064 } |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1065 |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1066 // FIXME: needed? |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1067 maybe_mutate (); |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1068 } |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1069 |
9725 | 1070 octave_value::octave_value (const Array<std::string>& cellstr) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1071 : m_rep (new octave_cell (cellstr)) |
9725 | 1072 { |
1073 maybe_mutate (); | |
1074 } | |
1075 | |
29954
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29930
diff
changeset
|
1076 // Remove when public constructor that uses this function is removed. |
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29930
diff
changeset
|
1077 octave_base_value * |
30022
85d8dfe7e483
fix error in defn of make_range_rep_deprecated introduced in 4c88a452519c
John W. Eaton <jwe@octave.org>
parents:
30001
diff
changeset
|
1078 octave_value::make_range_rep_deprecated (double base, double inc, double limit) |
2423 | 1079 { |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
1080 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC) |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
1081 # pragma GCC diagnostic push |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
1082 # pragma GCC diagnostic ignored "-Wdeprecated-declarations" |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
1083 #endif |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
1084 |
29954
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29930
diff
changeset
|
1085 return dynamic_cast<octave_base_value *> |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
1086 (new octave_legacy_range (Range (base, inc, limit))); |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
1087 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
1088 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC) |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
1089 # pragma GCC diagnostic pop |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
1090 #endif |
2423 | 1091 } |
2376 | 1092 |
29954
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29930
diff
changeset
|
1093 // Remove when public constructor that uses this function is removed. |
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29930
diff
changeset
|
1094 octave_base_value * |
30022
85d8dfe7e483
fix error in defn of make_range_rep_deprecated introduced in 4c88a452519c
John W. Eaton <jwe@octave.org>
parents:
30001
diff
changeset
|
1095 octave_value::make_range_rep_deprecated (const Range& r, bool force_range) |
2423 | 1096 { |
28592
e70c859c4bff
allow infinite limits on for loop ranges (bug #45143)
John W. Eaton <jwe@octave.org>
parents:
28588
diff
changeset
|
1097 if (! force_range && ! r.ok ()) |
e70c859c4bff
allow infinite limits on for loop ranges (bug #45143)
John W. Eaton <jwe@octave.org>
parents:
28588
diff
changeset
|
1098 error ("invalid range"); |
e70c859c4bff
allow infinite limits on for loop ranges (bug #45143)
John W. Eaton <jwe@octave.org>
parents:
28588
diff
changeset
|
1099 |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
1100 if ((force_range || Voptimize_range)) |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
1101 return dynamic_cast<octave_base_value *> (new octave_legacy_range (r)); |
28592
e70c859c4bff
allow infinite limits on for loop ranges (bug #45143)
John W. Eaton <jwe@octave.org>
parents:
28588
diff
changeset
|
1102 else |
29954
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29930
diff
changeset
|
1103 return dynamic_cast<octave_base_value *> (new octave_matrix (r.matrix_value ())); |
2423 | 1104 } |
2376 | 1105 |
30835
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1106 octave_value::octave_value (const octave::range<double>& r, bool force_range) |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1107 : m_rep (force_range || Voptimize_range |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1108 ? dynamic_cast<octave_base_value *> (new ov_range<double> (r)) |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1109 : dynamic_cast<octave_base_value *> (new octave_matrix (r.array_value ()))) |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1110 { |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1111 maybe_mutate (); |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1112 } |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1113 |
30835
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1114 // For now, disable all but range<double>. |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1115 |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1116 #if 0 |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1117 |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1118 octave_value::octave_value (const octave::range<float>& r, bool force_range) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1119 : m_rep (force_range || Voptimize_range |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1120 ? dynamic_cast<octave_base_value *> (new ov_range<float> (r)) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1121 : dynamic_cast<octave_base_value *> (new octave_float_matrix (r.array_value ()))) |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1122 { |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1123 maybe_mutate (); |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1124 } |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1125 |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1126 octave_value::octave_value (const octave::range<octave_int8>& r, |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1127 bool force_range) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1128 : m_rep (force_range || Voptimize_range |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1129 ? dynamic_cast<octave_base_value *> (new ov_range<octave_int8> (r)) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1130 : dynamic_cast<octave_base_value *> (new octave_int8_matrix (r.array_value ()))) |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1131 { |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1132 maybe_mutate (); |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1133 } |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1134 |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1135 octave_value::octave_value (const octave::range<octave_int16>& r, |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1136 bool force_range) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1137 : m_rep (force_range || Voptimize_range |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1138 ? dynamic_cast<octave_base_value *> (new ov_range<octave_int16> (r)) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1139 : dynamic_cast<octave_base_value *> (new octave_int16_matrix (r.array_value ()))) |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1140 { |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1141 maybe_mutate (); |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1142 } |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1143 |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1144 octave_value::octave_value (const octave::range<octave_int32>& r, |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1145 bool force_range) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1146 : m_rep (force_range || Voptimize_range |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1147 ? dynamic_cast<octave_base_value *> (new ov_range<octave_int32> (r)) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1148 : dynamic_cast<octave_base_value *> (new octave_int32_matrix (r.array_value ()))) |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1149 { |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1150 maybe_mutate (); |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1151 } |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1152 |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1153 octave_value::octave_value (const octave::range<octave_int64>& r, |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1154 bool force_range) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1155 : m_rep (force_range || Voptimize_range |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1156 ? dynamic_cast<octave_base_value *> (new ov_range<octave_int64> (r)) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1157 : dynamic_cast<octave_base_value *> (new octave_int64_matrix (r.array_value ()))) |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1158 { |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1159 maybe_mutate (); |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1160 } |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1161 |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1162 octave_value::octave_value (const octave::range<octave_uint8>& r, |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1163 bool force_range) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1164 : m_rep (force_range || Voptimize_range |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1165 ? dynamic_cast<octave_base_value *> (new ov_range<octave_uint8> (r)) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1166 : dynamic_cast<octave_base_value *> (new octave_uint8_matrix (r.array_value ()))) |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1167 { |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1168 maybe_mutate (); |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1169 } |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1170 |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1171 octave_value::octave_value (const octave::range<octave_uint16>& r, |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1172 bool force_range) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1173 : m_rep (force_range || Voptimize_range |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1174 ? dynamic_cast<octave_base_value *> (new ov_range<octave_uint16> (r)) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1175 : dynamic_cast<octave_base_value *> (new octave_uint16_matrix (r.array_value ()))) |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1176 { |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1177 maybe_mutate (); |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1178 } |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1179 |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1180 octave_value::octave_value (const octave::range<octave_uint32>& r, |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1181 bool force_range) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1182 : m_rep (force_range || Voptimize_range |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1183 ? dynamic_cast<octave_base_value *> (new ov_range<octave_uint32> (r)) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1184 : dynamic_cast<octave_base_value *> (new octave_uint32_matrix (r.array_value ()))) |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1185 { |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1186 maybe_mutate (); |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1187 } |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1188 |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1189 octave_value::octave_value (const octave::range<octave_uint64>& r, |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1190 bool force_range) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1191 : m_rep (force_range || Voptimize_range |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1192 ? dynamic_cast<octave_base_value *> (new ov_range<octave_uint64> (r)) |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1193 : dynamic_cast<octave_base_value *> (new octave_uint64_matrix (r.array_value ()))) |
2423 | 1194 { |
1195 maybe_mutate (); | |
1196 } | |
2376 | 1197 |
30835
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1198 octave_value::octave_value (const octave::range<char>& r, char type, |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1199 bool /*force_range*/) |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1200 #if 0 |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1201 : m_rep (force_range || optimize_range |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1202 ? dynamic_cast<octave_base_value *> (new octave_char_range (r, type)) |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1203 : dynamic_cast<octave_base_value *> (type == '"' |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1204 ? new octave_char_matrix_dq_str (r.array_value ()) |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1205 : new octave_char_matrix_sq_str (r.array_value ()))) |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1206 #else |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1207 : m_rep (type == '"' |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1208 ? new octave_char_matrix_dq_str (r.array_value ()) |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1209 : new octave_char_matrix_sq_str (r.array_value ())) |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1210 #endif |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1211 { |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1212 maybe_mutate (); |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1213 } |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1214 |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1215 #endif |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
1216 |
10742
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1217 octave_value::octave_value (const octave_map& m) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1218 : m_rep (new octave_struct (m)) |
10742
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1219 { |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1220 maybe_mutate (); |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1221 } |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1222 |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1223 octave_value::octave_value (const octave_scalar_map& m) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1224 : m_rep (new octave_scalar_struct (m)) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
1225 { } |
10742
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1226 |
23678
dcba41788495
new struct/map constructors
John W. Eaton <jwe@octave.org>
parents:
23614
diff
changeset
|
1227 octave_value::octave_value (const std::map<std::string, octave_value>& m) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1228 : m_rep (new octave_scalar_struct (m)) |
23678
dcba41788495
new struct/map constructors
John W. Eaton <jwe@octave.org>
parents:
23614
diff
changeset
|
1229 { } |
dcba41788495
new struct/map constructors
John W. Eaton <jwe@octave.org>
parents:
23614
diff
changeset
|
1230 |
18402
4c064d3d2750
Remove Octave_map class deprecated in 3.8.
Rik <rik@octave.org>
parents:
18306
diff
changeset
|
1231 octave_value::octave_value (const octave_map& m, const std::string& id, |
4c064d3d2750
Remove Octave_map class deprecated in 3.8.
Rik <rik@octave.org>
parents:
18306
diff
changeset
|
1232 const std::list<std::string>& plist) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1233 : m_rep (new octave_class (m, id, plist)) |
2825 | 1234 { |
10742
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1235 maybe_mutate (); |
2880 | 1236 } |
1237 | |
18402
4c064d3d2750
Remove Octave_map class deprecated in 3.8.
Rik <rik@octave.org>
parents:
18306
diff
changeset
|
1238 octave_value::octave_value (const octave_scalar_map& m, const std::string& id, |
13294
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13101
diff
changeset
|
1239 const std::list<std::string>& plist) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1240 : m_rep (new octave_class (m, id, plist)) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
1241 { } |
7336 | 1242 |
23352
778fdffc09df
deprecate "octave_value (octave_value_list, bool)" constructor
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1243 octave_value::octave_value (const octave_value_list& l) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1244 : m_rep (new octave_cs_list (l)) |
23352
778fdffc09df
deprecate "octave_value (octave_value_list, bool)" constructor
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1245 { } |
778fdffc09df
deprecate "octave_value (octave_value_list, bool)" constructor
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1246 |
2376 | 1247 octave_value::octave_value (octave_value::magic_colon) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1248 : m_rep (new octave_magic_colon ()) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
1249 { } |
2376 | 1250 |
9728
70925b11ba46
again allow the obsolete syntax for cellfun
Jaroslav Hajek <highegg@gmail.com>
parents:
9725
diff
changeset
|
1251 octave_value::octave_value (octave_base_value *new_rep, bool borrow) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1252 : m_rep (new_rep) |
2825 | 1253 { |
9728
70925b11ba46
again allow the obsolete syntax for cellfun
Jaroslav Hajek <highegg@gmail.com>
parents:
9725
diff
changeset
|
1254 if (borrow) |
30139
c789e728d57a
Backed out changeset 938794bc82b7
John W. Eaton <jwe@octave.org>
parents:
30133
diff
changeset
|
1255 m_rep->count++; |
2825 | 1256 } |
2376 | 1257 |
5759 | 1258 octave_base_value * |
3933 | 1259 octave_value::clone (void) const |
2880 | 1260 { |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1261 return m_rep->clone (); |
2880 | 1262 } |
1263 | |
2409 | 1264 void |
29476
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1265 octave_value::break_closure_cycles (const std::shared_ptr<octave::stack_frame>& frame) |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1266 { |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1267 if (is_function_handle ()) |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1268 { |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1269 octave_fcn_handle *fhdl = m_rep->fcn_handle_value (); |
29476
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1270 |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1271 if (fhdl->is_nested (frame) && ! fhdl->is_weak_nested ()) |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1272 *this = fhdl->make_weak_nested_handle (); |
29477
34d06c73b48d
hold references to closure frames in anon functions if needed (bug #60237)
John W. Eaton <jwe@octave.org>
parents:
29476
diff
changeset
|
1273 else if (fhdl->is_anonymous () && ! fhdl->is_weak_anonymous ()) |
34d06c73b48d
hold references to closure frames in anon functions if needed (bug #60237)
John W. Eaton <jwe@octave.org>
parents:
29476
diff
changeset
|
1274 *this = fhdl->make_weak_anonymous_handle (); |
29476
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1275 } |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1276 else |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1277 { |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1278 // FIXME: Is there a efficient way to avoid calling make_unique |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1279 // if REP doesn't contain any nested function handles? |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1280 // |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1281 // Probably we should be asking REP to make a modified copy IFF it |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1282 // is needed, then replace our REP with that if a copy is made, |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1283 // otherwise we leave it alone. |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1284 |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1285 make_unique (); |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1286 |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1287 m_rep->break_closure_cycles (frame); |
29476
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1288 } |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1289 } |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1290 |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1291 void |
2409 | 1292 octave_value::maybe_mutate (void) |
1293 { | |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1294 octave_base_value *tmp = m_rep->try_narrowing_conversion (); |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1295 |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1296 if (tmp && tmp != m_rep) |
2409 | 1297 { |
30139
c789e728d57a
Backed out changeset 938794bc82b7
John W. Eaton <jwe@octave.org>
parents:
30133
diff
changeset
|
1298 if (--m_rep->count == 0) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1299 delete m_rep; |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1300 |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1301 m_rep = tmp; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1302 } |
2409 | 1303 } |
1304 | |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31155
diff
changeset
|
1305 OCTAVE_BEGIN_NAMESPACE(octave) |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
1306 |
22283
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1307 DEFUN (double, args, , |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1308 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30868
diff
changeset
|
1309 @deftypefn {} {@var{y} =} double (@var{x}) |
22283
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1310 Convert @var{x} to double precision type. |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1311 @seealso{single} |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1312 @end deftypefn */) |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1313 { |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1314 if (args.length () != 1) |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1315 print_usage (); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1316 |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1317 return ovl (args(0).as_double ()); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1318 } |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1319 |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1320 /* |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1321 %!assert (class (double (single (1))), "double") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1322 %!assert (class (double (single (1 + i))), "double") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1323 %!assert (class (double (int8 (1))), "double") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1324 %!assert (class (double (uint8 (1))), "double") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1325 %!assert (class (double (int16 (1))), "double") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1326 %!assert (class (double (uint16 (1))), "double") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1327 %!assert (class (double (int32 (1))), "double") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1328 %!assert (class (double (uint32 (1))), "double") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1329 %!assert (class (double (int64 (1))), "double") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1330 %!assert (class (double (uint64 (1))), "double") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1331 %!assert (class (double (true)), "double") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1332 %!assert (class (double ("A")), "double") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1333 %!test |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1334 %! x = sparse (logical ([1 0; 0 1])); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1335 %! y = double (x); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1336 %! assert (class (x), "logical"); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1337 %! assert (class (y), "double"); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1338 %! assert (issparse (y)); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1339 %!test |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1340 %! x = diag (single ([1 3 2])); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1341 %! y = double (x); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1342 %! assert (class (x), "single"); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1343 %! assert (class (y), "double"); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1344 %!test |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1345 %! x = diag (single ([i 3 2])); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1346 %! y = double (x); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1347 %! assert (class (x), "single"); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1348 %! assert (class (y), "double"); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1349 */ |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1350 |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1351 DEFUN (single, args, , |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1352 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30868
diff
changeset
|
1353 @deftypefn {} {@var{y} =} single (@var{x}) |
22283
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1354 Convert @var{x} to single precision type. |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1355 @seealso{double} |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1356 @end deftypefn */) |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1357 { |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1358 if (args.length () != 1) |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1359 print_usage (); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1360 |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1361 return args(0).as_single (); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1362 |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1363 return ovl (); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1364 } |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1365 |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1366 /* |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1367 %!assert (class (single (1)), "single") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1368 %!assert (class (single (1 + i)), "single") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1369 %!assert (class (single (int8 (1))), "single") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1370 %!assert (class (single (uint8 (1))), "single") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1371 %!assert (class (single (int16 (1))), "single") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1372 %!assert (class (single (uint16 (1))), "single") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1373 %!assert (class (single (int32 (1))), "single") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1374 %!assert (class (single (uint32 (1))), "single") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1375 %!assert (class (single (int64 (1))), "single") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1376 %!assert (class (single (uint64 (1))), "single") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1377 %!assert (class (single (true)), "single") |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1378 %!assert (class (single ("A")), "single") |
28930
2883b3d08b7e
maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents:
28888
diff
changeset
|
1379 %!error single (sparse (1)) |
22283
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1380 %!test |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1381 %! x = diag ([1 3 2]); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1382 %! y = single (x); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1383 %! assert (class (x), "double"); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1384 %! assert (class (y), "single"); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1385 %!test |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1386 %! x = diag ([i 3 2]); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1387 %! y = single (x); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1388 %! assert (class (x), "double"); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1389 %! assert (class (y), "single"); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1390 */ |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1391 |
22296
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1392 DEFUN (int8, args, , |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1393 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30868
diff
changeset
|
1394 @deftypefn {} {@var{y} =} int8 (@var{x}) |
22296
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1395 Convert @var{x} to 8-bit integer type. |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1396 @seealso{uint8, int16, uint16, int32, uint32, int64, uint64} |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1397 @end deftypefn */) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1398 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1399 if (args.length () != 1) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1400 print_usage (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1401 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1402 return args(0).as_int8 (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1403 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1404 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1405 /* |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1406 %!assert (class (int8 (1)), "int8") |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1407 %!assert (int8 (1.25), int8 (1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1408 %!assert (int8 (1.5), int8 (2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1409 %!assert (int8 (-1.5), int8 (-2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1410 %!assert (int8 (2^9), int8 (2^8-1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1411 %!assert (int8 (-2^9), int8 (-2^8)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1412 */ |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1413 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1414 DEFUN (int16, args, , |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1415 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30868
diff
changeset
|
1416 @deftypefn {} {@var{y} =} int16 (@var{x}) |
22296
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1417 Convert @var{x} to 16-bit integer type. |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1418 @seealso{int8, uint8, uint16, int32, uint32, int64, uint64} |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1419 @end deftypefn */) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1420 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1421 if (args.length () != 1) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1422 print_usage (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1423 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1424 return args(0).as_int16 (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1425 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1426 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1427 /* |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1428 %!assert (class (int16 (1)), "int16") |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1429 %!assert (int16 (1.25), int16 (1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1430 %!assert (int16 (1.5), int16 (2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1431 %!assert (int16 (-1.5), int16 (-2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1432 %!assert (int16 (2^17), int16 (2^16-1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1433 %!assert (int16 (-2^17), int16 (-2^16)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1434 */ |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1435 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1436 DEFUN (int32, args, , |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1437 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30868
diff
changeset
|
1438 @deftypefn {} {@var{y} =} int32 (@var{x}) |
22296
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1439 Convert @var{x} to 32-bit integer type. |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1440 @seealso{int8, uint8, int16, uint16, uint32, int64, uint64} |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1441 @end deftypefn */) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1442 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1443 if (args.length () != 1) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1444 print_usage (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1445 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1446 return args(0).as_int32 (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1447 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1448 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1449 /* |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1450 %!assert (class (int32 (1)), "int32") |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1451 %!assert (int32 (1.25), int32 (1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1452 %!assert (int32 (1.5), int32 (2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1453 %!assert (int32 (-1.5), int32 (-2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1454 %!assert (int32 (2^33), int32 (2^32-1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1455 %!assert (int32 (-2^33), int32 (-2^32)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1456 */ |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1457 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1458 DEFUN (int64, args, , |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1459 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30868
diff
changeset
|
1460 @deftypefn {} {@var{y} =} int64 (@var{x}) |
22296
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1461 Convert @var{x} to 64-bit integer type. |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1462 @seealso{int8, uint8, int16, uint16, int32, uint32, uint64} |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1463 @end deftypefn */) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1464 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1465 if (args.length () != 1) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1466 print_usage (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1467 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1468 return args(0).as_int64 (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1469 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1470 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1471 /* |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1472 %!assert (class (int64 (1)), "int64") |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1473 %!assert (int64 (1.25), int64 (1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1474 %!assert (int64 (1.5), int64 (2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1475 %!assert (int64 (-1.5), int64 (-2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1476 %!assert (int64 (2^65), int64 (2^64-1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1477 %!assert (int64 (-2^65), int64 (-2^64)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1478 */ |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1479 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1480 DEFUN (uint8, args, , |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1481 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30868
diff
changeset
|
1482 @deftypefn {} {@var{y} =} uint8 (@var{x}) |
22296
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1483 Convert @var{x} to unsigned 8-bit integer type. |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1484 @seealso{int8, int16, uint16, int32, uint32, int64, uint64} |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1485 @end deftypefn */) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1486 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1487 if (args.length () != 1) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1488 print_usage (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1489 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1490 return args(0).as_uint8 (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1491 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1492 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1493 /* |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1494 %!assert (class (uint8 (1)), "uint8") |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1495 %!assert (uint8 (1.25), uint8 (1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1496 %!assert (uint8 (1.5), uint8 (2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1497 %!assert (uint8 (-1.5), uint8 (0)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1498 %!assert (uint8 (2^9), uint8 (2^8-1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1499 %!assert (uint8 (-2^9), uint8 (0)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1500 */ |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1501 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1502 DEFUN (uint16, args, , |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1503 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30868
diff
changeset
|
1504 @deftypefn {} {@var{y} =} uint16 (@var{x}) |
22296
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1505 Convert @var{x} to unsigned 16-bit integer type. |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1506 @seealso{int8, uint8, int16, int32, uint32, int64, uint64} |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1507 @end deftypefn */) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1508 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1509 if (args.length () != 1) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1510 print_usage (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1511 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1512 return args(0).as_uint16 (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1513 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1514 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1515 /* |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1516 %!assert (class (uint16 (1)), "uint16") |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1517 %!assert (uint16 (1.25), uint16 (1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1518 %!assert (uint16 (1.5), uint16 (2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1519 %!assert (uint16 (-1.5), uint16 (0)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1520 %!assert (uint16 (2^17), uint16 (2^16-1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1521 %!assert (uint16 (-2^17), uint16 (0)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1522 */ |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1523 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1524 DEFUN (uint32, args, , |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1525 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30868
diff
changeset
|
1526 @deftypefn {} {@var{y} =} uint32 (@var{x}) |
22296
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1527 Convert @var{x} to unsigned 32-bit integer type. |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1528 @seealso{int8, uint8, int16, uint16, int32, int64, uint64} |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1529 @end deftypefn */) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1530 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1531 if (args.length () != 1) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1532 print_usage (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1533 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1534 return args(0).as_uint32 (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1535 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1536 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1537 /* |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1538 %!assert (class (uint32 (1)), "uint32") |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1539 %!assert (uint32 (1.25), uint32 (1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1540 %!assert (uint32 (1.5), uint32 (2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1541 %!assert (uint32 (-1.5), uint32 (0)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1542 %!assert (uint32 (2^33), uint32 (2^32-1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1543 %!assert (uint32 (-2^33), uint32 (0)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1544 */ |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1545 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1546 DEFUN (uint64, args, , |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1547 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30868
diff
changeset
|
1548 @deftypefn {} {@var{y} =} uint64 (@var{x}) |
22296
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1549 Convert @var{x} to unsigned 64-bit integer type. |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1550 @seealso{int8, uint8, int16, uint16, int32, uint32, int64} |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1551 @end deftypefn */) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1552 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1553 if (args.length () != 1) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1554 print_usage (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1555 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1556 return args(0).as_uint64 (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1557 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1558 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1559 /* |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1560 %!assert (class (uint64 (1)), "uint64") |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1561 %!assert (uint64 (1.25), uint64 (1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1562 %!assert (uint64 (1.5), uint64 (2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1563 %!assert (uint64 (-1.5), uint64 (0)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1564 %!assert (uint64 (2^65), uint64 (2^64-1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1565 %!assert (uint64 (-2^65), uint64 (0)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1566 */ |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1567 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31155
diff
changeset
|
1568 OCTAVE_END_NAMESPACE(octave) |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
1569 |
22296
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1570 octave_value |
4271 | 1571 octave_value::single_subsref (const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1572 const octave_value_list& idx) |
4247 | 1573 { |
1574 std::list<octave_value_list> i; | |
1575 | |
1576 i.push_back (idx); | |
1577 | |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1578 return m_rep->subsref (type, i); |
4247 | 1579 } |
1580 | |
2974 | 1581 octave_value_list |
4247 | 1582 octave_value::subsref (const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1583 const std::list<octave_value_list>& idx, int nargout) |
3933 | 1584 { |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1585 return m_rep->subsref (type, idx, nargout); |
3933 | 1586 } |
1587 | |
1588 octave_value | |
4247 | 1589 octave_value::next_subsref (const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1590 const std::list<octave_value_list>& idx, |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
1591 std::size_t skip) |
3933 | 1592 { |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1593 if (idx.size () > skip) |
3933 | 1594 { |
4219 | 1595 std::list<octave_value_list> new_idx (idx); |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
1596 for (std::size_t i = 0; i < skip; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1597 new_idx.erase (new_idx.begin ()); |
3933 | 1598 return subsref (type.substr (skip), new_idx); |
1599 } | |
1600 else | |
1601 return *this; | |
1602 } | |
1603 | |
1604 octave_value_list | |
4994 | 1605 octave_value::next_subsref (int nargout, const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1606 const std::list<octave_value_list>& idx, |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
1607 std::size_t skip) |
4994 | 1608 { |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1609 if (idx.size () > skip) |
4994 | 1610 { |
1611 std::list<octave_value_list> new_idx (idx); | |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
1612 for (std::size_t i = 0; i < skip; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1613 new_idx.erase (new_idx.begin ()); |
4994 | 1614 return subsref (type.substr (skip), new_idx, nargout); |
1615 } | |
1616 else | |
1617 return *this; | |
1618 } | |
1619 | |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1620 octave_value |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1621 octave_value::next_subsref (bool auto_add, const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1622 const std::list<octave_value_list>& idx, |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
1623 std::size_t skip) |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1624 { |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1625 if (idx.size () > skip) |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1626 { |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1627 std::list<octave_value_list> new_idx (idx); |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
1628 for (std::size_t i = 0; i < skip; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1629 new_idx.erase (new_idx.begin ()); |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1630 return subsref (type.substr (skip), new_idx, auto_add); |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1631 } |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1632 else |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1633 return *this; |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1634 } |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1635 |
3933 | 1636 octave_value |
4247 | 1637 octave_value::subsasgn (const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1638 const std::list<octave_value_list>& idx, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1639 const octave_value& rhs) |
3933 | 1640 { |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1641 return m_rep->subsasgn (type, idx, rhs); |
3933 | 1642 } |
1643 | |
12171
d08901c05c1b
fix bug in class assignment to undefined object with index
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1644 octave_value |
d08901c05c1b
fix bug in class assignment to undefined object with index
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1645 octave_value::undef_subsasgn (const std::string& type, |
d08901c05c1b
fix bug in class assignment to undefined object with index
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1646 const std::list<octave_value_list>& idx, |
d08901c05c1b
fix bug in class assignment to undefined object with index
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1647 const octave_value& rhs) |
d08901c05c1b
fix bug in class assignment to undefined object with index
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1648 { |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1649 return m_rep->undef_subsasgn (type, idx, rhs); |
12171
d08901c05c1b
fix bug in class assignment to undefined object with index
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1650 } |
d08901c05c1b
fix bug in class assignment to undefined object with index
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1651 |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1652 octave_value& |
4247 | 1653 octave_value::assign (assign_op op, const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1654 const std::list<octave_value_list>& idx, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1655 const octave_value& rhs) |
3933 | 1656 { |
1657 make_unique (); | |
1658 | |
1659 octave_value t_rhs = rhs; | |
1660 | |
1661 if (op != op_asn_eq) | |
1662 { | |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
1663 if (! is_defined ()) |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1664 error ("in computed assignment A(index) OP= X, A must be defined first"); |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
1665 |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
1666 octave_value t = subsref (type, idx); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
1667 |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
1668 binary_op binop = op_eq_to_binary_op (op); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
1669 |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
1670 t_rhs = octave::binary_op (binop, t, rhs); |
3933 | 1671 } |
1672 | |
20741
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
1673 *this = subsasgn (type, idx, t_rhs); |
3933 | 1674 |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1675 return *this; |
3933 | 1676 } |
1677 | |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1678 octave_value& |
3203 | 1679 octave_value::assign (assign_op op, const octave_value& rhs) |
2880 | 1680 { |
3533 | 1681 if (op == op_asn_eq) |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
1682 // Regularize a null matrix if stored into a variable. |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
1683 operator = (rhs.storable_value ()); |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1684 else if (is_defined ()) |
3203 | 1685 { |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
1686 octave::type_info::assign_op_fcn f = nullptr; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1687 |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1688 // Only attempt to operate in-place if this variable is unshared. |
30139
c789e728d57a
Backed out changeset 938794bc82b7
John W. Eaton <jwe@octave.org>
parents:
30133
diff
changeset
|
1689 if (m_rep->count == 1) |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1690 { |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1691 int tthis = this->type_id (); |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1692 int trhs = rhs.type_id (); |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1693 |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30888
diff
changeset
|
1694 octave::type_info& ti = octave::__get_type_info__ (); |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
1695 |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
1696 f = ti.lookup_assign_op (op, tthis, trhs); |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1697 } |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1698 |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1699 if (f) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1700 { |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1701 f (*m_rep, octave_value_list (), rhs.get_rep ()); |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
1702 // Usually unnecessary, but may be needed (complex arrays). |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
1703 maybe_mutate (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1704 } |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1705 else |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1706 { |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1707 |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1708 binary_op binop = op_eq_to_binary_op (op); |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1709 |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
1710 octave_value t = octave::binary_op (binop, *this, rhs); |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1711 |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1712 operator = (t); |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1713 } |
3204 | 1714 } |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1715 else |
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1716 error ("in computed assignment A OP= X, A must be defined first"); |
3204 | 1717 |
3933 | 1718 return *this; |
2376 | 1719 } |
1720 | |
26078
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1721 // FIXME: This is a bit of a kluge. We'd like to just use val.dims() |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1722 // and if val is an object, expect that dims will call size if it is |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1723 // overloaded by a user-defined method. But there are currently some |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1724 // unresolved const issues that prevent that solution from working. |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1725 |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1726 std::string |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1727 octave_value::get_dims_str (void) const |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1728 { |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1729 octave_value tmp = *this; |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1730 |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1731 Matrix sz = tmp.size (); |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1732 |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1733 dim_vector dv = dim_vector::alloc (sz.numel ()); |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1734 |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1735 for (octave_idx_type i = 0; i < dv.ndims (); i++) |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1736 dv(i) = sz(i); |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1737 |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1738 return dv.str (); |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1739 } |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1740 |
5275 | 1741 octave_idx_type |
4563 | 1742 octave_value::length (void) const |
1743 { | |
10654
984b8b6bee02
simplify octave_value::length
Jaroslav Hajek <highegg@gmail.com>
parents:
10614
diff
changeset
|
1744 octave_idx_type retval = 0; |
984b8b6bee02
simplify octave_value::length
Jaroslav Hajek <highegg@gmail.com>
parents:
10614
diff
changeset
|
1745 |
984b8b6bee02
simplify octave_value::length
Jaroslav Hajek <highegg@gmail.com>
parents:
10614
diff
changeset
|
1746 const dim_vector dv = dims (); |
4584 | 1747 |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
1748 for (int i = 0; i < dv.ndims (); i++) |
4563 | 1749 { |
4584 | 1750 if (dv(i) == 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1751 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1752 retval = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1753 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1754 } |
4584 | 1755 |
4563 | 1756 if (dv(i) > retval) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1757 retval = dv(i); |
4563 | 1758 } |
1759 | |
1760 return retval; | |
1761 } | |
1762 | |
8346
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1763 bool |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1764 octave_value::is_equal (const octave_value& test) const |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1765 { |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1766 bool retval = false; |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1767 |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1768 // If there is no op_eq for these types, we can't compare values. |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1769 |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1770 if (rows () == test.rows () && columns () == test.columns ()) |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1771 { |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
1772 octave_value tmp = octave::binary_op (octave_value::op_eq, *this, test); |
8346
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1773 |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1774 // Empty array also means a match. |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1775 if (tmp.is_defined ()) |
21990
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
1776 { |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23576
diff
changeset
|
1777 if (tmp.isempty ()) |
21990
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
1778 retval = true; |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
1779 else |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
1780 { |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
1781 // Reshape into a vector and call all() explicitly, |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
1782 // to avoid Octave:array-as-logical warning. |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
1783 tmp = tmp.reshape (dim_vector (tmp.numel (), 1)); |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
1784 retval = tmp.all ().is_true (); |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
1785 } |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
1786 } |
8346
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1787 } |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1788 |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1789 return retval; |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1790 } |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1791 |
8017
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1792 // Define the idx_type_value function here instead of in ov.h to avoid |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1793 // needing definitions for the SIZEOF_X macros in ov.h. |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1794 |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1795 octave_idx_type |
8024
dc36eb214129
ov.cc (octave_value::idx_type_value): don't include default argument value in definition
John W. Eaton <jwe@octave.org>
parents:
8017
diff
changeset
|
1796 octave_value::idx_type_value (bool req_int, bool frc_str_conv) const |
8017
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1797 { |
21229
a83e7a384ee0
create and install a subset of config.h in octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
1798 #if defined (OCTAVE_ENABLE_64) |
16323
e769440b39db
provide int64 extractors for octave_value class
John W. Eaton <jwe@octave.org>
parents:
16091
diff
changeset
|
1799 return int64_value (req_int, frc_str_conv); |
e769440b39db
provide int64 extractors for octave_value class
John W. Eaton <jwe@octave.org>
parents:
16091
diff
changeset
|
1800 #else |
8017
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1801 return int_value (req_int, frc_str_conv); |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1802 #endif |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1803 } |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1804 |
20703
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1805 Cell |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1806 octave_value::cell_value (void) const |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1807 { |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1808 return m_rep->cell_value (); |
20703
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1809 } |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1810 |
10742
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1811 octave_map |
2376 | 1812 octave_value::map_value (void) const |
1813 { | |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1814 return m_rep->map_value (); |
2376 | 1815 } |
1816 | |
10742
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1817 octave_scalar_map |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1818 octave_value::scalar_map_value (void) const |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1819 { |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1820 return m_rep->scalar_map_value (); |
10742
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1821 } |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1822 |
2974 | 1823 octave_function * |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
1824 octave_value::function_value (bool silent) const |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
1825 { |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1826 return m_rep->function_value (silent); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
1827 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
1828 |
23881
5aec653c88e7
new function for accessing classdef objects
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
1829 octave_classdef * |
5aec653c88e7
new function for accessing classdef objects
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
1830 octave_value::classdef_object_value (bool silent) const |
5aec653c88e7
new function for accessing classdef objects
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
1831 { |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1832 return m_rep->classdef_object_value (silent); |
23881
5aec653c88e7
new function for accessing classdef objects
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
1833 } |
5aec653c88e7
new function for accessing classdef objects
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
1834 |
4700 | 1835 octave_user_function * |
10075
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10033
diff
changeset
|
1836 octave_value::user_function_value (bool silent) const |
4700 | 1837 { |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1838 return m_rep->user_function_value (silent); |
4700 | 1839 } |
1840 | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
1841 octave_user_script * |
10075
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10033
diff
changeset
|
1842 octave_value::user_script_value (bool silent) const |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
1843 { |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1844 return m_rep->user_script_value (silent); |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
1845 } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
1846 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
1847 octave_user_code * |
10075
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10033
diff
changeset
|
1848 octave_value::user_code_value (bool silent) const |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
1849 { |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1850 return m_rep->user_code_value (silent); |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
1851 } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
1852 |
4346 | 1853 octave_fcn_handle * |
10075
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10033
diff
changeset
|
1854 octave_value::fcn_handle_value (bool silent) const |
4343 | 1855 { |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1856 return m_rep->fcn_handle_value (silent); |
4343 | 1857 } |
1858 | |
2880 | 1859 octave_value_list |
1860 octave_value::list_value (void) const | |
1861 { | |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
1862 return m_rep->list_value (); |
2880 | 1863 } |
1864 | |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1865 static dim_vector |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1866 make_vector_dims (const dim_vector& dv, bool force_vector_conversion, |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1867 const std::string& my_type, const std::string& wanted_type) |
3419 | 1868 { |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1869 dim_vector retval (dv); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1870 retval.chop_trailing_singletons (); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1871 octave_idx_type nel = dv.numel (); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1872 |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
1873 if (retval.ndims () > 2 || (retval(0) != 1 && retval(1) != 1)) |
3419 | 1874 { |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
1875 if (! force_vector_conversion) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21078
diff
changeset
|
1876 warn_implicit_conversion ("Octave:array-to-vector", |
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21078
diff
changeset
|
1877 my_type.c_str (), wanted_type.c_str ()); |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10325
diff
changeset
|
1878 retval = dim_vector (nel, 1); |
3419 | 1879 } |
1880 | |
1881 return retval; | |
1882 } | |
1883 | |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1884 ColumnVector |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1885 octave_value::column_vector_value (bool force_string_conv, |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1886 bool frc_vec_conv) const |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1887 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1888 return ColumnVector (vector_value (force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1889 frc_vec_conv)); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1890 } |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1891 |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1892 ComplexColumnVector |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1893 octave_value::complex_column_vector_value (bool force_string_conv, |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1894 bool frc_vec_conv) const |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1895 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1896 return ComplexColumnVector (complex_vector_value (force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1897 frc_vec_conv)); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1898 } |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1899 |
3419 | 1900 RowVector |
1901 octave_value::row_vector_value (bool force_string_conv, | |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1902 bool frc_vec_conv) const |
3419 | 1903 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1904 return RowVector (vector_value (force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1905 frc_vec_conv)); |
3419 | 1906 } |
1907 | |
1908 ComplexRowVector | |
1909 octave_value::complex_row_vector_value (bool force_string_conv, | |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1910 bool frc_vec_conv) const |
3419 | 1911 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1912 return ComplexRowVector (complex_vector_value (force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1913 frc_vec_conv)); |
3419 | 1914 } |
1915 | |
1916 Array<double> | |
2376 | 1917 octave_value::vector_value (bool force_string_conv, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1918 bool force_vector_conversion) const |
2376 | 1919 { |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1920 Array<double> retval = array_value (force_string_conv); |
2376 | 1921 |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1922 return retval.reshape (make_vector_dims (retval.dims (), |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1923 force_vector_conversion, |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1924 type_name (), "real vector")); |
2376 | 1925 } |
1926 | |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21129
diff
changeset
|
1927 template <typename T> |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1928 static Array<int> |
23534
b6498c088fca
maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents:
23502
diff
changeset
|
1929 convert_to_int_array (const Array<octave_int<T>>& A) |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1930 { |
7999 | 1931 Array<int> retval (A.dims ()); |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1932 octave_idx_type n = A.numel (); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1933 |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1934 for (octave_idx_type i = 0; i < n; i++) |
7999 | 1935 retval.xelem (i) = octave_int<int> (A.xelem (i)); |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
8024
diff
changeset
|
1936 |
7999 | 1937 return retval; |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1938 } |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1939 |
4044 | 1940 Array<int> |
20743
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
1941 octave_value::int_vector_value (bool require_int, bool force_string_conv, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1942 bool force_vector_conversion) const |
4044 | 1943 { |
1944 Array<int> retval; | |
1945 | |
23580
2230f9e10fb3
maint: Deprecate is_integer_type and replace with isinteger.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
1946 if (isinteger ()) |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1947 { |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1948 if (is_int32_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1949 retval = convert_to_int_array (int32_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1950 else if (is_int64_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1951 retval = convert_to_int_array (int64_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1952 else if (is_int16_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1953 retval = convert_to_int_array (int16_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1954 else if (is_int8_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1955 retval = convert_to_int_array (int8_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1956 else if (is_uint32_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1957 retval = convert_to_int_array (uint32_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1958 else if (is_uint64_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1959 retval = convert_to_int_array (uint64_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1960 else if (is_uint16_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1961 retval = convert_to_int_array (uint16_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1962 else if (is_uint8_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1963 retval = convert_to_int_array (uint8_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1964 else |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1965 retval = array_value (force_string_conv); |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1966 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1967 else |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1968 { |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1969 const NDArray a = array_value (force_string_conv); |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1970 |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1971 if (require_int) |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1972 { |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1973 retval.resize (a.dims ()); |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1974 for (octave_idx_type i = 0; i < a.numel (); i++) |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1975 { |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1976 double ai = a.elem (i); |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1977 int v = static_cast<int> (ai); |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1978 if (ai == v) |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1979 retval.xelem (i) = v; |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1980 else |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1981 { |
25927
d6581134daaa
Emit an error when utility matrices (zeros, ones, rand, etc.) are given a fractional dimension in a dimension vector (bug #54781).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
1982 error_with_cfn ("conversion of %g to int value failed", ai); |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1983 break; |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1984 } |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1985 } |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1986 } |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1987 else |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1988 retval = Array<int> (a); |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1989 } |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1990 |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1991 return retval.reshape (make_vector_dims (retval.dims (), |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1992 force_vector_conversion, |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1993 type_name (), "integer vector")); |
4044 | 1994 } |
1995 | |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21129
diff
changeset
|
1996 template <typename T> |
8811 | 1997 static Array<octave_idx_type> |
23534
b6498c088fca
maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents:
23502
diff
changeset
|
1998 convert_to_octave_idx_type_array (const Array<octave_int<T>>& A) |
8811 | 1999 { |
2000 Array<octave_idx_type> retval (A.dims ()); | |
2001 octave_idx_type n = A.numel (); | |
2002 | |
2003 for (octave_idx_type i = 0; i < n; i++) | |
2004 retval.xelem (i) = octave_int<octave_idx_type> (A.xelem (i)); | |
2005 | |
2006 return retval; | |
2007 } | |
2008 | |
2009 Array<octave_idx_type> | |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
2010 octave_value::octave_idx_type_vector_value (bool require_int, |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
2011 bool force_string_conv, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2012 bool force_vector_conversion) const |
8811 | 2013 { |
2014 Array<octave_idx_type> retval; | |
2015 | |
23580
2230f9e10fb3
maint: Deprecate is_integer_type and replace with isinteger.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
2016 if (isinteger ()) |
8811 | 2017 { |
2018 if (is_int32_type ()) | |
2019 retval = convert_to_octave_idx_type_array (int32_array_value ()); | |
2020 else if (is_int64_type ()) | |
2021 retval = convert_to_octave_idx_type_array (int64_array_value ()); | |
2022 else if (is_int16_type ()) | |
2023 retval = convert_to_octave_idx_type_array (int16_array_value ()); | |
2024 else if (is_int8_type ()) | |
2025 retval = convert_to_octave_idx_type_array (int8_array_value ()); | |
2026 else if (is_uint32_type ()) | |
2027 retval = convert_to_octave_idx_type_array (uint32_array_value ()); | |
2028 else if (is_uint64_type ()) | |
2029 retval = convert_to_octave_idx_type_array (uint64_array_value ()); | |
2030 else if (is_uint16_type ()) | |
2031 retval = convert_to_octave_idx_type_array (uint16_array_value ()); | |
2032 else if (is_uint8_type ()) | |
2033 retval = convert_to_octave_idx_type_array (uint8_array_value ()); | |
2034 else | |
2035 retval = array_value (force_string_conv); | |
2036 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2037 else |
8811 | 2038 { |
2039 const NDArray a = array_value (force_string_conv); | |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2040 |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2041 if (require_int) |
8811 | 2042 { |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2043 retval.resize (a.dims ()); |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2044 for (octave_idx_type i = 0; i < a.numel (); i++) |
8811 | 2045 { |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2046 double ai = a.elem (i); |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2047 octave_idx_type v = static_cast<octave_idx_type> (ai); |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2048 if (ai == v) |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2049 retval.xelem (i) = v; |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2050 else |
8811 | 2051 { |
25927
d6581134daaa
Emit an error when utility matrices (zeros, ones, rand, etc.) are given a fractional dimension in a dimension vector (bug #54781).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
2052 error_with_cfn ("conversion of %g to octave_idx_type value failed", ai); |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2053 break; |
8811 | 2054 } |
2055 } | |
2056 } | |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2057 else |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2058 retval = Array<octave_idx_type> (a); |
8811 | 2059 } |
2060 | |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2061 return retval.reshape (make_vector_dims (retval.dims (), |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2062 force_vector_conversion, |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2063 type_name (), "integer vector")); |
8811 | 2064 } |
2065 | |
3419 | 2066 Array<Complex> |
2376 | 2067 octave_value::complex_vector_value (bool force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
2068 bool force_vector_conversion) const |
2376 | 2069 { |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
2070 Array<Complex> retval = complex_array_value (force_string_conv); |
2376 | 2071 |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2072 return retval.reshape (make_vector_dims (retval.dims (), |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2073 force_vector_conversion, |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2074 type_name (), "complex vector")); |
2376 | 2075 } |
2076 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2077 FloatColumnVector |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2078 octave_value::float_column_vector_value (bool force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
2079 bool frc_vec_conv) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2080 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2081 return FloatColumnVector (float_vector_value (force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
2082 frc_vec_conv)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2083 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2084 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2085 FloatComplexColumnVector |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2086 octave_value::float_complex_column_vector_value (bool force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
2087 bool frc_vec_conv) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2088 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2089 return |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2090 FloatComplexColumnVector (float_complex_vector_value (force_string_conv, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2091 frc_vec_conv)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2092 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2093 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2094 FloatRowVector |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2095 octave_value::float_row_vector_value (bool force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
2096 bool frc_vec_conv) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2097 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2098 return FloatRowVector (float_vector_value (force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
2099 frc_vec_conv)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2100 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2101 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2102 FloatComplexRowVector |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2103 octave_value::float_complex_row_vector_value (bool force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
2104 bool frc_vec_conv) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2105 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2106 return FloatComplexRowVector (float_complex_vector_value (force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
2107 frc_vec_conv)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2108 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2109 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2110 Array<float> |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2111 octave_value::float_vector_value (bool force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
2112 bool force_vector_conversion) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2113 { |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
2114 Array<float> retval = float_array_value (force_string_conv); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2115 |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2116 return retval.reshape (make_vector_dims (retval.dims (), |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2117 force_vector_conversion, |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2118 type_name (), "real vector")); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2119 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2120 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2121 Array<FloatComplex> |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2122 octave_value::float_complex_vector_value (bool force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
2123 bool force_vector_conversion) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2124 { |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
2125 Array<FloatComplex> retval = float_complex_array_value (force_string_conv); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2126 |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2127 return retval.reshape (make_vector_dims (retval.dims (), |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2128 force_vector_conversion, |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2129 type_name (), "complex vector")); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2130 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2131 |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
2132 // NAME can't always be "x ## FCN" because some of the original |
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
2133 // value extraction functions perform implicit type conversions that we |
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
2134 // wish to avoid for these functions. |
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
2135 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2136 #define XVALUE_EXTRACTOR(TYPE, NAME, FCN) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2137 TYPE \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2138 octave_value::NAME (const char *fmt, ...) const \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2139 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2140 TYPE retval; \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2141 \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2142 try \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2143 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2144 retval = FCN (); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2145 } \ |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28975
diff
changeset
|
2146 catch (octave::execution_exception& ee) \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2147 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2148 if (fmt) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2149 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2150 va_list args; \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2151 va_start (args, fmt); \ |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28975
diff
changeset
|
2152 verror (ee, fmt, args); \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2153 va_end (args); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2154 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2155 \ |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28975
diff
changeset
|
2156 throw ee; \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2157 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2158 \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2159 return retval; \ |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
2160 } |
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
2161 |
20703
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2162 XVALUE_EXTRACTOR (short int, xshort_value, short_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2163 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2164 XVALUE_EXTRACTOR (unsigned short int, xushort_value, ushort_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2165 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2166 XVALUE_EXTRACTOR (int, xint_value, int_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2167 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2168 XVALUE_EXTRACTOR (unsigned int, xuint_value, uint_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2169 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2170 XVALUE_EXTRACTOR (int, xnint_value, nint_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2171 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2172 XVALUE_EXTRACTOR (long int, xlong_value, long_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2173 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2174 XVALUE_EXTRACTOR (unsigned long int, xulong_value, ulong_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2175 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2176 XVALUE_EXTRACTOR (int64_t, xint64_value, int64_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2177 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2178 XVALUE_EXTRACTOR (uint64_t, xuint64_value, uint64_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2179 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2180 XVALUE_EXTRACTOR (octave_idx_type, xidx_type_value, idx_type_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2181 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2182 XVALUE_EXTRACTOR (double, xdouble_value, double_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2183 XVALUE_EXTRACTOR (float, xfloat_value, float_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2184 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2185 XVALUE_EXTRACTOR (double, xscalar_value, scalar_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2186 XVALUE_EXTRACTOR (float, xfloat_scalar_value, float_scalar_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2187 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2188 XVALUE_EXTRACTOR (Matrix, xmatrix_value, matrix_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2189 XVALUE_EXTRACTOR (FloatMatrix, xfloat_matrix_value, float_matrix_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2190 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2191 XVALUE_EXTRACTOR (NDArray, xarray_value, array_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2192 XVALUE_EXTRACTOR (FloatNDArray, xfloat_array_value, float_array_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2193 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2194 XVALUE_EXTRACTOR (Complex, xcomplex_value, complex_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2195 XVALUE_EXTRACTOR (FloatComplex, xfloat_complex_value, float_complex_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2196 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2197 XVALUE_EXTRACTOR (ComplexMatrix, xcomplex_matrix_value, complex_matrix_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2198 XVALUE_EXTRACTOR (FloatComplexMatrix, xfloat_complex_matrix_value, float_complex_matrix_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2199 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2200 XVALUE_EXTRACTOR (ComplexNDArray, xcomplex_array_value, complex_array_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2201 XVALUE_EXTRACTOR (FloatComplexNDArray, xfloat_complex_array_value, float_complex_array_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2202 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2203 XVALUE_EXTRACTOR (bool, xbool_value, bool_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2204 XVALUE_EXTRACTOR (boolMatrix, xbool_matrix_value, bool_matrix_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2205 XVALUE_EXTRACTOR (boolNDArray, xbool_array_value, bool_array_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2206 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2207 XVALUE_EXTRACTOR (charMatrix, xchar_matrix_value, char_matrix_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2208 XVALUE_EXTRACTOR (charNDArray, xchar_array_value, char_array_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2209 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2210 XVALUE_EXTRACTOR (SparseMatrix, xsparse_matrix_value, sparse_matrix_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2211 XVALUE_EXTRACTOR (SparseComplexMatrix, xsparse_complex_matrix_value, sparse_complex_matrix_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2212 XVALUE_EXTRACTOR (SparseBoolMatrix, xsparse_bool_matrix_value, sparse_bool_matrix_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2213 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2214 XVALUE_EXTRACTOR (DiagMatrix, xdiag_matrix_value, diag_matrix_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2215 XVALUE_EXTRACTOR (FloatDiagMatrix, xfloat_diag_matrix_value, float_diag_matrix_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2216 XVALUE_EXTRACTOR (ComplexDiagMatrix, xcomplex_diag_matrix_value, complex_diag_matrix_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2217 XVALUE_EXTRACTOR (FloatComplexDiagMatrix, xfloat_complex_diag_matrix_value, float_complex_diag_matrix_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2218 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2219 XVALUE_EXTRACTOR (PermMatrix, xperm_matrix_value, perm_matrix_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2220 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2221 XVALUE_EXTRACTOR (octave_int8, xint8_scalar_value, int8_scalar_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2222 XVALUE_EXTRACTOR (octave_int16, xint16_scalar_value, int16_scalar_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2223 XVALUE_EXTRACTOR (octave_int32, xint32_scalar_value, int32_scalar_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2224 XVALUE_EXTRACTOR (octave_int64, xint64_scalar_value, int64_scalar_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2225 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2226 XVALUE_EXTRACTOR (octave_uint8, xuint8_scalar_value, uint8_scalar_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2227 XVALUE_EXTRACTOR (octave_uint16, xuint16_scalar_value, uint16_scalar_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2228 XVALUE_EXTRACTOR (octave_uint32, xuint32_scalar_value, uint32_scalar_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2229 XVALUE_EXTRACTOR (octave_uint64, xuint64_scalar_value, uint64_scalar_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2230 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2231 XVALUE_EXTRACTOR (int8NDArray, xint8_array_value, int8_array_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2232 XVALUE_EXTRACTOR (int16NDArray, xint16_array_value, int16_array_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2233 XVALUE_EXTRACTOR (int32NDArray, xint32_array_value, int32_array_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2234 XVALUE_EXTRACTOR (int64NDArray, xint64_array_value, int64_array_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2235 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2236 XVALUE_EXTRACTOR (uint8NDArray, xuint8_array_value, uint8_array_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2237 XVALUE_EXTRACTOR (uint16NDArray, xuint16_array_value, uint16_array_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2238 XVALUE_EXTRACTOR (uint32NDArray, xuint32_array_value, uint32_array_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2239 XVALUE_EXTRACTOR (uint64NDArray, xuint64_array_value, uint64_array_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2240 |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2241 XVALUE_EXTRACTOR (std::string, xstring_value, m_rep->xstring_value) |
20990
fc9cca99b2de
Deprecate all_strings, replace with string_vector_value.
Rik <rik@octave.org>
parents:
20978
diff
changeset
|
2242 XVALUE_EXTRACTOR (string_vector, xstring_vector_value, string_vector_value) |
20703
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2243 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2244 XVALUE_EXTRACTOR (Cell, xcell_value, cell_value) |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
2245 XVALUE_EXTRACTOR (Array<std::string>, xcellstr_value, cellstr_value) |
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
2246 |
30835
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
2247 XVALUE_EXTRACTOR (octave::range<double>, xrange_value, range_value) |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
2248 |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
2249 // For now, disable all but ov_range<double>. |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
2250 |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
2251 #if 0 |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
2252 |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
2253 XVALUE_EXTRACTOR (octave::range<float>, xfloat_range_value, float_range_value) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
2254 XVALUE_EXTRACTOR (octave::range<octave_int8>, xint8_range_value, int8_range_value) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
2255 XVALUE_EXTRACTOR (octave::range<octave_int16>, xint16_range_value, int16_range_value) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
2256 XVALUE_EXTRACTOR (octave::range<octave_int32>, xint32_range_value, int32_range_value) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
2257 XVALUE_EXTRACTOR (octave::range<octave_int64>, xint64_range_value, int64_range_value) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
2258 XVALUE_EXTRACTOR (octave::range<octave_uint8>, xuint8_range_value, uint8_range_value) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
2259 XVALUE_EXTRACTOR (octave::range<octave_uint16>, xuint16_range_value, uint16_range_value) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
2260 XVALUE_EXTRACTOR (octave::range<octave_uint32>, xuint32_range_value, uint32_range_value) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
2261 XVALUE_EXTRACTOR (octave::range<octave_uint64>, xuint64_range_value, uint64_range_value) |
20703
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2262 |
30835
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
2263 #endif |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
2264 |
20703
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2265 XVALUE_EXTRACTOR (octave_map, xmap_value, map_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2266 XVALUE_EXTRACTOR (octave_scalar_map, xscalar_map_value, scalar_map_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2267 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2268 XVALUE_EXTRACTOR (ColumnVector, xcolumn_vector_value, column_vector_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2269 XVALUE_EXTRACTOR (ComplexColumnVector, xcomplex_column_vector_value, complex_column_vector_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2270 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2271 XVALUE_EXTRACTOR (RowVector, xrow_vector_value, row_vector_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2272 XVALUE_EXTRACTOR (ComplexRowVector, xcomplex_row_vector_value, complex_row_vector_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2273 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2274 XVALUE_EXTRACTOR (FloatColumnVector, xfloat_column_vector_value, float_column_vector_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2275 XVALUE_EXTRACTOR (FloatComplexColumnVector, xfloat_complex_column_vector_value, float_complex_column_vector_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2276 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2277 XVALUE_EXTRACTOR (FloatRowVector, xfloat_row_vector_value, float_row_vector_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2278 XVALUE_EXTRACTOR (FloatComplexRowVector, xfloat_complex_row_vector_value, float_complex_row_vector_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2279 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2280 XVALUE_EXTRACTOR (Array<int>, xint_vector_value, int_vector_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2281 XVALUE_EXTRACTOR (Array<octave_idx_type>, xoctave_idx_type_vector_value, octave_idx_type_vector_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2282 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2283 XVALUE_EXTRACTOR (Array<double>, xvector_value, vector_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2284 XVALUE_EXTRACTOR (Array<Complex>, xcomplex_vector_value, complex_vector_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2285 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2286 XVALUE_EXTRACTOR (Array<float>, xfloat_vector_value, float_vector_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2287 XVALUE_EXTRACTOR (Array<FloatComplex>, xfloat_complex_vector_value, float_complex_vector_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2288 |
20741
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
2289 XVALUE_EXTRACTOR (octave_function *, xfunction_value, function_value) |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
2290 XVALUE_EXTRACTOR (octave_user_function *, xuser_function_value, user_function_value) |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
2291 XVALUE_EXTRACTOR (octave_user_script *, xuser_script_value, user_script_value) |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
2292 XVALUE_EXTRACTOR (octave_user_code *, xuser_code_value, user_code_value) |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
2293 XVALUE_EXTRACTOR (octave_fcn_handle *, xfcn_handle_value, fcn_handle_value) |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
2294 |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
2295 XVALUE_EXTRACTOR (octave_value_list, xlist_value, list_value) |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
2296 |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
2297 #undef XVALUE_EXTRACTOR |
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
2298 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2299 octave_value |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
2300 octave_value::storable_value (void) const |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2301 { |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
2302 octave_value retval = *this; |
23589
63950abd2f81
maint: Deprecate is_null_type and replace with isnull.
Rik <rik@octave.org>
parents:
23587
diff
changeset
|
2303 if (isnull ()) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2304 retval = octave_value (m_rep->empty_clone ()); |
28588
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
2305 else if (is_magic_int ()) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2306 retval = octave_value (m_rep->double_value ()); |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2307 else if (is_range () && ! m_rep->is_storable ()) |
29353
715344f405f0
improve handling of nan, infinite value, and empty ranges (bug #59229)
John W. Eaton <jwe@octave.org>
parents:
29163
diff
changeset
|
2308 error ("range with infinite number of elements cannot be stored"); |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2309 else |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
2310 retval.maybe_economize (); |
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
2311 |
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
2312 return retval; |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2313 } |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2314 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2315 void |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2316 octave_value::make_storable_value (void) |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2317 { |
23589
63950abd2f81
maint: Deprecate is_null_type and replace with isnull.
Rik <rik@octave.org>
parents:
23587
diff
changeset
|
2318 if (isnull ()) |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2319 { |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2320 octave_base_value *rc = m_rep->empty_clone (); |
30139
c789e728d57a
Backed out changeset 938794bc82b7
John W. Eaton <jwe@octave.org>
parents:
30133
diff
changeset
|
2321 if (--m_rep->count == 0) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2322 delete m_rep; |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2323 m_rep = rc; |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2324 } |
28588
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
2325 else if (is_magic_int ()) |
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
2326 { |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2327 octave_base_value *rc = new octave_scalar (m_rep->double_value ()); |
30139
c789e728d57a
Backed out changeset 938794bc82b7
John W. Eaton <jwe@octave.org>
parents:
30133
diff
changeset
|
2328 if (--m_rep->count == 0) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2329 delete m_rep; |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2330 m_rep = rc; |
28588
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
2331 } |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2332 else if (is_range () && ! m_rep->is_storable ()) |
29353
715344f405f0
improve handling of nan, infinite value, and empty ranges (bug #59229)
John W. Eaton <jwe@octave.org>
parents:
29163
diff
changeset
|
2333 error ("range with infinite number of elements cannot be stored"); |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
2334 else |
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
2335 maybe_economize (); |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2336 } |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2337 |
24668
d4dd741b2794
new octave_value functions for formatting output
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
2338 float_display_format |
d4dd741b2794
new octave_value functions for formatting output
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
2339 octave_value::get_edit_display_format (void) const |
d4dd741b2794
new octave_value functions for formatting output
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
2340 { |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2341 return m_rep->get_edit_display_format (); |
24668
d4dd741b2794
new octave_value functions for formatting output
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
2342 } |
d4dd741b2794
new octave_value functions for formatting output
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
2343 |
4944 | 2344 int |
23059
b98ebcd7f11c
move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2345 octave_value::write (octave::stream& os, int block_size, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2346 oct_data_conv::data_type output_type, int skip, |
21739
c4ab2e54f100
use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
2347 octave::mach_info::float_format flt_fmt) const |
4944 | 2348 { |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2349 return m_rep->write (os, block_size, output_type, skip, flt_fmt); |
4944 | 2350 } |
2351 | |
3933 | 2352 void |
2353 octave_value::print_info (std::ostream& os, const std::string& prefix) const | |
2354 { | |
2355 os << prefix << "type_name: " << type_name () << "\n" | |
30139
c789e728d57a
Backed out changeset 938794bc82b7
John W. Eaton <jwe@octave.org>
parents:
30133
diff
changeset
|
2356 << prefix << "count: " << get_count () << "\n" |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2357 << prefix << "m_rep info: "; |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2358 |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2359 m_rep->print_info (os, prefix + ' '); |
3933 | 2360 } |
2361 | |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2362 bool octave_value::load_ascii (std::istream& is) |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2363 { |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2364 bool status = m_rep->load_ascii (is); |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2365 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2366 // Force conversion of legacy objects. |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2367 if (is_legacy_object ()) |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2368 maybe_mutate (); |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2369 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2370 return status; |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2371 } |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2372 bool octave_value::load_binary (std::istream& is, bool swap, |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2373 octave::mach_info::float_format fmt) |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2374 { |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2375 bool status = m_rep->load_binary (is, swap, fmt); |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2376 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2377 // Force conversion of legacy objects. |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2378 if (is_legacy_object ()) |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2379 maybe_mutate (); |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2380 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2381 return status; |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2382 } |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2383 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2384 bool octave_value::load_hdf5 (octave_hdf5_id loc_id, const char *name) |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2385 { |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2386 bool status = m_rep->load_hdf5 (loc_id, name); |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2387 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2388 // Force conversion of legacy objects. |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2389 if (is_legacy_object ()) |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2390 maybe_mutate (); |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2391 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2392 return status; |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2393 } |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
2394 |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30142
diff
changeset
|
2395 const void * |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2396 octave_value::mex_get_data (mxClassID class_id, mxComplexity complexity) const |
3203 | 2397 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2398 // If class_id is set to mxUNKNOWN_CLASS, return data for any type. |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2399 // Otherwise, require that REP matches the requested type and |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2400 // complexity. |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2401 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2402 if (class_id != mxUNKNOWN_CLASS) |
3203 | 2403 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2404 bool type_ok = false; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2405 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2406 switch (class_id) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2407 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2408 case mxDOUBLE_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2409 type_ok = is_double_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2410 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2411 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2412 case mxSINGLE_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2413 type_ok = is_single_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2414 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2415 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2416 case mxINT8_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2417 type_ok = is_int8_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2418 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2419 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2420 case mxINT16_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2421 type_ok = is_int16_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2422 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2423 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2424 case mxINT32_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2425 type_ok = is_int32_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2426 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2427 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2428 case mxINT64_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2429 type_ok = is_int64_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2430 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2431 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2432 case mxUINT8_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2433 type_ok = is_uint8_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2434 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2435 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2436 case mxUINT16_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2437 type_ok = is_uint16_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2438 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2439 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2440 case mxUINT32_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2441 type_ok = is_uint32_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2442 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2443 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2444 case mxUINT64_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2445 type_ok = is_uint64_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2446 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2447 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2448 default: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2449 // We only expect to see numeric types explicitly requested. |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2450 error ("mex_get_data: unexpected type requested"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2451 } |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2452 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2453 if (! type_ok) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2454 error ("mex_get_data: type mismatch"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2455 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2456 if (complexity == mxCOMPLEX && ! iscomplex ()) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2457 error ("mex_get_data: objectis not complex as requested"); |
3203 | 2458 } |
2459 | |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2460 return m_rep->mex_get_data (); |
24565
dbec1e04f499
accept type_info obj as arg to binary_op, unary_op, and cat_op functions
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2461 } |
dbec1e04f499
accept type_info obj as arg to binary_op, unary_op, and cat_op functions
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2462 |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
2463 OCTAVE_NORETURN static void |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
2464 err_unary_op_conversion_failed (const std::string& op, |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
2465 const std::string& tn) |
3203 | 2466 { |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
15428
diff
changeset
|
2467 error ("operator %s: type conversion for '%s' failed", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2468 op.c_str (), tn.c_str ()); |
3203 | 2469 } |
2470 | |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2471 OCTAVE_NORETURN static void |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2472 err_unary_op (const std::string& on, const std::string& tn) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2473 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2474 error ("unary operator '%s' not implemented for '%s' operands", |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2475 on.c_str (), tn.c_str ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2476 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2477 |
10614
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2478 octave_value& |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2479 octave_value::non_const_unary_op (unary_op op) |
3203 | 2480 { |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2481 if (op == op_incr || op == op_decr) |
3203 | 2482 { |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
2483 // We want the error just here, because in the other branch this should |
10614
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2484 // not happen, and if it did anyway (internal error), the message would |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2485 // be confusing. |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2486 if (is_undefined ()) |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2487 { |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2488 std::string op_str = unary_op_as_string (op); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2489 error ("in x%s or %sx, x must be defined first", |
10614
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2490 op_str.c_str (), op_str.c_str ()); |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2491 return *this; |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2492 } |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2493 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2494 // Genuine. |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2495 int t = type_id (); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2496 |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30888
diff
changeset
|
2497 octave::type_info& ti = octave::__get_type_info__ (); |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
2498 |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
2499 octave::type_info::non_const_unary_op_fcn f |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
2500 = ti.lookup_non_const_unary_op (op, t); |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2501 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2502 if (f) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2503 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2504 make_unique (); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2505 |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2506 f (*m_rep); |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2507 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2508 else |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2509 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2510 octave_base_value::type_conv_fcn cf = numeric_conversion_function (); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2511 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2512 if (! cf) |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2513 err_unary_op (octave_value::unary_op_as_string (op), type_name ()); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2514 |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2515 octave_base_value *tmp = cf (*m_rep); |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2516 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2517 if (! tmp) |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2518 err_unary_op_conversion_failed |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2519 (octave_value::unary_op_as_string (op), type_name ()); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2520 |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2521 octave_base_value *old_rep = m_rep; |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2522 m_rep = tmp; |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2523 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2524 t = type_id (); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2525 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
2526 f = ti.lookup_non_const_unary_op (op, t); |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2527 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2528 if (f) |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2529 { |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2530 f (*m_rep); |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2531 |
30139
c789e728d57a
Backed out changeset 938794bc82b7
John W. Eaton <jwe@octave.org>
parents:
30133
diff
changeset
|
2532 if (old_rep && --old_rep->count == 0) |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2533 delete old_rep; |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2534 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2535 else |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2536 { |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2537 if (old_rep) |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2538 { |
30139
c789e728d57a
Backed out changeset 938794bc82b7
John W. Eaton <jwe@octave.org>
parents:
30133
diff
changeset
|
2539 if (--m_rep->count == 0) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2540 delete m_rep; |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2541 |
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2542 m_rep = old_rep; |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2543 } |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2544 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2545 err_unary_op (octave_value::unary_op_as_string (op), |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2546 type_name ()); |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2547 } |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2548 } |
3203 | 2549 } |
2550 else | |
2551 { | |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2552 // Non-genuine. |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2553 int t = type_id (); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2554 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
2555 octave::type_info::non_const_unary_op_fcn f = nullptr; |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2556 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2557 // Only attempt to operate in-place if this variable is unshared. |
30139
c789e728d57a
Backed out changeset 938794bc82b7
John W. Eaton <jwe@octave.org>
parents:
30133
diff
changeset
|
2558 if (m_rep->count == 1) |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
2559 { |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30888
diff
changeset
|
2560 octave::type_info& ti = octave::__get_type_info__ (); |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
2561 |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
2562 f = ti.lookup_non_const_unary_op (op, t); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
2563 } |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2564 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2565 if (f) |
30128
5616702bffac
maint: use "m_" prefix for member variable "m_rep" in class octave_value.
Rik <rik@octave.org>
parents:
30022
diff
changeset
|
2566 f (*m_rep); |
3203 | 2567 else |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2568 *this = octave::unary_op (op, *this); |
3203 | 2569 } |
3933 | 2570 |
2571 return *this; | |
3203 | 2572 } |
2573 | |
10614
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2574 octave_value& |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2575 octave_value::non_const_unary_op (unary_op op, const std::string& type, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2576 const std::list<octave_value_list>& idx) |
3933 | 2577 { |
2578 if (idx.empty ()) | |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2579 non_const_unary_op (op); |
3933 | 2580 else |
2581 { | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2582 // FIXME: only do the following stuff if we can't find a |
3933 | 2583 // specific function to call to handle the op= operation for the |
2584 // types we have. | |
3205 | 2585 |
3933 | 2586 assign_op assop = unary_op_to_assign_op (op); |
2587 | |
10614
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2588 assign (assop, type, idx, 1.0); |
3933 | 2589 } |
2590 | |
10614
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2591 return *this; |
3205 | 2592 } |
2593 | |
2594 octave_value::assign_op | |
2595 octave_value::unary_op_to_assign_op (unary_op op) | |
2596 { | |
2597 switch (op) | |
2598 { | |
3533 | 2599 case op_incr: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2600 return op_add_eq; |
3205 | 2601 |
3533 | 2602 case op_decr: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2603 return op_sub_eq; |
3205 | 2604 |
2605 default: | |
2606 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2607 std::string on = unary_op_as_string (op); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2608 error ("operator %s: no assign operator found", on.c_str ()); |
3205 | 2609 } |
2610 } | |
2611 } | |
2612 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2613 octave_value::binary_op |
3204 | 2614 octave_value::op_eq_to_binary_op (assign_op op) |
2615 { | |
2616 switch (op) | |
2617 { | |
3533 | 2618 case op_add_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2619 return op_add; |
3204 | 2620 |
3533 | 2621 case op_sub_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2622 return op_sub; |
3204 | 2623 |
3533 | 2624 case op_mul_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2625 return op_mul; |
3204 | 2626 |
3533 | 2627 case op_div_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2628 return op_div; |
3204 | 2629 |
3533 | 2630 case op_ldiv_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2631 return op_ldiv; |
3204 | 2632 |
4018 | 2633 case op_pow_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2634 return op_pow; |
3204 | 2635 |
3533 | 2636 case op_el_mul_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2637 return op_el_mul; |
3204 | 2638 |
3533 | 2639 case op_el_div_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2640 return op_el_div; |
3204 | 2641 |
3533 | 2642 case op_el_ldiv_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2643 return op_el_ldiv; |
3204 | 2644 |
4018 | 2645 case op_el_pow_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2646 return op_el_pow; |
4018 | 2647 |
3533 | 2648 case op_el_and_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2649 return op_el_and; |
3204 | 2650 |
3533 | 2651 case op_el_or_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2652 return op_el_or; |
3204 | 2653 |
2654 default: | |
2655 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2656 std::string on = assign_op_as_string (op); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2657 error ("operator %s: no binary operator found", on.c_str ()); |
3204 | 2658 } |
2659 } | |
2660 } | |
2661 | |
3933 | 2662 octave_value |
2663 octave_value::empty_conv (const std::string& type, const octave_value& rhs) | |
2664 { | |
2665 if (type.length () > 0) | |
2666 { | |
2667 switch (type[0]) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2668 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2669 case '(': |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2670 if (type.length () > 1 && type[1] == '.') |
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2671 return octave_map (); |
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2672 else |
21295
29a0e9e70879
* ov.h: Fix typo in previous change.
John W. Eaton <jwe@octave.org>
parents:
21294
diff
changeset
|
2673 return octave_value (rhs.empty_clone ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2674 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2675 case '{': |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2676 return Cell (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2677 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2678 case '.': |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2679 return octave_scalar_map (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2680 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2681 default: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2682 panic_impossible (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2683 } |
3933 | 2684 } |
2685 else | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2686 return octave_value (rhs.empty_clone ()); |
3933 | 2687 } |
2688 | |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31155
diff
changeset
|
2689 OCTAVE_BEGIN_NAMESPACE(octave) |
29960
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
2690 |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2691 OCTAVE_NORETURN static void |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2692 err_binary_op (const std::string& on, const std::string& tn1, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2693 const std::string& tn2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2694 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2695 error ("binary operator '%s' not implemented for '%s' by '%s' operations", |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2696 on.c_str (), tn1.c_str (), tn2.c_str ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2697 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2698 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2699 OCTAVE_NORETURN static void |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2700 err_binary_op_conv (const std::string& on) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2701 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2702 error ("type conversion failed for binary operator '%s'", on.c_str ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2703 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2704 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2705 octave_value |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2706 binary_op (type_info& ti, octave_value::binary_op op, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2707 const octave_value& v1, const octave_value& v2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2708 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2709 octave_value retval; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2710 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2711 int t1 = v1.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2712 int t2 = v2.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2713 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2714 if (t1 == octave_class::static_type_id () |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2715 || t2 == octave_class::static_type_id () |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2716 || t1 == octave_classdef::static_type_id () |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2717 || t2 == octave_classdef::static_type_id ()) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2718 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2719 type_info::binary_class_op_fcn f = ti.lookup_binary_class_op (op); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2720 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2721 if (! f) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2722 err_binary_op (octave_value::binary_op_as_string (op), |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2723 v1.class_name (), v2.class_name ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2724 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2725 retval = f (v1, v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2726 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2727 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2728 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2729 // FIXME: we need to handle overloading operators for built-in |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2730 // classes (double, char, int8, etc.) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2731 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2732 type_info::binary_op_fcn f |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2733 = ti.lookup_binary_op (op, t1, t2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2734 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2735 if (f) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2736 retval = f (v1.get_rep (), v2.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2737 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2738 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2739 octave_value tv1; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2740 octave_base_value::type_conv_info cf1 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2741 = v1.numeric_conversion_function (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2742 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2743 octave_value tv2; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2744 octave_base_value::type_conv_info cf2 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2745 = v2.numeric_conversion_function (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2746 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2747 // Try biased (one-sided) conversions first. |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2748 if (cf2.type_id () >= 0 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2749 && ti.lookup_binary_op (op, t1, cf2.type_id ())) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2750 cf1 = nullptr; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2751 else if (cf1.type_id () >= 0 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2752 && ti.lookup_binary_op (op, cf1.type_id (), t2)) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2753 cf2 = nullptr; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2754 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2755 if (cf1) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2756 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2757 octave_base_value *tmp = cf1 (v1.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2758 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2759 if (! tmp) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2760 err_binary_op_conv (octave_value::binary_op_as_string (op)); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2761 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2762 tv1 = octave_value (tmp); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2763 t1 = tv1.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2764 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2765 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2766 tv1 = v1; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2767 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2768 if (cf2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2769 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2770 octave_base_value *tmp = cf2 (v2.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2771 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2772 if (! tmp) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2773 err_binary_op_conv (octave_value::binary_op_as_string (op)); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2774 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2775 tv2 = octave_value (tmp); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2776 t2 = tv2.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2777 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2778 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2779 tv2 = v2; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2780 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2781 if (cf1 || cf2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2782 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2783 retval = binary_op (op, tv1, tv2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2784 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2785 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2786 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2787 //demote double -> single and try again |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2788 cf1 = tv1.numeric_demotion_function (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2789 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2790 cf2 = tv2.numeric_demotion_function (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2791 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2792 // Try biased (one-sided) conversions first. |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2793 if (cf2.type_id () >= 0 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2794 && ti.lookup_binary_op (op, t1, cf2.type_id ())) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2795 cf1 = nullptr; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2796 else if (cf1.type_id () >= 0 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2797 && ti.lookup_binary_op (op, cf1.type_id (), t2)) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2798 cf2 = nullptr; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2799 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2800 if (cf1) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2801 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2802 octave_base_value *tmp = cf1 (tv1.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2803 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2804 if (! tmp) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2805 err_binary_op_conv (octave_value::binary_op_as_string (op)); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2806 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2807 tv1 = octave_value (tmp); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2808 t1 = tv1.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2809 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2810 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2811 if (cf2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2812 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2813 octave_base_value *tmp = cf2 (tv2.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2814 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2815 if (! tmp) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2816 err_binary_op_conv (octave_value::binary_op_as_string (op)); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2817 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2818 tv2 = octave_value (tmp); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2819 t2 = tv2.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2820 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2821 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2822 if (! cf1 && ! cf2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2823 err_binary_op (octave_value::binary_op_as_string (op), |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2824 v1.type_name (), v2.type_name ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2825 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2826 f = ti.lookup_binary_op (op, t1, t2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2827 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2828 if (! f) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2829 err_binary_op (octave_value::binary_op_as_string (op), |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2830 v1.type_name (), v2.type_name ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2831 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2832 retval = f (tv1.get_rep (), tv2.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2833 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2834 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2835 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2836 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2837 return retval; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2838 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2839 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2840 octave_value |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2841 binary_op (octave_value::binary_op op, const octave_value& v1, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2842 const octave_value& v2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2843 { |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30888
diff
changeset
|
2844 type_info& ti = __get_type_info__ (); |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2845 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2846 return binary_op (ti, op, v1, v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2847 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2848 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2849 static octave_value |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2850 decompose_binary_op (type_info& ti, octave_value::compound_binary_op op, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2851 const octave_value& v1, const octave_value& v2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2852 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2853 switch (op) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2854 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2855 case octave_value::op_trans_mul: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2856 return binary_op (octave_value::op_mul, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2857 unary_op (octave_value::op_transpose, v1), v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2858 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2859 case octave_value::op_mul_trans: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2860 return binary_op (ti, octave_value::op_mul, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2861 v1, unary_op (octave_value::op_transpose, v2)); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2862 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2863 case octave_value::op_herm_mul: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2864 return binary_op (ti, octave_value::op_mul, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2865 unary_op (octave_value::op_hermitian, v1), v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2866 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2867 case octave_value::op_mul_herm: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2868 return binary_op (ti, octave_value::op_mul, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2869 v1, unary_op (octave_value::op_hermitian, v2)); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2870 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2871 case octave_value::op_trans_ldiv: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2872 return binary_op (ti, octave_value::op_ldiv, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2873 unary_op (octave_value::op_transpose, v1), v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2874 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2875 case octave_value::op_herm_ldiv: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2876 return binary_op (ti, octave_value::op_ldiv, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2877 unary_op (octave_value::op_hermitian, v1), v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2878 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2879 case octave_value::op_el_not_and: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2880 return binary_op (ti, octave_value::op_el_and, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2881 unary_op (octave_value::op_not, v1), v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2882 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2883 case octave_value::op_el_not_or: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2884 return binary_op (ti, octave_value::op_el_or, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2885 unary_op (octave_value::op_not, v1), v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2886 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2887 case octave_value::op_el_and_not: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2888 return binary_op (ti, octave_value::op_el_and, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2889 v1, unary_op (octave_value::op_not, v2)); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2890 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2891 case octave_value::op_el_or_not: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2892 return binary_op (ti, octave_value::op_el_or, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2893 v1, unary_op (octave_value::op_not, v2)); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2894 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2895 default: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2896 error ("invalid compound operator"); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2897 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2898 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2899 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2900 octave_value |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2901 binary_op (type_info& ti, octave_value::compound_binary_op op, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2902 const octave_value& v1, const octave_value& v2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2903 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2904 octave_value retval; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2905 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2906 int t1 = v1.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2907 int t2 = v2.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2908 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2909 if (t1 == octave_class::static_type_id () |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2910 || t2 == octave_class::static_type_id () |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2911 || t1 == octave_classdef::static_type_id () |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2912 || t2 == octave_classdef::static_type_id ()) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2913 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2914 type_info::binary_class_op_fcn f = ti.lookup_binary_class_op (op); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2915 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2916 if (f) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2917 retval = f (v1, v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2918 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2919 retval = decompose_binary_op (ti, op, v1, v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2920 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2921 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2922 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2923 type_info::binary_op_fcn f = ti.lookup_binary_op (op, t1, t2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2924 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2925 if (f) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2926 retval = f (v1.get_rep (), v2.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2927 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2928 retval = decompose_binary_op (ti, op, v1, v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2929 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2930 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2931 return retval; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2932 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2933 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2934 octave_value |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2935 binary_op (octave_value::compound_binary_op op, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2936 const octave_value& v1, const octave_value& v2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2937 { |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30888
diff
changeset
|
2938 type_info& ti = __get_type_info__ (); |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2939 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2940 return binary_op (ti, op, v1, v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2941 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2942 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2943 OCTAVE_NORETURN static void |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2944 err_cat_op (const std::string& tn1, const std::string& tn2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2945 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2946 error ("concatenation operator not implemented for '%s' by '%s' operations", |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2947 tn1.c_str (), tn2.c_str ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2948 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2949 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2950 OCTAVE_NORETURN static void |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2951 err_cat_op_conv (void) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2952 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2953 error ("type conversion failed for concatenation operator"); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2954 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2955 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2956 octave_value |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2957 cat_op (type_info& ti, const octave_value& v1, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2958 const octave_value& v2, const Array<octave_idx_type>& ra_idx) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2959 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2960 octave_value retval; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2961 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2962 // Can't rapid return for concatenation with an empty object here as |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2963 // something like cat(1,[],single([]) must return the correct type. |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2964 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2965 int t1 = v1.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2966 int t2 = v2.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2967 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2968 type_info::cat_op_fcn f = ti.lookup_cat_op (t1, t2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2969 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2970 if (f) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2971 retval = f (v1.get_rep (), v2.get_rep (), ra_idx); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2972 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2973 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2974 octave_value tv1; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2975 octave_base_value::type_conv_info cf1 = v1.numeric_conversion_function (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2976 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2977 octave_value tv2; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2978 octave_base_value::type_conv_info cf2 = v2.numeric_conversion_function (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2979 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2980 // Try biased (one-sided) conversions first. |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2981 if (cf2.type_id () >= 0 && ti.lookup_cat_op (t1, cf2.type_id ())) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2982 cf1 = nullptr; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2983 else if (cf1.type_id () >= 0 && ti.lookup_cat_op (cf1.type_id (), t2)) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2984 cf2 = nullptr; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2985 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2986 if (cf1) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2987 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2988 octave_base_value *tmp = cf1 (v1.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2989 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2990 if (! tmp) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2991 err_cat_op_conv (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2992 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2993 tv1 = octave_value (tmp); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2994 t1 = tv1.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2995 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2996 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2997 tv1 = v1; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2998 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2999 if (cf2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3000 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3001 octave_base_value *tmp = cf2 (v2.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3002 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3003 if (! tmp) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3004 err_cat_op_conv (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3005 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3006 tv2 = octave_value (tmp); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3007 t2 = tv2.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3008 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3009 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3010 tv2 = v2; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3011 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3012 if (! cf1 && ! cf2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3013 err_cat_op (v1.type_name (), v2.type_name ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3014 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3015 retval = cat_op (ti, tv1, tv2, ra_idx); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3016 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3017 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3018 return retval; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3019 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3020 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3021 octave_value |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3022 cat_op (const octave_value& v1, const octave_value& v2, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3023 const Array<octave_idx_type>& ra_idx) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3024 { |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30888
diff
changeset
|
3025 type_info& ti = __get_type_info__ (); |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3026 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3027 return cat_op (ti, v1, v2, ra_idx); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3028 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3029 |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3030 // Unless the colon operator is used with a class or classdef object, |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3031 // then all arguments must be the same type or mixed with double |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3032 // values. |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3033 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3034 static builtin_type_t |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3035 get_colon_op_type (builtin_type_t op1_type, builtin_type_t op2_type) |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3036 { |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3037 if (op1_type == op2_type) |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3038 return op1_type; |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3039 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3040 if (op1_type == btyp_double) |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3041 return op2_type; |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3042 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3043 if (op2_type == btyp_double) |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3044 return op1_type; |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3045 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3046 return btyp_unknown; |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3047 } |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3048 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3049 static builtin_type_t |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3050 get_colon_op_type (const octave_value& base, const octave_value& increment, |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3051 const octave_value& limit) |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3052 { |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3053 builtin_type_t typ |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3054 = get_colon_op_type (base.builtin_type (), increment.builtin_type ()); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3055 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3056 if (typ == btyp_unknown) |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3057 return typ; |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3058 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3059 return get_colon_op_type (typ, limit.builtin_type ()); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3060 } |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3061 |
30142
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
3062 // This check depends on the type of VAL either being the expected |
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
3063 // integer type or a double value. |
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
3064 |
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
3065 template <typename T> |
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
3066 static void |
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
3067 check_colon_operand (const octave_value& val, const char *op_str) |
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
3068 { |
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
3069 if (! val.is_double_type ()) |
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
3070 return; |
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
3071 |
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
3072 double dval = val.double_value (); |
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
3073 double intpart; |
30867
014030798d5e
Avoid issues when converting large integers to floating point (bug #62212).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30859
diff
changeset
|
3074 static const double out_of_range_top |
014030798d5e
Avoid issues when converting large integers to floating point (bug #62212).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30859
diff
changeset
|
3075 = static_cast<double> (std::numeric_limits<typename T::val_type>::max ()) |
014030798d5e
Avoid issues when converting large integers to floating point (bug #62212).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30859
diff
changeset
|
3076 + 1.; |
014030798d5e
Avoid issues when converting large integers to floating point (bug #62212).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30859
diff
changeset
|
3077 |
014030798d5e
Avoid issues when converting large integers to floating point (bug #62212).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30859
diff
changeset
|
3078 if (dval >= out_of_range_top |
30142
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
3079 || dval < std::numeric_limits<typename T::val_type>::min () |
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
3080 || std::modf (dval, &intpart) != 0.0) |
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
3081 error ("colon operator %s invalid (not an integer or out of range for given integer type)", op_str); |
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
3082 } |
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
3083 |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3084 // Return the difference between two unsigned integers as an unsigned |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3085 // integer of the same type. |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3086 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3087 template <typename UT, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3088 typename std::enable_if<(std::is_integral<UT>::value |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3089 && std::is_unsigned<UT>::value), |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3090 bool>::type = true> |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3091 UT |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3092 integer_difference (UT a, UT b) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3093 { |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3094 return a > b ? a - b : b - a; |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3095 } |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3096 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3097 // Return the difference between two signed integers as an unsigned |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3098 // integer corresponding to the signed type. |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3099 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3100 template <typename ST, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3101 typename UT = typename std::make_unsigned<ST>::type, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3102 typename std::enable_if<(std::is_integral<ST>::value |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3103 && std::is_signed<ST>::value), |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3104 bool>::type = true> |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3105 UT |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3106 integer_difference (ST a, ST b) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3107 { |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3108 // Map to unsigned. |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3109 // Idea from https://stackoverflow.com/questions/10589559 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3110 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3111 static const UT offset |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3112 = UT (0) - static_cast<UT> (std::numeric_limits<ST>::min ()); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3113 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3114 UT au = static_cast<UT> (a) + offset; |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3115 UT bu = static_cast<UT> (b) + offset; |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3116 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3117 return integer_difference (au, bu); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3118 } |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3119 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3120 // Number of elements in an integer range taking care to avoid |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3121 // overflow. Base and limit are of the same type. If they are |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3122 // unsigned, then increment is also of the same type. If they are |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3123 // signed, then the type of increment is the unsigned type |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3124 // corresponding to T. Assumes that the base and limit values are |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3125 // consistent with the sign of the original increment (not an empty |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3126 // range) so we can calculate numel with the absolute value of the |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3127 // increment and the absolute difference between the base and limit |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3128 // values. |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3129 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3130 template <typename T, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3131 typename UT = typename std::make_unsigned<T>::type, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3132 typename std::enable_if<std::is_integral<T>::value, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3133 bool>::type = true> |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3134 octave_idx_type |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3135 range_numel_aux (T base, UT unsigned_increment, T limit) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3136 { |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3137 // Adding one to DIFF/INCREMENT may overflow, so check whether it is |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3138 // out of range before adding. |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3139 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3140 UT nel_m1 = integer_difference (limit, base) / unsigned_increment; |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3141 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3142 // FIXME: fix error message. |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3143 if (nel_m1 > std::numeric_limits<octave_idx_type>::max () - 1) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3144 error ("too many elements for range!"); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3145 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3146 return static_cast<octave_idx_type> (nel_m1) + 1; |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3147 } |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3148 |
30839
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3149 // Convert signed range increment to unsigned. |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3150 |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3151 template <typename ST, |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3152 typename UT = typename std::make_unsigned<ST>::type, |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3153 typename std::enable_if<(std::is_integral<ST>::value |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3154 && std::is_signed<ST>::value), |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3155 bool>::type = true> |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3156 UT |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3157 range_increment (ST increment) |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3158 { |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3159 return (increment < 0 |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3160 ? UT (0) - static_cast<UT> (increment) |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3161 : static_cast<UT> (increment)); |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3162 } |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3163 |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3164 // "Convert" unsigned range increment to unsigned. A no-op, but |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3165 // needed to provide a consistent interface for other template |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3166 // functions. |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3167 |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3168 template <typename T, |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3169 typename UT = typename std::make_unsigned<T>::type, |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3170 typename std::enable_if<(std::is_integral<UT>::value |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3171 && std::is_unsigned<UT>::value), |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3172 bool>::type = true> |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3173 UT |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3174 range_increment (UT increment) |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3175 { |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3176 return increment; |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3177 } |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3178 |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3179 // Convert double range increment to unsigned. Enable by return type. |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3180 |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3181 template <typename T, |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3182 typename UT = typename std::make_unsigned<T>::type> |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3183 typename std::enable_if<(std::is_integral<UT>::value |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3184 && std::is_unsigned<UT>::value), UT>::type |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3185 range_increment (double increment) |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3186 { |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3187 double abs_increment = std::abs (increment); |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3188 |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3189 return static_cast<UT> (abs_increment); |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3190 } |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3191 |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3192 // Number of elements in an integer range base:increment:limit. Base, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3193 // increment, and limit are of the same signed type. |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3194 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3195 template <typename ST, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3196 typename std::enable_if<(std::is_integral<ST>::value |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3197 && std::is_signed<ST>::value), |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3198 bool>::type = true> |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3199 octave_idx_type |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3200 range_numel (ST base, ST increment, ST limit) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3201 { |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3202 typedef typename std::make_unsigned<ST>::type UT; |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3203 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3204 if (increment == 0 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3205 || (increment > 0 && base > limit) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3206 || (increment < 0 && base < limit)) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3207 return 0; |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3208 |
30839
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3209 UT unsigned_increment = range_increment<ST> (increment); |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3210 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3211 return range_numel_aux (base, unsigned_increment, limit); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3212 } |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3213 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3214 // Number of elements in an integer range base:increment:limit. Base, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3215 // increment, and limit are unsigned and of the same type. |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3216 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3217 template <typename UT, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3218 typename std::enable_if<(std::is_integral<UT>::value |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3219 && std::is_unsigned<UT>::value), |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3220 bool>::type = true> |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3221 octave_idx_type |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3222 range_numel (UT base, UT increment, UT limit) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3223 { |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3224 // Unsigned, INCREMENT is always >= 0. |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3225 if (increment == 0 || base > limit) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3226 return 0; |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3227 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3228 return range_numel_aux (base, increment, limit); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3229 } |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3230 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3231 // Number of elements in an integer range base:increment:limit. Base |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3232 // and limit are of the same type and increment is a double value. |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3233 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3234 template <typename T, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3235 typename UT = typename std::make_unsigned<T>::type, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3236 typename std::enable_if<std::is_integral<T>::value, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3237 bool>::type = true> |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3238 octave_idx_type |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3239 range_numel (T base, double increment, T limit) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3240 { |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3241 double intpart; |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3242 if (math::isnan (increment) || std::modf (increment, &intpart) != 0.0) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3243 error ("colon operator increment invalid (not an integer)"); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3244 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3245 if (increment == 0 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3246 || (increment > 0 && base > limit) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3247 || (increment < 0 && base < limit)) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3248 return 0; |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3249 |
30867
014030798d5e
Avoid issues when converting large integers to floating point (bug #62212).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30859
diff
changeset
|
3250 static const double out_of_range_top |
014030798d5e
Avoid issues when converting large integers to floating point (bug #62212).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30859
diff
changeset
|
3251 = static_cast<double> (std::numeric_limits<UT>::max ()) + 1.; |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3252 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3253 double abs_increment = std::abs (increment); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3254 |
30867
014030798d5e
Avoid issues when converting large integers to floating point (bug #62212).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30859
diff
changeset
|
3255 // Technically, this condition should be |
014030798d5e
Avoid issues when converting large integers to floating point (bug #62212).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30859
diff
changeset
|
3256 // `abs_increment > std::numeric_limits<UT>::max ()`. |
30859
df26decca96b
Tweak check for maximum possible increment of integer ranges (bug #62212).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30855
diff
changeset
|
3257 // But intmax('uint64') is not representable exactly as floating point |
df26decca96b
Tweak check for maximum possible increment of integer ranges (bug #62212).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30855
diff
changeset
|
3258 // number. Instead, it "rounds" up by 1 to 2^64. To account for |
df26decca96b
Tweak check for maximum possible increment of integer ranges (bug #62212).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30855
diff
changeset
|
3259 // this, use the following expression which works for all unsigned |
df26decca96b
Tweak check for maximum possible increment of integer ranges (bug #62212).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30855
diff
changeset
|
3260 // integer types. |
30867
014030798d5e
Avoid issues when converting large integers to floating point (bug #62212).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30859
diff
changeset
|
3261 if (abs_increment >= out_of_range_top) |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3262 return 1; |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3263 |
30839
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3264 UT unsigned_increment = range_increment<T> (increment); |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3265 |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3266 return range_numel_aux (base, unsigned_increment, limit); |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3267 } |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3268 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3269 // Make a range from integer values. Increment may be integer or double. |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3270 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3271 template <typename T, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3272 typename IT, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3273 typename std::enable_if<(std::is_integral<T>::value |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3274 && std::is_arithmetic<IT>::value), |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3275 bool>::type = true> |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3276 octave_value |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3277 make_int_range (T base, IT increment, T limit) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3278 { |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3279 octave_idx_type nel = range_numel (base, increment, limit); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3280 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3281 // For now, we create arrays instead of range<T> for all types |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3282 // except double. |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3283 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3284 Array<octave_int<T>> result (dim_vector (1, nel)); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3285 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3286 if (nel > 0) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3287 { |
30839
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3288 typedef typename std::make_unsigned<T>::type UT; |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3289 |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3290 UT unsigned_increment = range_increment<T> (increment); |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3291 |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3292 T val = base; |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3293 result.xelem (0) = val; |
30839
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3294 |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3295 if (limit > base) |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3296 { |
30839
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3297 for (octave_idx_type i = 1; i < nel; i++) |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3298 { |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3299 val += unsigned_increment; |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3300 result.xelem (i) = val; |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3301 } |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3302 } |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3303 else |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3304 { |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3305 for (octave_idx_type i = 1; i < nel; i++) |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3306 { |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3307 val -= unsigned_increment; |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3308 result.xelem (i) = val; |
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3309 } |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3310 } |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3311 } |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3312 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3313 return octave_value (result); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3314 } |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3315 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3316 // Make a range from floating point values. |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3317 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3318 // FIXME: Try again to define memory efficient range classes for |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3319 // integer and floating point values? Maybe with the templates |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3320 // defined in this file we could do that in a reasonable way? |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3321 // Regardless of that, it might be good to provide special treatment |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3322 // of colon expressions in FOR loops so that we can eliminate the |
30839
1a4a3ba925c8
don't use double precision increment when computing integer range values
John W. Eaton <jwe@octave.org>
parents:
30835
diff
changeset
|
3323 // "is_for_cmd_expr / force_range" flag from the parser and the |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3324 // octave_value constructors for range objects. |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3325 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3326 // NOTE: We define this function separately for float and double so |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3327 // that we can avoid having to instantiate ov_range<float>. We DO |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3328 // instantiate range<float> but only so we can take advantage of the |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3329 // range<T> class to generate the corresponding array of float values |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3330 // and not have to duplicate that code here. |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3331 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3332 template <typename T, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3333 typename std::enable_if<std::is_same<T, double>::value, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3334 bool>::type = true> |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3335 octave_value |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3336 make_float_range (T base, T increment, T limit, bool is_for_cmd_expr) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3337 { |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3338 if (math::isnan (base) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3339 || math::isnan (increment) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3340 || math::isnan (limit)) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3341 return octave_value (numeric_limits<T>::NaN ()); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3342 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3343 if (increment == 0 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3344 || (increment > 0 && base > limit) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3345 || (increment < 0 && base < limit)) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3346 return octave_value (Array<T> (dim_vector (1, 0))); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3347 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3348 // At this point, we know that the base and limit values are |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3349 // consistent with the sign of the increment (not an empty range). |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3350 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3351 range<T> r (base, increment, limit); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3352 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3353 if (! is_for_cmd_expr && ! r.is_storable ()) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3354 error ("range with infinite number of elements cannot be stored"); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3355 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3356 return octave_value (r, is_for_cmd_expr); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3357 } |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3358 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3359 template <typename T, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3360 typename std::enable_if<std::is_same<T, float>::value, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3361 bool>::type = true> |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3362 octave_value |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3363 make_float_range (T base, T increment, T limit, bool is_for_cmd_expr) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3364 { |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3365 if (math::isnan (base) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3366 || math::isnan (increment) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3367 || math::isnan (limit)) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3368 return octave_value (numeric_limits<T>::NaN ()); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3369 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3370 if (increment == 0 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3371 || (increment > 0 && base > limit) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3372 || (increment < 0 && base < limit)) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3373 return octave_value (Array<T> (dim_vector (1, 0))); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3374 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3375 // At this point, we know that the base and limit values are |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3376 // consistent with the sign of the increment (not an empty range). |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3377 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3378 range<T> r (base, increment, limit); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3379 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3380 if (! is_for_cmd_expr && ! r.is_storable ()) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3381 error ("range with infinite number of elements cannot be stored"); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3382 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3383 return octave_value (r.array_value ()); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3384 } |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3385 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3386 template <typename T, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3387 typename std::enable_if<(std::is_same<T, octave_int8>::value |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3388 || std::is_same<T, octave_uint8>::value |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3389 || std::is_same<T, octave_int16>::value |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3390 || std::is_same<T, octave_uint16>::value |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3391 || std::is_same<T, octave_int32>::value |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3392 || std::is_same<T, octave_uint32>::value |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3393 || std::is_same<T, octave_int64>::value |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3394 || std::is_same<T, octave_uint64>::value), |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3395 bool>::type = true> |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3396 octave_value |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3397 make_int_range (const octave_value& base, const octave_value& increment, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3398 const octave_value& limit) |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3399 { |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3400 if (base.isempty () || increment.isempty () || limit.isempty ()) |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3401 return octave_value (Array<T> (dim_vector (1, 0))); |
30423
e658f400a30e
Fix possible lifetime issue (bug #61132).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30416
diff
changeset
|
3402 |
30142
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
3403 check_colon_operand<T> (base, "lower bound"); |
a4d1c080e445
fix construction of ranges with extreme integer values (bug #61132)
John W. Eaton <jwe@octave.org>
parents:
30139
diff
changeset
|
3404 check_colon_operand<T> (limit, "upper bound"); |
29410
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3405 |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3406 typename T::val_type base_val = octave_value_extract<T> (base).value (); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3407 typename T::val_type limit_val = octave_value_extract<T> (limit).value (); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3408 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3409 if (increment.is_double_type ()) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3410 { |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3411 double increment_val = increment.double_value (); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3412 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3413 return make_int_range (base_val, increment_val, limit_val); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3414 } |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3415 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3416 check_colon_operand<T> (increment, "increment"); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3417 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3418 typename T::val_type increment_val |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3419 = octave_value_extract<T> (increment).value (); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3420 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3421 return make_int_range (base_val, increment_val, limit_val); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3422 } |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3423 |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3424 template <typename T, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3425 typename std::enable_if<std::is_floating_point<T>::value, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3426 bool>::type = true> |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3427 octave_value |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3428 make_float_range (const octave_value& base, const octave_value& increment, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3429 const octave_value& limit, bool is_for_cmd_expr) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3430 { |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3431 if (base.isempty () || increment.isempty () || limit.isempty ()) |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3432 return octave_value (Array<T> (dim_vector (1, 0))); |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3433 |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3434 T base_val = octave_value_extract<T> (base); |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3435 T increment_val = octave_value_extract<T> (increment); |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3436 T limit_val = octave_value_extract<T> (limit); |
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3437 |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3438 return make_float_range (base_val, increment_val, limit_val, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3439 is_for_cmd_expr); |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3440 } |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3441 |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3442 |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3443 octave_value |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3444 make_char_range (const octave_value& base, const octave_value& increment, |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3445 const octave_value& limit) |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3446 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3447 octave_value retval; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3448 |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3449 bool dq_str = (base.is_dq_string () || increment.is_dq_string () |
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3450 || limit.is_dq_string ()); |
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3451 |
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3452 char type = dq_str ? '"' : '\''; |
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3453 |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3454 if (base.isempty () || increment.isempty () || limit.isempty ()) |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3455 retval = octave_value ("", type); |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3456 else |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3457 { |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3458 Matrix mtx_base = base.matrix_value (true); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3459 Matrix mtx_increment = increment.matrix_value (true); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3460 Matrix mtx_limit = limit.matrix_value (true); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3461 |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3462 range<double> tmp (mtx_base(0), mtx_increment(0), mtx_limit(0)); |
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3463 |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3464 retval = octave_value (tmp); |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3465 } |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3466 |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3467 return retval.convert_to_str (false, true, type); |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3468 } |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3469 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3470 octave_value |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3471 colon_op (const octave_value& base, const octave_value& increment_arg, |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3472 const octave_value& limit, bool is_for_cmd_expr) |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3473 { |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3474 if (base.isobject () || increment_arg.isobject () || limit.isobject ()) |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3475 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3476 octave_value_list tmp1; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3477 |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3478 if (increment_arg.is_defined ()) |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3479 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3480 tmp1(2) = limit; |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3481 tmp1(1) = increment_arg; |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3482 tmp1(0) = base; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3483 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3484 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3485 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3486 tmp1(1) = limit; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3487 tmp1(0) = base; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3488 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3489 |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30888
diff
changeset
|
3490 interpreter& interp = __get_interpreter__ (); |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3491 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3492 symbol_table& symtab = interp.get_symbol_table (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3493 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3494 octave_value fcn = symtab.find_function ("colon", tmp1); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3495 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3496 if (fcn.is_defined ()) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3497 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3498 octave_value_list tmp2 = interp.feval (fcn, tmp1, 1); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3499 |
29410
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3500 return tmp2(0); |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3501 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3502 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3503 |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3504 octave_value increment |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3505 = increment_arg.is_defined () ? increment_arg : octave_value (1.0); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3506 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3507 if (base.numel () > 1 || limit.numel () > 1 || increment.numel () > 1) |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3508 warning_with_id ("Octave:colon-nonscalar-argument", |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3509 "colon arguments should be scalars"); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3510 |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3511 if (base.iscomplex () || limit.iscomplex () || increment.iscomplex ()) |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3512 warning_with_id ("Octave:colon-complex-argument", |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3513 "imaginary part of complex colon arguments is ignored"); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3514 |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3515 // FIXME: is there a better way to do this job, maybe using type traits? |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3516 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3517 builtin_type_t type_id = get_colon_op_type (base, increment, limit); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3518 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3519 // For compatibility with Matlab, don't allow the range used in |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3520 // a FOR loop expression to be converted to a Matrix. |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3521 |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3522 // For now, these functions create arrays instead of range<T> for |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3523 // all types except double. |
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3524 |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3525 switch (type_id) |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3526 { |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3527 case btyp_double: |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3528 case btyp_complex: |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3529 return make_float_range<double> (base, increment, limit, is_for_cmd_expr); |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3530 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3531 case btyp_float: |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3532 case btyp_float_complex: |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3533 return make_float_range<float> (base, increment, limit, is_for_cmd_expr); |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3534 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3535 case btyp_int8: |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3536 return make_int_range<octave_int8> (base, increment, limit); |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3537 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3538 case btyp_int16: |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3539 return make_int_range<octave_int16> (base, increment, limit); |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3540 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3541 case btyp_int32: |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3542 return make_int_range<octave_int32> (base, increment, limit); |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3543 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3544 case btyp_int64: |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3545 return make_int_range<octave_int64> (base, increment, limit); |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3546 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3547 case btyp_uint8: |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3548 return make_int_range<octave_uint8> (base, increment, limit); |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3549 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3550 case btyp_uint16: |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3551 return make_int_range<octave_uint16> (base, increment, limit); |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3552 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3553 case btyp_uint32: |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3554 return make_int_range<octave_uint32> (base, increment, limit); |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3555 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3556 case btyp_uint64: |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3557 return make_int_range<octave_uint64> (base, increment, limit); |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3558 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3559 case btyp_char: |
30834
f1a9e55d850c
for all but range<double>, create arrays instead of range objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3560 return make_char_range (base, increment, limit); |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3561 |
29369
c75996cbe3ba
Emit more specific error when two different integer types used in range (bug #59899).
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
3562 case btyp_unknown: |
c75996cbe3ba
Emit more specific error when two different integer types used in range (bug #59899).
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
3563 error ("incompatible types found in range expression"); |
c75996cbe3ba
Emit more specific error when two different integer types used in range (bug #59899).
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
3564 |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3565 default: |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3566 error ("invalid types found in range expression"); |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3567 } |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3568 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3569 return octave_value (); |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3570 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3571 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3572 OCTAVE_NORETURN static void |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3573 err_unary_op_conv (const std::string& on) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3574 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3575 error ("type conversion failed for unary operator '%s'", on.c_str ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3576 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3577 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3578 octave_value |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3579 unary_op (type_info& ti, octave_value::unary_op op, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3580 const octave_value& v) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3581 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3582 octave_value retval; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3583 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3584 int t = v.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3585 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3586 if (t == octave_class::static_type_id () |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3587 || t == octave_classdef::static_type_id ()) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3588 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3589 type_info::unary_class_op_fcn f = ti.lookup_unary_class_op (op); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3590 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3591 if (! f) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3592 err_unary_op (octave_value::unary_op_as_string (op), v.class_name ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3593 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3594 retval = f (v); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3595 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3596 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3597 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3598 // FIXME: we need to handle overloading operators for built-in |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3599 // classes (double, char, int8, etc.) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3600 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3601 type_info::unary_op_fcn f = ti.lookup_unary_op (op, t); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3602 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3603 if (f) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3604 retval = f (v.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3605 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3606 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3607 octave_value tv; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3608 octave_base_value::type_conv_fcn cf |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3609 = v.numeric_conversion_function (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3610 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3611 if (! cf) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3612 err_unary_op (octave_value::unary_op_as_string (op), |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3613 v.type_name ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3614 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3615 octave_base_value *tmp = cf (v.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3616 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3617 if (! tmp) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3618 err_unary_op_conv (octave_value::unary_op_as_string (op)); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3619 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3620 tv = octave_value (tmp); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3621 retval = unary_op (op, tv); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3622 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3623 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3624 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3625 return retval; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3626 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3627 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3628 octave_value |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3629 unary_op (octave_value::unary_op op, const octave_value& v) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3630 { |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30888
diff
changeset
|
3631 type_info& ti = __get_type_info__ (); |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3632 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3633 return unary_op (ti, op, v); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3634 } |
29960
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
3635 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31155
diff
changeset
|
3636 OCTAVE_END_NAMESPACE(octave) |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3637 |
2376 | 3638 void |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3639 install_types (octave::type_info& ti) |
2376 | 3640 { |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3641 octave_base_value::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3642 octave_cell::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3643 octave_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3644 octave_complex::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3645 octave_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3646 octave_diag_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3647 octave_complex_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3648 octave_complex_diag_matrix::register_type (ti); |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
3649 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
3650 // Legacy range type, preserved to allow loading "constant" ranges |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
3651 // from data files. |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
3652 octave_legacy_range::register_type (ti); |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
3653 |
30835
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
3654 ov_range<double>::register_type (ti); |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
3655 |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
3656 // For now, disable all but ov_range<double>. |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
3657 |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
3658 #if 0 |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
3659 |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
3660 ov_range<float>::register_type (ti); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
3661 ov_range<octave_int8>::register_type (ti); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
3662 ov_range<octave_int16>::register_type (ti); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
3663 ov_range<octave_int32>::register_type (ti); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
3664 ov_range<octave_int64>::register_type (ti); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
3665 ov_range<octave_uint8>::register_type (ti); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
3666 ov_range<octave_uint16>::register_type (ti); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
3667 ov_range<octave_uint32>::register_type (ti); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
3668 ov_range<octave_uint64>::register_type (ti); |
30835
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
3669 |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
3670 #endif |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30834
diff
changeset
|
3671 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3672 octave_bool::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3673 octave_bool_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3674 octave_char_matrix_str::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3675 octave_char_matrix_sq_str::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3676 octave_int8_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3677 octave_int16_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3678 octave_int32_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3679 octave_int64_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3680 octave_uint8_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3681 octave_uint16_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3682 octave_uint32_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3683 octave_uint64_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3684 octave_int8_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3685 octave_int16_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3686 octave_int32_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3687 octave_int64_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3688 octave_uint8_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3689 octave_uint16_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3690 octave_uint32_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3691 octave_uint64_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3692 octave_sparse_bool_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3693 octave_sparse_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3694 octave_sparse_complex_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3695 octave_struct::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3696 octave_scalar_struct::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3697 octave_class::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3698 octave_cs_list::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3699 octave_magic_colon::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3700 octave_builtin::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3701 octave_user_function::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3702 octave_dld_function::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3703 octave_fcn_handle::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3704 octave_float_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3705 octave_float_complex::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3706 octave_float_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3707 octave_float_diag_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3708 octave_float_complex_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3709 octave_float_complex_diag_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3710 octave_perm_matrix::register_type (ti); |
28588
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
3711 octave_magic_int::register_type (ti); |
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
3712 octave_magic_uint::register_type (ti); |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3713 octave_null_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3714 octave_null_str::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3715 octave_null_sq_str::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3716 octave_lazy_index::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3717 octave_oncleanup::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3718 octave_java::register_type (ti); |
2376 | 3719 } |
3720 | |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31155
diff
changeset
|
3721 OCTAVE_BEGIN_NAMESPACE(octave) |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
3722 |
4791 | 3723 DEFUN (sizeof, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3724 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30868
diff
changeset
|
3725 @deftypefn {} {@var{sz} =} sizeof (@var{val}) |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3726 Return the size of @var{val} in bytes. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3727 @seealso{whos} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3728 @end deftypefn */) |
4791 | 3729 { |
20797
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3730 if (args.length () != 1) |
5823 | 3731 print_usage (); |
4791 | 3732 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20893
diff
changeset
|
3733 return ovl (args(0).byte_size ()); |
4791 | 3734 } |
3735 | |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3736 /* |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3737 %!assert (sizeof (uint64 (ones (3))), 72) |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3738 %!assert (sizeof (double (zeros (2,4))), 64) |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3739 %!assert (sizeof ({"foo", "bar", "baaz"}), 10) |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3740 */ |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3741 |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3742 static void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23433
diff
changeset
|
3743 decode_subscripts (const char *name, const octave_value& arg, |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3744 std::string& type_string, |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3745 std::list<octave_value_list>& idx) |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3746 { |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20703
diff
changeset
|
3747 const octave_map m = arg.xmap_value ("%s: second argument must be a structure with fields 'type' and 'subs'", name); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20703
diff
changeset
|
3748 |
20978
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3749 if (m.nfields () != 2 || ! m.contains ("type") || ! m.contains ("subs")) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3750 error ("%s: second argument must be a structure with fields 'type' and 'subs'", |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3751 name); |
20978
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3752 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3753 octave_idx_type nel = m.numel (); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3754 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3755 type_string = std::string (nel, '\0'); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3756 idx = std::list<octave_value_list> (); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3757 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3758 if (nel == 0) |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3759 return; |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3760 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3761 const Cell type = m.contents ("type"); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3762 const Cell subs = m.contents ("subs"); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3763 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3764 for (int k = 0; k < nel; k++) |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3765 { |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3766 std::string item = type(k).xstring_value ("%s: type(%d) must be a string", name, k+1); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3767 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3768 if (item == "{}") |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3769 type_string[k] = '{'; |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3770 else if (item == "()") |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3771 type_string[k] = '('; |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3772 else if (item == ".") |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3773 type_string[k] = '.'; |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3774 else |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3775 error ("%s: invalid indexing type '%s'", name, item.c_str ()); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3776 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3777 octave_value_list idx_item; |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3778 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3779 if (subs(k).is_string ()) |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3780 idx_item(0) = subs(k); |
23576
00e518162fda
maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents:
23534
diff
changeset
|
3781 else if (subs(k).iscell ()) |
20978
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3782 { |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3783 Cell subs_cell = subs(k).cell_value (); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3784 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3785 for (int n = 0; n < subs_cell.numel (); n++) |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3786 { |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3787 if (subs_cell(n).is_string () |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3788 && subs_cell(n).string_value () == ":") |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3789 idx_item(n) = octave_value(octave_value::magic_colon_t); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3790 else |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3791 idx_item(n) = subs_cell(n); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3792 } |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3793 } |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3794 else |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3795 error ("%s: subs(%d) must be a string or cell array", name, k+1); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3796 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3797 idx.push_back (idx_item); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3798 } |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3799 } |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3800 |
6153 | 3801 DEFUN (subsref, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3802 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30868
diff
changeset
|
3803 @deftypefn {} {@var{newval} =} subsref (@var{val}, @var{idx}) |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3804 Perform the subscripted element selection operation on @var{val} according |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3805 to the subscript specified by @var{idx}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3806 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3807 The subscript @var{idx} must be a structure array with fields @samp{type} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3808 and @samp{subs}. Valid values for @samp{type} are @qcode{"()"}, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3809 @qcode{"@{@}"}, and @qcode{"."}. The @samp{subs} field may be either |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3810 @qcode{":"} or a cell array of index values. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3811 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3812 The following example shows how to extract the first two columns of a matrix |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3813 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3814 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3815 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3816 val = magic (3) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3817 @result{} val = [ 8 1 6 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3818 3 5 7 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3819 4 9 2 ] |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3820 idx.type = "()"; |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3821 idx.subs = @{":", 1:2@}; |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3822 subsref (val, idx) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3823 @result{} [ 8 1 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3824 3 5 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3825 4 9 ] |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3826 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3827 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3828 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3829 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3830 Note that this is the same as writing @code{val(:, 1:2)}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3831 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3832 If @var{idx} is an empty structure array with fields @samp{type} and |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3833 @samp{subs}, return @var{val}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3834 @seealso{subsasgn, substruct} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3835 @end deftypefn */) |
6153 | 3836 { |
20797
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3837 if (args.length () != 2) |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3838 print_usage (); |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3839 |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3840 std::string type; |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3841 std::list<octave_value_list> idx; |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3842 |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3843 decode_subscripts ("subsref", args(1), type, idx); |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3844 |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3845 octave_value arg0 = args(0); |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3846 |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3847 if (type.empty ()) |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20893
diff
changeset
|
3848 return ovl (arg0); |
6153 | 3849 else |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20893
diff
changeset
|
3850 return arg0.subsref (type, idx, nargout); |
6153 | 3851 } |
3852 | |
3853 DEFUN (subsasgn, args, , | |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3854 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30868
diff
changeset
|
3855 @deftypefn {} {@var{newval} =} subsasgn (@var{val}, @var{idx}, @var{rhs}) |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3856 Perform the subscripted assignment operation according to the subscript |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3857 specified by @var{idx}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3858 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3859 The subscript @var{idx} must be a structure array with fields @samp{type} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3860 and @samp{subs}. Valid values for @samp{type} are @qcode{"()"}, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3861 @qcode{"@{@}"}, and @qcode{"."}. The @samp{subs} field may be either |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3862 @qcode{":"} or a cell array of index values. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3863 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3864 The following example shows how to set the two first columns of a 3-by-3 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3865 matrix to zero. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3866 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3867 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3868 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3869 val = magic (3); |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3870 idx.type = "()"; |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3871 idx.subs = @{":", 1:2@}; |
31150
44b9673c7b8d
correct subsasgn docstring example code (bug #33221)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
30867
diff
changeset
|
3872 val = subsasgn (val, idx, 0) |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3873 @result{} [ 0 0 6 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3874 0 0 7 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3875 0 0 2 ] |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3876 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3877 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3878 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3879 Note that this is the same as writing @code{val(:, 1:2) = 0}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3880 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3881 If @var{idx} is an empty structure array with fields @samp{type} and |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3882 @samp{subs}, return @var{rhs}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3883 @seealso{subsref, substruct, optimize_subsasgn_calls} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3884 @end deftypefn */) |
6153 | 3885 { |
20797
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3886 if (args.length () != 3) |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3887 print_usage (); |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3888 |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3889 std::string type; |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3890 std::list<octave_value_list> idx; |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3891 |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3892 decode_subscripts ("subsasgn", args(1), type, idx); |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3893 |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3894 if (type.empty ()) |
6153 | 3895 { |
20797
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3896 // Regularize a null matrix if stored into a variable. |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20893
diff
changeset
|
3897 return ovl (args(2).storable_value ()); |
6153 | 3898 } |
3899 else | |
20797
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3900 { |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3901 octave_value arg0 = args(0); |
22390
6cbbd550aa91
allow subsasgn (x, idx, zeros(0,0)) to remove elements (bug #48867)
John W. Eaton <jwe@octave.org>
parents:
22327
diff
changeset
|
3902 octave_value arg2 = args(2); |
20797
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3903 |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3904 arg0.make_unique (); |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3905 |
22390
6cbbd550aa91
allow subsasgn (x, idx, zeros(0,0)) to remove elements (bug #48867)
John W. Eaton <jwe@octave.org>
parents:
22327
diff
changeset
|
3906 bool arg2_null = arg2.is_zero_by_zero () && arg2.is_double_type (); |
6cbbd550aa91
allow subsasgn (x, idx, zeros(0,0)) to remove elements (bug #48867)
John W. Eaton <jwe@octave.org>
parents:
22327
diff
changeset
|
3907 |
6cbbd550aa91
allow subsasgn (x, idx, zeros(0,0)) to remove elements (bug #48867)
John W. Eaton <jwe@octave.org>
parents:
22327
diff
changeset
|
3908 return ovl (arg0.subsasgn (type, idx, (arg2_null |
6cbbd550aa91
allow subsasgn (x, idx, zeros(0,0)) to remove elements (bug #48867)
John W. Eaton <jwe@octave.org>
parents:
22327
diff
changeset
|
3909 ? octave_null_matrix::instance |
6cbbd550aa91
allow subsasgn (x, idx, zeros(0,0)) to remove elements (bug #48867)
John W. Eaton <jwe@octave.org>
parents:
22327
diff
changeset
|
3910 : arg2))); |
20797
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3911 } |
6153 | 3912 } |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3913 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3914 /* |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3915 %!test |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3916 %! a = reshape ([1:25], 5,5); |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3917 %! idx1 = substruct ("()", {3, 3}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3918 %! idx2 = substruct ("()", {2:2:5, 2:2:5}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3919 %! idx3 = substruct ("()", {":", [1,5]}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3920 %! idx4 = struct ("type", {}, "subs", {}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3921 %! assert (subsref (a, idx1), 13); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3922 %! assert (subsref (a, idx2), [7 17; 9 19]); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3923 %! assert (subsref (a, idx3), [1:5; 21:25]'); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3924 %! assert (subsref (a, idx4), a); |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3925 %! a = subsasgn (a, idx1, 0); |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3926 %! a = subsasgn (a, idx2, 0); |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3927 %! a = subsasgn (a, idx3, 0); |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3928 %!# a = subsasgn (a, idx4, 0); |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3929 %! b = [0 6 11 16 0 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3930 %! 0 0 12 0 0 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3931 %! 0 8 0 18 0 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3932 %! 0 0 14 0 0 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3933 %! 0 10 15 20 0]; |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
3934 %! assert (a, b); |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3935 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3936 %!test |
22390
6cbbd550aa91
allow subsasgn (x, idx, zeros(0,0)) to remove elements (bug #48867)
John W. Eaton <jwe@octave.org>
parents:
22327
diff
changeset
|
3937 %! x = 1:10; |
6cbbd550aa91
allow subsasgn (x, idx, zeros(0,0)) to remove elements (bug #48867)
John W. Eaton <jwe@octave.org>
parents:
22327
diff
changeset
|
3938 %! assert (subsasgn (x, substruct ("()", {1}), zeros (0, 0)), 2:10); |
6cbbd550aa91
allow subsasgn (x, idx, zeros(0,0)) to remove elements (bug #48867)
John W. Eaton <jwe@octave.org>
parents:
22327
diff
changeset
|
3939 |
6cbbd550aa91
allow subsasgn (x, idx, zeros(0,0)) to remove elements (bug #48867)
John W. Eaton <jwe@octave.org>
parents:
22327
diff
changeset
|
3940 %!test |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3941 %! c = num2cell (reshape ([1:25],5,5)); |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3942 %! idx1 = substruct ("{}", {3, 3}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3943 %! idx2 = substruct ("()", {2:2:5, 2:2:5}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3944 %! idx3 = substruct ("()", {":", [1,5]}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3945 %! idx2p = substruct ("{}", {2:2:5, 2:2:5}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3946 %! idx3p = substruct ("{}", {":", [1,5]}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3947 %! idx4 = struct ("type", {}, "subs", {}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3948 %! assert ({ subsref(c, idx1) }, {13}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3949 %! assert ({ subsref(c, idx2p) }, {7 9 17 19}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3950 %! assert ({ subsref(c, idx3p) }, num2cell ([1:5, 21:25])); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14528
diff
changeset
|
3951 %! assert (subsref (c, idx4), c); |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3952 %! c = subsasgn (c, idx1, 0); |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3953 %! c = subsasgn (c, idx2, 0); |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3954 %! c = subsasgn (c, idx3, 0); |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3955 %!# c = subsasgn (c, idx4, 0); |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3956 %! d = {0 6 11 16 0 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3957 %! 0 0 12 0 0 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3958 %! 0 8 0 18 0 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3959 %! 0 0 14 0 0 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3960 %! 0 10 15 20 0}; |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3961 %! assert (c, d); |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3962 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3963 %!test |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3964 %! s.a = "ohai"; |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3965 %! s.b = "dere"; |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3966 %! s.c = 42; |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3967 %! idx1 = substruct (".", "a"); |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3968 %! idx2 = substruct (".", "b"); |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3969 %! idx3 = substruct (".", "c"); |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3970 %! idx4 = struct ("type", {}, "subs", {}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3971 %! assert (subsref (s, idx1), "ohai"); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3972 %! assert (subsref (s, idx2), "dere"); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3973 %! assert (subsref (s, idx3), 42); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3974 %! assert (subsref (s, idx4), s); |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3975 %! s = subsasgn (s, idx1, "Hello"); |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3976 %! s = subsasgn (s, idx2, "There"); |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3977 %! s = subsasgn (s, idx3, 163); |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3978 %!# s = subsasgn (s, idx4, 163); |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3979 %! t.a = "Hello"; |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3980 %! t.b = "There"; |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3981 %! t.c = 163; |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3982 %! assert (s, t); |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3983 */ |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3984 |
13712
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3985 DEFUN (is_sq_string, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3986 doc: /* -*- texinfo -*- |
30559
841a10208c38
doc: Use TF for output variable in documentation for isXXX functions in libinterp/ directory.
Rik <rik@octave.org>
parents:
30424
diff
changeset
|
3987 @deftypefn {} {@var{tf} =} is_sq_string (@var{x}) |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3988 Return true if @var{x} is a single-quoted character string. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3989 @seealso{is_dq_string, ischar} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3990 @end deftypefn */) |
13712
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3991 { |
20797
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3992 if (args.length () != 1) |
13712
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3993 print_usage (); |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3994 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20893
diff
changeset
|
3995 return ovl (args(0).is_sq_string ()); |
13712
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3996 } |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3997 |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3998 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
3999 %!assert (is_sq_string ('foo'), true) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
4000 %!assert (is_sq_string ("foo"), false) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
4001 %!assert (is_sq_string (1.0), false) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
4002 %!assert (is_sq_string ({2.0}), false) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
4003 |
13712
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
4004 %!error is_sq_string () |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
4005 %!error is_sq_string ('foo', 2) |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
4006 */ |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
4007 |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
4008 DEFUN (is_dq_string, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
4009 doc: /* -*- texinfo -*- |
30559
841a10208c38
doc: Use TF for output variable in documentation for isXXX functions in libinterp/ directory.
Rik <rik@octave.org>
parents:
30424
diff
changeset
|
4010 @deftypefn {} {@var{tf} =} is_dq_string (@var{x}) |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
4011 Return true if @var{x} is a double-quoted character string. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
4012 @seealso{is_sq_string, ischar} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
4013 @end deftypefn */) |
13712
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
4014 { |
20797
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4015 if (args.length () != 1) |
13712
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
4016 print_usage (); |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
4017 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20893
diff
changeset
|
4018 return ovl (args(0).is_dq_string ()); |
13712
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
4019 } |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
4020 |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
4021 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
4022 %!assert (is_dq_string ("foo"), true) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
4023 %!assert (is_dq_string ('foo'), false) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
4024 %!assert (is_dq_string (1.0), false) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
4025 %!assert (is_dq_string ({2.0}), false) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
4026 |
13712
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
4027 %!error is_dq_string () |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
4028 %!error is_dq_string ("foo", 2) |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
4029 */ |
19391
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4030 |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4031 DEFUN (optimize_permutation_matrix, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
4032 doc: /* -*- texinfo -*- |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4033 @deftypefn {} {@var{val} =} optimize_permutation_matrix () |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4034 @deftypefnx {} {@var{old_val} =} optimize_permutation_matrix (@var{new_val}) |
30588
ed17822e7662
doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
4035 @deftypefnx {} {@var{old_val} =} optimize_permutation_matrix (@var{new_val}, "local") |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4036 Query or set whether a special space-efficient format is used for storing |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4037 permutation matrices. |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4038 |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4039 The default value is true. If this option is set to false, Octave will store |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
4040 permutation matrices as full matrices. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
4041 |
29929
a3ac00db296b
doc: disable_diagonal_matrix, disable_diagonal_matrix, and disable_range (patch #10089).
José Luis García Pallero <jgpallero@gmail.com>
parents:
29654
diff
changeset
|
4042 When called from inside a function with the @qcode{"local"} option, the setting |
a3ac00db296b
doc: disable_diagonal_matrix, disable_diagonal_matrix, and disable_range (patch #10089).
José Luis García Pallero <jgpallero@gmail.com>
parents:
29654
diff
changeset
|
4043 is changed locally for the function and any subroutines it calls. The original |
a3ac00db296b
doc: disable_diagonal_matrix, disable_diagonal_matrix, and disable_range (patch #10089).
José Luis García Pallero <jgpallero@gmail.com>
parents:
29654
diff
changeset
|
4044 setting is restored when exiting the function. |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4045 @seealso{optimize_range, optimize_diagonal_matrix} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
4046 @end deftypefn */) |
19391
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4047 { |
30001
428cccc75cc9
move most functions in variables.cc to octave namespace
John W. Eaton <jwe@octave.org>
parents:
29982
diff
changeset
|
4048 return set_internal_variable (Voptimize_permutation_matrix, args, nargout, |
428cccc75cc9
move most functions in variables.cc to octave namespace
John W. Eaton <jwe@octave.org>
parents:
29982
diff
changeset
|
4049 "optimize_permutation_matrix"); |
19391
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4050 } |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4051 |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4052 /* |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4053 %!function p = __test_dpm__ (dpm) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4054 %! optimize_permutation_matrix (dpm, "local"); |
19391
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4055 %! [~, ~, p] = lu ([1,2;3,4]); |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4056 %!endfunction |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4057 |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4058 %!assert (typeinfo (__test_dpm__ (true)), "permutation matrix") |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4059 %!assert (typeinfo (__test_dpm__ (false)), "matrix") |
19391
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4060 */ |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4061 |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4062 DEFUN (optimize_diagonal_matrix, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
4063 doc: /* -*- texinfo -*- |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4064 @deftypefn {} {@var{val} =} optimize_diagonal_matrix () |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4065 @deftypefnx {} {@var{old_val} =} optimize_diagonal_matrix (@var{new_val}) |
30588
ed17822e7662
doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
4066 @deftypefnx {} {@var{old_val} =} optimize_diagonal_matrix (@var{new_val}, "local") |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4067 Query or set whether a special space-efficient format is used for storing |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4068 diagonal matrices. |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4069 |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4070 The default value is true. If this option is set to false, Octave will store |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
4071 diagonal matrices as full matrices. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
4072 |
29929
a3ac00db296b
doc: disable_diagonal_matrix, disable_diagonal_matrix, and disable_range (patch #10089).
José Luis García Pallero <jgpallero@gmail.com>
parents:
29654
diff
changeset
|
4073 When called from inside a function with the @qcode{"local"} option, the setting |
30354
c980f938fdd8
doc: grammarcheck C++ files in libinterp/ directory ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
4074 is changed locally for the function and any subroutines it calls. The original |
29929
a3ac00db296b
doc: disable_diagonal_matrix, disable_diagonal_matrix, and disable_range (patch #10089).
José Luis García Pallero <jgpallero@gmail.com>
parents:
29654
diff
changeset
|
4075 setting is restored when exiting the function. |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4076 @seealso{optimize_range, optimize_permutation_matrix} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
4077 @end deftypefn */) |
19391
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4078 { |
30001
428cccc75cc9
move most functions in variables.cc to octave namespace
John W. Eaton <jwe@octave.org>
parents:
29982
diff
changeset
|
4079 return set_internal_variable (Voptimize_diagonal_matrix, args, nargout, |
428cccc75cc9
move most functions in variables.cc to octave namespace
John W. Eaton <jwe@octave.org>
parents:
29982
diff
changeset
|
4080 "optimize_diagonal_matrix"); |
19391
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4081 } |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4082 |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4083 /* |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4084 %!function [x, xi, fx, fxi] = __test_ddm__ (ddm) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4085 %! optimize_diagonal_matrix (ddm, "local"); |
19391
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4086 %! x = eye (2); |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4087 %! xi = x*i; |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4088 %! fx = single (x); |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4089 %! fxi = single (xi); |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4090 %!endfunction |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4091 |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4092 %!shared x, xi, fx, fxi |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4093 %! [x, xi, fx, fxi] = __test_ddm__ (true); |
21317
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
4094 %!assert (typeinfo (x), "diagonal matrix") |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
4095 %!assert (typeinfo (xi), "complex diagonal matrix") |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
4096 %!assert (typeinfo (fx), "float diagonal matrix") |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
4097 %!assert (typeinfo (fxi), "float complex diagonal matrix") |
19391
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4098 |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4099 %!shared x, xi, fx, fxi |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4100 %! [x, xi, fx, fxi] = __test_ddm__ (false); |
21317
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
4101 %!assert (typeinfo (x), "matrix") |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
4102 %!assert (typeinfo (xi), "complex matrix") |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
4103 %!assert (typeinfo (fx), "float matrix") |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
4104 %!assert (typeinfo (fxi), "float complex matrix") |
19391
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
4105 */ |
19394
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
4106 |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4107 DEFUN (optimize_range, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
4108 doc: /* -*- texinfo -*- |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4109 @deftypefn {} {@var{val} =} optimize_range () |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4110 @deftypefnx {} {@var{old_val} =} optimize_range (@var{new_val}) |
30588
ed17822e7662
doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
4111 @deftypefnx {} {@var{old_val} =} optimize_range (@var{new_val}, "local") |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4112 Query or set whether a special space-efficient format is used for storing |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4113 ranges. |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4114 |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4115 The default value is true. If this option is set to false, Octave will store |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
4116 ranges as full matrices. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
4117 |
29929
a3ac00db296b
doc: disable_diagonal_matrix, disable_diagonal_matrix, and disable_range (patch #10089).
José Luis García Pallero <jgpallero@gmail.com>
parents:
29654
diff
changeset
|
4118 When called from inside a function with the @qcode{"local"} option, the setting |
a3ac00db296b
doc: disable_diagonal_matrix, disable_diagonal_matrix, and disable_range (patch #10089).
José Luis García Pallero <jgpallero@gmail.com>
parents:
29654
diff
changeset
|
4119 is changed locally for the function and any subroutines it calls. The original |
a3ac00db296b
doc: disable_diagonal_matrix, disable_diagonal_matrix, and disable_range (patch #10089).
José Luis García Pallero <jgpallero@gmail.com>
parents:
29654
diff
changeset
|
4120 setting is restored when exiting the function. |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4121 @seealso{optimize_diagonal_matrix, optimize_permutation_matrix} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
4122 @end deftypefn */) |
19394
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
4123 { |
30001
428cccc75cc9
move most functions in variables.cc to octave namespace
John W. Eaton <jwe@octave.org>
parents:
29982
diff
changeset
|
4124 return set_internal_variable (Voptimize_range, args, nargout, |
428cccc75cc9
move most functions in variables.cc to octave namespace
John W. Eaton <jwe@octave.org>
parents:
29982
diff
changeset
|
4125 "optimize_range"); |
19394
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
4126 } |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
4127 |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
4128 /* |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
4129 %!function r = __test_dr__ (dr) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4130 %! optimize_range (dr, "local"); |
19394
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
4131 %! ## Constant folding will produce range for 1:13. |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
4132 %! base = 1; |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
4133 %! limit = 13; |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
4134 %! r = base:limit; |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
4135 %!endfunction |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
4136 |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
30839
diff
changeset
|
4137 %!assert (typeinfo (__test_dr__ (true)), "double_range") |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
4138 %!assert (typeinfo (__test_dr__ (false)), "matrix") |
19394
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
4139 */ |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
4140 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31155
diff
changeset
|
4141 OCTAVE_END_NAMESPACE(octave) |