Mercurial > octave
annotate libinterp/octave-value/ov-intx.h @ 21244:1473547f50f5
include octave-config.h in public header files
* mk-opts.pl, mkbuiltins, mk-ops.awk, sparse-mk-ops.awk:
Emit "#include octave-config.h" statement for generated header files.
* build-env.h, builtins.h, Cell.h, base-text-renderer.h,
c-file-ptr-stream.h, cdisplay.h, comment-list.h, data.h, debug.h,
defaults.in.h, defun-dld.h, defun-int.h, defun.h, dirfns.h, display.h,
dynamic-ld.h, error.h, errwarn.h, event-queue.h, file-io.h,
ft-text-renderer.h, gl-render.h, gl2ps-print.h, graphics.in.h,
gripes.h, help.h, hook-fcn.h, input.h, jit-ir.h, jit-typeinfo.h,
jit-util.h, load-path.h, load-save.h, ls-ascii-helper.h, ls-hdf5.h,
ls-mat-ascii.h, ls-mat4.h, ls-mat5.h, ls-oct-binary.h, ls-oct-text.h,
ls-utils.h, mex.h, mexproto.h, mxarray.in.h, oct-errno.h, oct-fstrm.h,
oct-handle.h, oct-hdf5-types.h, oct-hdf5.h, oct-hist.h, oct-iostrm.h,
oct-lvalue.h, oct-map.h, oct-obj.h, oct-opengl.h, oct-prcstrm.h,
oct-procbuf.h, oct-stdstrm.h, oct-stream.h, oct-strstrm.h, oct.h,
octave-default-image.h, octave-link.h, octave-preserve-stream-state.h,
pager.h, pr-output.h, procstream.h, profiler.h, pt-jit.h,
sighandlers.h, siglist.h, sparse-xdiv.h, sparse-xpow.h, symtab.h,
sysdep.h, text-renderer.h, toplev.h, txt-eng.h, utils.h, variables.h,
workspace-element.h, xdiv.h, xnorm.h, xpow.h, zfstream.h, oct-qhull.h,
ov-base-diag.h, ov-base-int.h, ov-base-mat.h, ov-base-scalar.h,
ov-base-sparse.h, ov-base.h, ov-bool-mat.h, ov-bool-sparse.h,
ov-bool.h, ov-builtin.h, ov-cell.h, ov-ch-mat.h, ov-class.h,
ov-classdef.h, ov-colon.h, ov-complex.h, ov-cs-list.h, ov-cx-diag.h,
ov-cx-mat.h, ov-cx-sparse.h, ov-dld-fcn.h, ov-fcn-handle.h,
ov-fcn-inline.h, ov-fcn.h, ov-float.h, ov-flt-complex.h,
ov-flt-cx-diag.h, ov-flt-cx-mat.h, ov-flt-re-diag.h, ov-flt-re-mat.h,
ov-int-traits.h, ov-int16.h, ov-int32.h, ov-int64.h, ov-int8.h,
ov-intx.h, ov-java.h, ov-lazy-idx.h, ov-mex-fcn.h, ov-null-mat.h,
ov-oncleanup.h, ov-perm.h, ov-range.h, ov-re-diag.h, ov-re-mat.h,
ov-re-sparse.h, ov-scalar.h, ov-str-mat.h, ov-struct.h,
ov-type-conv.h, ov-typeinfo.h, ov-uint16.h, ov-uint32.h, ov-uint64.h,
ov-uint8.h, ov-usr-fcn.h, ov.h, ovl.h, octave.h, op-int.h, ops.h,
options-usage.h, lex.h, parse.h, pt-all.h, pt-arg-list.h,
pt-array-list.h, pt-assign.h, pt-binop.h, pt-bp.h, pt-cbinop.h,
pt-cell.h, pt-check.h, pt-classdef.h, pt-cmd.h, pt-colon.h,
pt-const.h, pt-decl.h, pt-eval.h, pt-except.h, pt-exp.h,
pt-fcn-handle.h, pt-funcall.h, pt-id.h, pt-idx.h, pt-jump.h,
pt-loop.h, pt-mat.h, pt-misc.h, pt-pr-code.h, pt-select.h, pt-stmt.h,
pt-unop.h, pt-walk.h, pt.h, token.h, version.in.h, Array-util.h,
Array.h, CColVector.h, CDiagMatrix.h, CMatrix.h, CNDArray.h,
CRowVector.h, CSparse.h, DiagArray2.h, MArray.h, MDiagArray2.h,
MSparse.h, Matrix.h, MatrixType.h, PermMatrix.h, Range.h, Sparse.h,
boolMatrix.h, boolNDArray.h, boolSparse.h, chMatrix.h, chNDArray.h,
dColVector.h, dDiagMatrix.h, dMatrix.h, dNDArray.h, dRowVector.h,
dSparse.h, dim-vector.h, fCColVector.h, fCDiagMatrix.h, fCMatrix.h,
fCNDArray.h, fCRowVector.h, fColVector.h, fDiagMatrix.h, fMatrix.h,
fNDArray.h, fRowVector.h, idx-vector.h, int16NDArray.h,
int32NDArray.h, int64NDArray.h, int8NDArray.h, intNDArray.h,
uint16NDArray.h, uint32NDArray.h, uint64NDArray.h, uint8NDArray.h,
f77-fcn.h, lo-error.h, quit.h, CmplxAEPBAL.h, CmplxCHOL.h,
CmplxGEPBAL.h, CmplxHESS.h, CmplxLU.h, CmplxQR.h, CmplxQRP.h,
CmplxSCHUR.h, CmplxSVD.h, CollocWt.h, DAE.h, DAEFunc.h, DAERT.h,
DAERTFunc.h, DASPK.h, DASRT.h, DASSL.h, DET.h, EIG.h, LSODE.h, ODE.h,
ODEFunc.h, ODES.h, ODESFunc.h, Quad.h, base-aepbal.h, base-dae.h,
base-de.h, base-lu.h, base-min.h, base-qr.h, bsxfun-decl.h, bsxfun.h,
dbleAEPBAL.h, dbleCHOL.h, dbleGEPBAL.h, dbleHESS.h, dbleLU.h,
dbleQR.h, dbleQRP.h, dbleSCHUR.h, dbleSVD.h, eigs-base.h,
fCmplxAEPBAL.h, fCmplxCHOL.h, fCmplxGEPBAL.h, fCmplxHESS.h,
fCmplxLU.h, fCmplxQR.h, fCmplxQRP.h, fCmplxSCHUR.h, fCmplxSVD.h,
fEIG.h, floatAEPBAL.h, floatCHOL.h, floatGEPBAL.h, floatHESS.h,
floatLU.h, floatQR.h, floatQRP.h, floatSCHUR.h, floatSVD.h,
lo-mappers.h, lo-specfun.h, oct-convn.h, oct-fftw.h, oct-norm.h,
oct-rand.h, oct-spparms.h, randgamma.h, randmtzig.h, randpoisson.h,
sparse-chol.h, sparse-dmsolve.h, sparse-lu.h, sparse-qr.h,
Sparse-diag-op-defs.h, Sparse-op-decls.h, Sparse-op-defs.h,
Sparse-perm-op-defs.h, mx-base.h, mx-defs.h, mx-ext.h, mx-op-decl.h,
mx-op-defs.h, dir-ops.h, file-ops.h, file-stat.h, lo-sysdep.h,
mach-info.h, oct-env.h, oct-group.h, oct-openmp.h, oct-passwd.h,
oct-syscalls.h, oct-time.h, oct-uname.h, pathlen.h, sysdir.h,
syswait.h, action-container.h, base-list.h, byte-swap.h,
caseless-str.h, cmd-edit.h, cmd-hist.h, data-conv.h, functor.h,
glob-match.h, lo-array-errwarn.h, lo-array-gripes.h, lo-cutils.h,
lo-ieee.h, lo-macros.h, lo-math.h, lo-regexp.h, lo-traits.h,
lo-utils.h, oct-alloc.h, oct-base64.h, oct-binmap.h, oct-cmplx.h,
oct-glob.h, oct-inttypes.h, oct-locbuf.h, oct-mutex.h, oct-refcount.h,
oct-rl-edit.h, oct-rl-hist.h, oct-shlib.h, oct-sort.h, oct-sparse.h,
pathsearch.h, singleton-cleanup.h, sparse-sort.h, sparse-util.h,
statdefs.h, str-vec.h, sun-utils.h, unwind-prot.h, url-transfer.h:
Include octave-config.h.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 10 Feb 2016 14:25:53 -0500 |
parents | f7d1050b9b53 |
children | 53728df3e4c9 |
rev | line source |
---|---|
4904 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19598
diff
changeset
|
3 Copyright (C) 2004-2015 John W. Eaton |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10405
diff
changeset
|
4 Copyright (C) 2010 VZLU Prague |
4904 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
4904 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
4904 | 21 |
22 */ | |
23 | |
21213
f7d1050b9b53
maint: Clean up various usages of #ifdef.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
24 // FIXME: Do not uncomment these lines to have this file included only once. |
f7d1050b9b53
maint: Clean up various usages of #ifdef.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
25 // The build will break (2/6/2016). |
f7d1050b9b53
maint: Clean up various usages of #ifdef.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
26 // #if ! defined (octave_ov_intx_h) |
f7d1050b9b53
maint: Clean up various usages of #ifdef.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
27 // #define octave_ov_intx_h 1 |
f7d1050b9b53
maint: Clean up various usages of #ifdef.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
28 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21213
diff
changeset
|
29 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21213
diff
changeset
|
30 |
4904 | 31 #include <cstdlib> |
32 | |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
33 #include <iosfwd> |
4904 | 34 #include <string> |
35 | |
36 #include "mx-base.h" | |
37 #include "str-vec.h" | |
38 | |
39 #include "error.h" | |
15149
62a35ae7d6a2
use forward decls for mxArray in ov.h and ov-base.h
John W. Eaton <jwe@octave.org>
parents:
15057
diff
changeset
|
40 #include "mxarray.h" |
4944 | 41 #include "oct-stream.h" |
4904 | 42 #include "ov-base.h" |
43 #include "ov-base-int.h" | |
44 #include "ov-typeinfo.h" | |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21055
diff
changeset
|
45 #include "errwarn.h" |
4904 | 46 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7201
diff
changeset
|
47 #include "ov-re-mat.h" |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7201
diff
changeset
|
48 #include "ov-scalar.h" |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7201
diff
changeset
|
49 |
4904 | 50 class |
6693 | 51 OCTINTERP_API |
4904 | 52 OCTAVE_VALUE_INT_MATRIX_T |
8321
69b6127f6962
better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents:
8039
diff
changeset
|
53 : public octave_base_int_matrix<intNDArray<OCTAVE_INT_T> > |
4904 | 54 { |
55 public: | |
56 | |
57 OCTAVE_VALUE_INT_MATRIX_T (void) | |
8321
69b6127f6962
better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents:
8039
diff
changeset
|
58 : octave_base_int_matrix<intNDArray<OCTAVE_INT_T> > () { } |
4904 | 59 |
8321
69b6127f6962
better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents:
8039
diff
changeset
|
60 OCTAVE_VALUE_INT_MATRIX_T (const intNDArray<OCTAVE_INT_T>& nda) |
69b6127f6962
better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents:
8039
diff
changeset
|
61 : octave_base_int_matrix<intNDArray<OCTAVE_INT_T> > (nda) { } |
4904 | 62 |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9685
diff
changeset
|
63 OCTAVE_VALUE_INT_MATRIX_T (const Array<OCTAVE_INT_T>& nda) |
8321
69b6127f6962
better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents:
8039
diff
changeset
|
64 : octave_base_int_matrix<intNDArray<OCTAVE_INT_T> > |
69b6127f6962
better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents:
8039
diff
changeset
|
65 (intNDArray<OCTAVE_INT_T> (nda)) { } |
7064 | 66 |
4904 | 67 ~OCTAVE_VALUE_INT_MATRIX_T (void) { } |
68 | |
5759 | 69 octave_base_value *clone (void) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
70 { return new OCTAVE_VALUE_INT_MATRIX_T (*this); } |
4904 | 71 |
5759 | 72 octave_base_value *empty_clone (void) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
73 { return new OCTAVE_VALUE_INT_MATRIX_T (); } |
4904 | 74 |
6069 | 75 bool OCTAVE_TYPE_PREDICATE_FUNCTION (void) const { return true; } |
5895 | 76 |
6223 | 77 bool is_integer_type (void) const { return true; } |
78 | |
9685 | 79 builtin_type_t builtin_type (void) const { return OCTAVE_INT_BTYP; } |
80 | |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
81 public: |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
82 |
5533 | 83 int8NDArray |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
84 int8_array_value (void) const { return int8NDArray (matrix); } |
5533 | 85 |
86 int16NDArray | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
87 int16_array_value (void) const { return int16NDArray (matrix); } |
5533 | 88 |
89 int32NDArray | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
90 int32_array_value (void) const { return int32NDArray (matrix); } |
5533 | 91 |
92 int64NDArray | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
93 int64_array_value (void) const { return int64NDArray (matrix); } |
5533 | 94 |
95 uint8NDArray | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
96 uint8_array_value (void) const { return uint8NDArray (matrix); } |
5533 | 97 |
98 uint16NDArray | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
99 uint16_array_value (void) const { return uint16NDArray (matrix); } |
5533 | 100 |
101 uint32NDArray | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
102 uint32_array_value (void) const { return uint32NDArray (matrix); } |
5533 | 103 |
104 uint64NDArray | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
105 uint64_array_value (void) const { return uint64NDArray (matrix); } |
4904 | 106 |
4982 | 107 double |
108 double_value (bool = false) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
109 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
110 double retval = lo_ieee_nan_value (); |
4982 | 111 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
112 if (numel () == 0) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21055
diff
changeset
|
113 err_invalid_conversion (type_name (), "real scalar"); |
4982 | 114 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
115 warn_implicit_conversion ("Octave:array-to-scalar", |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
116 type_name (), "real scalar"); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
117 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
118 retval = matrix(0).double_value (); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
119 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
120 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
121 } |
4982 | 122 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
123 float |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
124 float_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
125 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
126 float retval = lo_ieee_float_nan_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
127 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
128 if (numel () == 0) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21055
diff
changeset
|
129 err_invalid_conversion (type_name (), "real scalar"); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
130 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
131 warn_implicit_conversion ("Octave:array-to-scalar", |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
132 type_name (), "real scalar"); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
133 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
134 retval = matrix(0).float_value (); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
135 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
136 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
137 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
138 |
4983 | 139 double scalar_value (bool = false) const { return double_value (); } |
4982 | 140 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
141 float float_scalar_value (bool = false) const { return float_value (); } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
142 |
6214 | 143 Matrix |
144 matrix_value (bool = false) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
145 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
146 Matrix retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
147 dim_vector dv = dims (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
148 if (dv.length () > 2) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
149 error ("invalid conversion of %s to Matrix", type_name ().c_str ()); |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
150 |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
151 retval = Matrix (dv(0), dv(1)); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
152 double *vec = retval.fortran_vec (); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
153 octave_idx_type nel = matrix.numel (); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
154 for (octave_idx_type i = 0; i < nel; i++) |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
155 vec[i] = matrix(i).double_value (); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
156 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
157 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
158 } |
6214 | 159 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
160 FloatMatrix |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
161 float_matrix_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
162 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
163 FloatMatrix retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
164 dim_vector dv = dims (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
165 if (dv.length () > 2) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
166 error ("invalid conversion of %s to FloatMatrix", type_name ().c_str ()); |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
167 |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
168 retval = FloatMatrix (dv(0), dv(1)); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
169 float *vec = retval.fortran_vec (); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
170 octave_idx_type nel = matrix.numel (); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
171 for (octave_idx_type i = 0; i < nel; i++) |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
172 vec[i] = matrix(i).float_value (); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
173 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
174 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
175 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
176 |
6214 | 177 ComplexMatrix |
178 complex_matrix_value (bool = false) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
179 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
180 ComplexMatrix retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
181 dim_vector dv = dims (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
182 if (dv.length () > 2) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
183 error ("invalid conversion of %s to Matrix", type_name ().c_str ()); |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
184 |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
185 retval = ComplexMatrix (dv(0), dv(1)); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
186 Complex *vec = retval.fortran_vec (); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
187 octave_idx_type nel = matrix.numel (); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
188 for (octave_idx_type i = 0; i < nel; i++) |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
189 vec[i] = Complex (matrix(i).double_value ()); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
190 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
191 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
192 } |
6214 | 193 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
194 FloatComplexMatrix |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
195 float_complex_matrix_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
196 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
197 FloatComplexMatrix retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
198 dim_vector dv = dims (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
199 if (dv.length () > 2) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
200 error ("invalid conversion of %s to FloatMatrix", type_name ().c_str ()); |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
201 |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
202 retval = FloatComplexMatrix (dv(0), dv(1)); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
203 FloatComplex *vec = retval.fortran_vec (); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
204 octave_idx_type nel = matrix.numel (); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
205 for (octave_idx_type i = 0; i < nel; i++) |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
206 vec[i] = FloatComplex (matrix(i).float_value ()); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
207 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
208 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
209 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
210 |
4915 | 211 NDArray |
212 array_value (bool = false) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
213 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
214 NDArray retval (matrix.dims ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
215 double *vec = retval.fortran_vec (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
216 octave_idx_type nel = matrix.numel (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
217 for (octave_idx_type i = 0; i < nel; i++) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
218 vec[i] = matrix(i).double_value (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
219 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
220 } |
4963 | 221 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
222 FloatNDArray |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
223 float_array_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
224 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
225 FloatNDArray retval (matrix.dims ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
226 float *vec = retval.fortran_vec (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
227 octave_idx_type nel = matrix.numel (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
228 for (octave_idx_type i = 0; i < nel; i++) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
229 vec[i] = matrix(i).float_value (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
230 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
231 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
232 |
4963 | 233 ComplexNDArray |
234 complex_array_value (bool = false) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
235 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
236 ComplexNDArray retval (matrix.dims ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
237 Complex *vec = retval.fortran_vec (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
238 octave_idx_type nel = matrix.numel (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
239 for (octave_idx_type i = 0; i < nel; i++) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
240 vec[i] = Complex (matrix(i).double_value ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
241 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
242 } |
4915 | 243 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
244 FloatComplexNDArray |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
245 float_complex_array_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
246 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
247 FloatComplexNDArray retval (matrix.dims ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
248 FloatComplex *vec = retval.fortran_vec (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
249 octave_idx_type nel = matrix.numel (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
250 for (octave_idx_type i = 0; i < nel; i++) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
251 vec[i] = FloatComplex (matrix(i).float_value ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
252 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
253 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
254 |
5898 | 255 boolNDArray |
5943 | 256 bool_array_value (bool warn = false) const |
5898 | 257 { |
258 boolNDArray retval (dims ()); | |
259 | |
260 octave_idx_type nel = numel (); | |
5943 | 261 |
262 if (warn && matrix.any_element_not_one_or_zero ()) | |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21055
diff
changeset
|
263 warn_logical_conversion (); |
5943 | 264 |
6214 | 265 bool *vec = retval.fortran_vec (); |
5898 | 266 for (octave_idx_type i = 0; i < nel; i++) |
7198 | 267 vec[i] = matrix(i).bool_value (); |
5898 | 268 |
269 return retval; | |
270 } | |
271 | |
5533 | 272 charNDArray |
273 char_array_value (bool = false) const | |
274 { | |
275 charNDArray retval (dims ()); | |
276 | |
277 octave_idx_type nel = numel (); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
278 |
6214 | 279 char *vec = retval.fortran_vec (); |
5533 | 280 for (octave_idx_type i = 0; i < nel; i++) |
7198 | 281 vec[i] = matrix(i).char_value (); |
5533 | 282 |
283 return retval; | |
284 } | |
285 | |
9606
a04352386a6b
clear index cache on ++,-- operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9358
diff
changeset
|
286 // Use matrix_ref here to clear index cache. |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
287 void increment (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
288 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
289 matrix_ref () += OCTAVE_INT_T (1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
290 } |
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:
7999
diff
changeset
|
291 |
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:
7999
diff
changeset
|
292 void decrement (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
293 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
294 matrix_ref () -= OCTAVE_INT_T (1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
295 } |
5829 | 296 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9606
diff
changeset
|
297 void changesign (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
298 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
299 matrix_ref ().changesign (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
300 } |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9606
diff
changeset
|
301 |
18130
e473c4853afc
enable non-integer ranges as indices by default and deprecate preference
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
302 idx_vector index_vector (bool /* require_integers */ = false) const |
e473c4853afc
enable non-integer ranges as indices by default and deprecate preference
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
303 { |
e473c4853afc
enable non-integer ranges as indices by default and deprecate preference
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
304 return idx_cache ? *idx_cache : set_idx_cache (idx_vector (matrix)); |
e473c4853afc
enable non-integer ranges as indices by default and deprecate preference
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
305 } |
4938 | 306 |
4944 | 307 int write (octave_stream& os, int block_size, |
10313 | 308 oct_data_conv::data_type output_type, int skip, |
309 oct_mach_info::float_format flt_fmt) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
310 { return os.write (matrix, block_size, output_type, skip, flt_fmt); } |
4944 | 311 |
9358
d4b1314a7c31
mex.cc (mxArray_octave_value::get_data): avoid enumerating types that can be handled as foreign
John W. Eaton <jwe@octave.org>
parents:
9350
diff
changeset
|
312 // Unsafe. This function exists to support the MEX interface. |
d4b1314a7c31
mex.cc (mxArray_octave_value::get_data): avoid enumerating types that can be handled as foreign
John W. Eaton <jwe@octave.org>
parents:
9350
diff
changeset
|
313 // You should not use it anywhere else. |
d4b1314a7c31
mex.cc (mxArray_octave_value::get_data): avoid enumerating types that can be handled as foreign
John W. Eaton <jwe@octave.org>
parents:
9350
diff
changeset
|
314 void *mex_get_data (void) const { return matrix.mex_get_data (); } |
d4b1314a7c31
mex.cc (mxArray_octave_value::get_data): avoid enumerating types that can be handled as foreign
John W. Eaton <jwe@octave.org>
parents:
9350
diff
changeset
|
315 |
5900 | 316 mxArray *as_mxArray (void) const |
317 { | |
318 mxArray *retval = new mxArray (OCTAVE_INT_MX_CLASS, dims (), mxREAL); | |
319 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
320 OCTAVE_INT_T::val_type *pr = static_cast<OCTAVE_INT_T::val_type *> |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
321 (retval->get_data ()); |
5900 | 322 |
6686 | 323 mwSize nel = numel (); |
5900 | 324 |
325 const OCTAVE_INT_T *p = matrix.data (); | |
326 | |
6686 | 327 for (mwIndex i = 0; i < nel; i++) |
5900 | 328 pr[i] = p[i].value (); |
329 | |
330 return retval; | |
331 } | |
332 | |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
333 octave_value map (unary_mapper_t umap) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
334 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
335 switch (umap) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
336 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
337 case umap_abs: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
338 return matrix.abs (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
339 case umap_signum: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
340 return matrix.signum (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
341 case umap_ceil: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
342 case umap_conj: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
343 case umap_fix: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
344 case umap_floor: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
345 case umap_real: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
346 case umap_round: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
347 return matrix; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
348 case umap_imag: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
349 return intNDArray<OCTAVE_INT_T> (matrix.dims (), OCTAVE_INT_T ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
350 case umap_isnan: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
351 case umap_isna: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
352 case umap_isinf: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
353 return boolNDArray (matrix.dims (), false); |
21013
7f4c6d594e3d
Finish renaming mapper function finite to isfinite.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
354 case umap_isfinite: |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
355 return boolNDArray (matrix.dims (), true); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
356 |
18196
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
357 // Special cases for Matlab compatibility. |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
358 case umap_xtolower: |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
359 case umap_xtoupper: |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
360 return matrix; |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
361 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
362 default: |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
363 { |
18196
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
364 // FIXME: we should be able to do better than converting to |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
365 // double here. |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
366 octave_matrix m (array_value ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
367 return m.map (umap); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
368 } |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
369 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
370 } |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7201
diff
changeset
|
371 |
4904 | 372 private: |
373 | |
374 | |
375 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA | |
376 }; | |
377 | |
378 class | |
6693 | 379 OCTINTERP_API |
4904 | 380 OCTAVE_VALUE_INT_SCALAR_T |
381 : public octave_base_int_scalar<OCTAVE_INT_T> | |
382 { | |
383 public: | |
384 | |
385 OCTAVE_VALUE_INT_SCALAR_T (void) | |
386 : octave_base_int_scalar<OCTAVE_INT_T> () { } | |
387 | |
388 OCTAVE_VALUE_INT_SCALAR_T (const OCTAVE_INT_T& nda) | |
389 : octave_base_int_scalar<OCTAVE_INT_T> (nda) { } | |
390 | |
391 ~OCTAVE_VALUE_INT_SCALAR_T (void) { } | |
392 | |
5759 | 393 octave_base_value *clone (void) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
394 { return new OCTAVE_VALUE_INT_SCALAR_T (*this); } |
4904 | 395 |
5759 | 396 octave_base_value *empty_clone (void) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
397 { return new OCTAVE_VALUE_INT_MATRIX_T (); } |
4904 | 398 |
5885 | 399 octave_value do_index_op (const octave_value_list& idx, |
10313 | 400 bool resize_ok = false) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
401 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
402 // FIXME: this doesn't solve the problem of |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
403 // |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
404 // a = 1; a([1,1], [1,1], [1,1]) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
405 // |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
406 // and similar constructions. Hmm... |
4964 | 407 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
408 // FIXME: using this constructor avoids narrowing the |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
409 // 1x1 matrix back to a scalar value. Need a better solution |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
410 // to this problem. |
4964 | 411 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
412 octave_value tmp |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
413 (new OCTAVE_VALUE_INT_MATRIX_T |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
414 (OCTAVE_VALUE_INT_NDARRAY_EXTRACTOR_FUNCTION ())); |
4964 | 415 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
416 return tmp.do_index_op (idx, resize_ok); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
417 } |
4964 | 418 |
6069 | 419 bool OCTAVE_TYPE_PREDICATE_FUNCTION (void) const { return true; } |
5895 | 420 |
6223 | 421 bool is_integer_type (void) const { return true; } |
422 | |
9685 | 423 builtin_type_t builtin_type (void) const { return OCTAVE_INT_BTYP; } |
424 | |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
425 public: |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
426 |
5533 | 427 octave_int8 |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
428 int8_scalar_value (void) const { return octave_int8 (scalar); } |
5533 | 429 |
430 octave_int16 | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
431 int16_scalar_value (void) const { return octave_int16 (scalar); } |
5533 | 432 |
433 octave_int32 | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
434 int32_scalar_value (void) const { return octave_int32 (scalar); } |
5533 | 435 |
436 octave_int64 | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
437 int64_scalar_value (void) const { return octave_int64 (scalar); } |
5533 | 438 |
439 octave_uint8 | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
440 uint8_scalar_value (void) const { return octave_uint8 (scalar); } |
5533 | 441 |
442 octave_uint16 | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
443 uint16_scalar_value (void) const { return octave_uint16 (scalar); } |
5533 | 444 |
445 octave_uint32 | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
446 uint32_scalar_value (void) const { return octave_uint32 (scalar); } |
5533 | 447 |
448 octave_uint64 | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
449 uint64_scalar_value (void) const { return octave_uint64 (scalar); } |
5533 | 450 |
451 int8NDArray | |
452 int8_array_value (void) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
453 { return int8NDArray (dim_vector (1, 1), int8_scalar_value ()); } |
4904 | 454 |
5533 | 455 int16NDArray |
456 int16_array_value (void) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
457 { return int16NDArray (dim_vector (1, 1), int16_scalar_value ()); } |
5533 | 458 |
459 int32NDArray | |
460 int32_array_value (void) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
461 { return int32NDArray (dim_vector (1, 1), int32_scalar_value ()); } |
5533 | 462 |
463 int64NDArray | |
464 int64_array_value (void) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
465 { return int64NDArray (dim_vector (1, 1), int64_scalar_value ()); } |
5533 | 466 |
467 uint8NDArray | |
468 uint8_array_value (void) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
469 { return uint8NDArray (dim_vector (1, 1), uint8_scalar_value ()); } |
5533 | 470 |
471 uint16NDArray | |
472 uint16_array_value (void) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
473 { return uint16NDArray (dim_vector (1, 1), uint16_scalar_value ()); } |
5533 | 474 |
475 uint32NDArray | |
476 uint32_array_value (void) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
477 { return uint32NDArray (dim_vector (1, 1), uint32_scalar_value ()); } |
5533 | 478 |
479 uint64NDArray | |
480 uint64_array_value (void) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
481 { return uint64NDArray (dim_vector (1, 1), uint64_scalar_value ()); } |
4904 | 482 |
5731 | 483 octave_value resize (const dim_vector& dv, bool fill = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
484 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
485 if (fill) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
486 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
487 intNDArray<OCTAVE_INT_T> retval (dv, 0); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
488 if (dv.numel ()) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
489 retval(0) = scalar; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
490 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
491 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
492 else |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
493 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
494 intNDArray<OCTAVE_INT_T> retval (dv); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
495 if (dv.numel ()) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
496 retval(0) = scalar; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
497 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
498 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
499 } |
4982 | 500 |
7198 | 501 double double_value (bool = false) const { return scalar.double_value (); } |
4983 | 502 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
503 float float_value (bool = false) const { return scalar.float_value (); } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
504 |
7198 | 505 double scalar_value (bool = false) const { return scalar.double_value (); } |
4982 | 506 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
507 float float_scalar_value (bool = false) const |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
508 { return scalar.float_value (); } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
509 |
6214 | 510 Matrix |
511 matrix_value (bool = false) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
512 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
513 Matrix retval (1, 1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
514 retval(0,0) = scalar.double_value (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
515 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
516 } |
6214 | 517 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
518 FloatMatrix |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
519 float_matrix_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
520 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
521 FloatMatrix retval (1, 1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
522 retval(0,0) = scalar.float_value (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
523 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
524 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
525 |
6214 | 526 ComplexMatrix |
527 complex_matrix_value (bool = false) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
528 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
529 ComplexMatrix retval (1, 1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
530 retval(0,0) = Complex (scalar.double_value ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
531 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
532 } |
6214 | 533 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
534 FloatComplexMatrix |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
535 float_complex_matrix_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
536 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
537 FloatComplexMatrix retval (1, 1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
538 retval(0,0) = FloatComplex (scalar.float_value ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
539 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
540 } |
6214 | 541 |
4915 | 542 NDArray |
543 array_value (bool = false) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
544 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
545 NDArray retval (dim_vector (1, 1)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
546 retval(0) = scalar.double_value (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
547 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
548 } |
4963 | 549 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
550 FloatNDArray |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
551 float_array_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
552 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
553 FloatNDArray retval (dim_vector (1, 1)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
554 retval(0) = scalar.float_value (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
555 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
556 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
557 |
4963 | 558 ComplexNDArray |
559 complex_array_value (bool = false) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
560 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
561 ComplexNDArray retval (dim_vector (1, 1)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
562 retval(0) = FloatComplex (scalar.double_value ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
563 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
564 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
565 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
566 FloatComplexNDArray |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
567 float_complex_array_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
568 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
569 FloatComplexNDArray retval (dim_vector (1, 1)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
570 retval(0) = FloatComplex (scalar.float_value ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
571 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
572 } |
4915 | 573 |
12645
d3ccd2e37de6
Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
574 bool bool_value (bool warn = false) const |
d3ccd2e37de6
Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
575 { |
d3ccd2e37de6
Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
576 if (warn && scalar != 0.0 && scalar != 1.0) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21055
diff
changeset
|
577 warn_logical_conversion (); |
12645
d3ccd2e37de6
Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
578 |
d3ccd2e37de6
Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
579 return scalar.bool_value (); |
d3ccd2e37de6
Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
580 } |
d3ccd2e37de6
Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
581 |
5898 | 582 boolNDArray |
5943 | 583 bool_array_value (bool warn = false) const |
5898 | 584 { |
585 boolNDArray retval (dim_vector (1, 1)); | |
5943 | 586 |
587 if (warn && scalar != 0.0 && scalar != 1.0) | |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21055
diff
changeset
|
588 warn_logical_conversion (); |
5943 | 589 |
7198 | 590 retval(0) = scalar.bool_value (); |
5943 | 591 |
5898 | 592 return retval; |
593 } | |
594 | |
5533 | 595 charNDArray |
596 char_array_value (bool = false) const | |
597 { | |
598 charNDArray retval (dim_vector (1, 1)); | |
7198 | 599 retval(0) = scalar.char_value (); |
5533 | 600 return retval; |
601 } | |
602 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
603 void increment (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
604 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
605 scalar += OCTAVE_INT_T (1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
606 } |
5829 | 607 |
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:
7999
diff
changeset
|
608 void decrement (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
609 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
610 scalar -= OCTAVE_INT_T (1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
611 } |
5829 | 612 |
18130
e473c4853afc
enable non-integer ranges as indices by default and deprecate preference
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
613 idx_vector index_vector (bool /* require_integers */ = false) const { return idx_vector (scalar); } |
4938 | 614 |
4944 | 615 int write (octave_stream& os, int block_size, |
10313 | 616 oct_data_conv::data_type output_type, octave_idx_type skip, |
617 oct_mach_info::float_format flt_fmt) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
618 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
619 return os.write (OCTAVE_VALUE_INT_NDARRAY_EXTRACTOR_FUNCTION (), |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
620 block_size, output_type, skip, flt_fmt); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
621 } |
4944 | 622 |
5900 | 623 // Unsafe. This function exists to support the MEX interface. |
624 // You should not use it anywhere else. | |
625 void *mex_get_data (void) const { return scalar.mex_get_data (); } | |
626 | |
627 mxArray *as_mxArray (void) const | |
628 { | |
629 mxArray *retval = new mxArray (OCTAVE_INT_MX_CLASS, 1, 1, mxREAL); | |
630 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
631 OCTAVE_INT_T::val_type *pr = static_cast<OCTAVE_INT_T::val_type *> |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
632 (retval->get_data ()); |
5900 | 633 |
634 pr[0] = scalar.value (); | |
635 | |
636 return retval; | |
637 } | |
638 | |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
639 octave_value map (unary_mapper_t umap) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
640 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
641 switch (umap) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
642 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
643 case umap_abs: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
644 return scalar.abs (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
645 case umap_signum: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
646 return scalar.signum (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
647 case umap_ceil: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
648 case umap_conj: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
649 case umap_fix: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
650 case umap_floor: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
651 case umap_real: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
652 case umap_round: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
653 return scalar; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
654 case umap_imag: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
655 return OCTAVE_INT_T (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
656 case umap_isnan: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
657 case umap_isna: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
658 case umap_isinf: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
659 return false; |
21013
7f4c6d594e3d
Finish renaming mapper function finite to isfinite.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
660 case umap_isfinite: |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
661 return true; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
662 |
18196
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
663 // Special cases for Matlab compatibility. |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
664 case umap_xtolower: |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
665 case umap_xtoupper: |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
666 return scalar; |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
667 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
668 default: |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
669 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
670 octave_scalar m (scalar_value ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
671 return m.map (umap); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
672 } |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
673 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
674 } |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7201
diff
changeset
|
675 |
4904 | 676 private: |
677 | |
678 | |
679 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA | |
680 }; |