annotate libinterp/octave-value/ov-intx.h @ 24224:ff81c6772664

avoid issue with link-time optimization With link-time optimization, the value used for the HDF5 save type was not working correctly for Octave int types. It seems that the templated load and save functions were recognized as duplicates and only one version was used, even though they needed to be different. This patch attempts to avoid that. * ov-base-int.h, ov-base-int.cc (octave_base_int<T>::load_hdf5_internal): Rename from octave_base_int<T>::load_hdf5. Pass HDF5 save type as arg. (octave_base_int<T>::save_hdf5_internal): Rename from octave_base_int<T>::save_hdf5. Pass HDF5 save type as arg. * ov-intx.h (OCTAVE_VALUE_INT_MATRIX_T::load_hdf5, OCTAVE_VALUE_INT_MATRIX_T::save_hdf5, OCTAVE_VALUE_INT_SCALAR_T:load_hdf5, OCTAVE_VALUE_INT_SCALAR_T:save_hdf5): New declarations. * ov-int16.cc, ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc: Define load_hdf5 and save_hdf5 functions.
author John W. Eaton <jwe@octave.org>
date Thu, 09 Nov 2017 18:20:19 -0500
parents 2230f9e10fb3
children b8cb5a05955e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
1 /*
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
2
23219
3ac9f9ecfae5 maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
3 Copyright (C) 2004-2017 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
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
5
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
7
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
9 under the terms of the GNU General Public License as published by
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
10 the Free Software Foundation; either version 3 of the License, or
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
11 (at your option) any later version.
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
12
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
13 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
14 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
16 GNU General Public License for more details.
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
17
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6693
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6693
diff changeset
20 <http://www.gnu.org/licenses/>.
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
21
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
22 */
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
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
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
31 #include <cstdlib>
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
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
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
34 #include <string>
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
35
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
36 #include "mx-base.h"
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
37 #include "str-vec.h"
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
38
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
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
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
41 #include "oct-stream.h"
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
42 #include "ov-base.h"
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
43 #include "ov-base-int.h"
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
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
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
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
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
50 class
6693
768d3ad80bbf [project @ 2007-06-06 05:18:54 by jwe]
jwe
parents: 6686
diff changeset
51 OCTINTERP_API
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
52 OCTAVE_VALUE_INT_MATRIX_T
23534
b6498c088fca maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents: 23446
diff changeset
53 : public octave_base_int_matrix<intNDArray<OCTAVE_INT_T>>
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
54 {
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
55 public:
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
56
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
57 OCTAVE_VALUE_INT_MATRIX_T (void)
23534
b6498c088fca maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents: 23446
diff changeset
58 : octave_base_int_matrix<intNDArray<OCTAVE_INT_T>> () { }
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
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)
23534
b6498c088fca maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents: 23446
diff changeset
61 : octave_base_int_matrix<intNDArray<OCTAVE_INT_T>> (nda) { }
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
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)
23534
b6498c088fca maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents: 23446
diff changeset
64 : octave_base_int_matrix<intNDArray<OCTAVE_INT_T>>
8321
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
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
66
22868
87e3163f6c87 use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents: 22859
diff changeset
67 ~OCTAVE_VALUE_INT_MATRIX_T (void) = default;
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
68
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
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
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
71
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
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
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
74
6069
67b1a61a85ce [project @ 2006-10-21 14:33:53 by jwe]
jwe
parents: 5943
diff changeset
75 bool OCTAVE_TYPE_PREDICATE_FUNCTION (void) const { return true; }
5895
b9c45e0cf685 [project @ 2006-07-19 01:57:44 by jwe]
jwe
parents: 5885
diff changeset
76
23580
2230f9e10fb3 maint: Deprecate is_integer_type and replace with isinteger.
Rik <rik@octave.org>
parents: 23577
diff changeset
77 bool isinteger (void) const { return true; }
6223
a6cc01dd09f9 [project @ 2007-01-03 20:59:28 by jwe]
jwe
parents: 6214
diff changeset
78
9685
e793865ede63 implement builtin_type
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
79 builtin_type_t builtin_type (void) const { return OCTAVE_INT_BTYP; }
e793865ede63 implement builtin_type
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
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
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
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
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
85
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
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
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
88
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
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
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
91
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
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
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
94
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
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
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
97
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
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
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
100
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
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
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
103
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
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
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
106
4982
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
107 double
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
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
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
111
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23534
diff changeset
112 if (isempty ())
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
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
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
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
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
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23534
diff changeset
128 if (isempty ())
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
13aaef87cf18 [project @ 2004-09-10 13:51:29 by jwe]
jwe
parents: 4982
diff changeset
139 double scalar_value (bool = false) const { return double_value (); }
4982
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
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
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
143 Matrix
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
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 ();
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21244
diff changeset
148 if (dv.ndims () > 2)
17787
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
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
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 ();
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21244
diff changeset
165 if (dv.ndims () > 2)
17787
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
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
177 ComplexMatrix
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
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 ();
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21244
diff changeset
182 if (dv.ndims () > 2)
17787
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
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
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 ();
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21244
diff changeset
199 if (dv.ndims () > 2)
17787
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
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
211 NDArray
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
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
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
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
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
233 ComplexNDArray
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
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
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
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
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
255 boolNDArray
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
256 bool_array_value (bool warn = false) const
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
257 {
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
258 boolNDArray retval (dims ());
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
259
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
260 octave_idx_type nel = numel ();
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
261
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
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
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
264
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
265 bool *vec = retval.fortran_vec ();
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
266 for (octave_idx_type i = 0; i < nel; i++)
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
267 vec[i] = matrix(i).bool_value ();
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
268
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
269 return retval;
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
270 }
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
271
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
272 charNDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
273 char_array_value (bool = false) const
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
274 {
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
275 charNDArray retval (dims ());
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
276
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
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
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
279 char *vec = retval.fortran_vec ();
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
280 for (octave_idx_type i = 0; i < nel; i++)
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
281 vec[i] = matrix(i).char_value ();
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
282
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
283 return retval;
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
284 }
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
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
93785a1b0f97 [project @ 2006-05-23 18:34:10 by jwe]
jwe
parents: 5781
diff changeset
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
703d97b89507 [project @ 2004-08-09 20:21:59 by jwe]
jwe
parents: 4915
diff changeset
306
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
307 int write (octave::stream& os, int block_size,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
308 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: 21660
diff changeset
309 octave::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
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
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.
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
314 void * mex_get_data (void) const { return matrix.mex_get_data (); }
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
315
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
316 mxArray * as_mxArray (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
317 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
318 mxArray *retval = new mxArray (OCTAVE_INT_MX_CLASS, dims (), mxREAL);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
322
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6223
diff changeset
323 mwSize nel = numel ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
324
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
325 const OCTAVE_INT_T *p = matrix.data ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
326
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6223
diff changeset
327 for (mwIndex i = 0; i < nel; i++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
328 pr[i] = p[i].value ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
329
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
330 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
331 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
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
24224
ff81c6772664 avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents: 23580
diff changeset
372 bool save_hdf5 (octave_hdf5_id loc_id, const char *name, bool flag);
ff81c6772664 avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents: 23580
diff changeset
373
ff81c6772664 avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents: 23580
diff changeset
374 bool load_hdf5 (octave_hdf5_id loc_id, const char *name);
ff81c6772664 avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents: 23580
diff changeset
375
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
376 private:
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
377
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
378 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
379 };
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
380
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
381 class
6693
768d3ad80bbf [project @ 2007-06-06 05:18:54 by jwe]
jwe
parents: 6686
diff changeset
382 OCTINTERP_API
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
383 OCTAVE_VALUE_INT_SCALAR_T
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
384 : public octave_base_int_scalar<OCTAVE_INT_T>
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
385 {
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
386 public:
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
387
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
388 OCTAVE_VALUE_INT_SCALAR_T (void)
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
389 : octave_base_int_scalar<OCTAVE_INT_T> () { }
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
390
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
391 OCTAVE_VALUE_INT_SCALAR_T (const OCTAVE_INT_T& nda)
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
392 : octave_base_int_scalar<OCTAVE_INT_T> (nda) { }
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
393
22868
87e3163f6c87 use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents: 22859
diff changeset
394 ~OCTAVE_VALUE_INT_SCALAR_T (void) = default;
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
395
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
396 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
397 { return new OCTAVE_VALUE_INT_SCALAR_T (*this); }
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
398
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
399 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
400 { return new OCTAVE_VALUE_INT_MATRIX_T (); }
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
401
5885
bd3041e30d97 [project @ 2006-07-14 20:29:35 by jwe]
jwe
parents: 5829
diff changeset
402 octave_value do_index_op (const octave_value_list& idx,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
403 bool resize_ok = false)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
404 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
405 // 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
406 //
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
407 // 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
408 //
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
409 // and similar constructions. Hmm...
4964
269c3d6c0569 [project @ 2004-09-04 01:16:28 by jwe]
jwe
parents: 4963
diff changeset
410
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
411 // 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
412 // 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
413 // to this problem.
4964
269c3d6c0569 [project @ 2004-09-04 01:16:28 by jwe]
jwe
parents: 4963
diff changeset
414
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
415 octave_value tmp
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
416 (new OCTAVE_VALUE_INT_MATRIX_T
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
417 (OCTAVE_VALUE_INT_NDARRAY_EXTRACTOR_FUNCTION ()));
4964
269c3d6c0569 [project @ 2004-09-04 01:16:28 by jwe]
jwe
parents: 4963
diff changeset
418
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
419 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
420 }
4964
269c3d6c0569 [project @ 2004-09-04 01:16:28 by jwe]
jwe
parents: 4963
diff changeset
421
6069
67b1a61a85ce [project @ 2006-10-21 14:33:53 by jwe]
jwe
parents: 5943
diff changeset
422 bool OCTAVE_TYPE_PREDICATE_FUNCTION (void) const { return true; }
5895
b9c45e0cf685 [project @ 2006-07-19 01:57:44 by jwe]
jwe
parents: 5885
diff changeset
423
23580
2230f9e10fb3 maint: Deprecate is_integer_type and replace with isinteger.
Rik <rik@octave.org>
parents: 23577
diff changeset
424 bool isinteger (void) const { return true; }
6223
a6cc01dd09f9 [project @ 2007-01-03 20:59:28 by jwe]
jwe
parents: 6214
diff changeset
425
9685
e793865ede63 implement builtin_type
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
426 builtin_type_t builtin_type (void) const { return OCTAVE_INT_BTYP; }
e793865ede63 implement builtin_type
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
427
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
428 public:
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
429
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
430 octave_int8
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
431 int8_scalar_value (void) const { return octave_int8 (scalar); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
432
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
433 octave_int16
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
434 int16_scalar_value (void) const { return octave_int16 (scalar); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
435
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
436 octave_int32
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
437 int32_scalar_value (void) const { return octave_int32 (scalar); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
438
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
439 octave_int64
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
440 int64_scalar_value (void) const { return octave_int64 (scalar); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
441
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
442 octave_uint8
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
443 uint8_scalar_value (void) const { return octave_uint8 (scalar); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
444
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
445 octave_uint16
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
446 uint16_scalar_value (void) const { return octave_uint16 (scalar); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
447
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
448 octave_uint32
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
449 uint32_scalar_value (void) const { return octave_uint32 (scalar); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
450
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
451 octave_uint64
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
452 uint64_scalar_value (void) const { return octave_uint64 (scalar); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
453
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
454 int8NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
455 int8_array_value (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
456 { return int8NDArray (dim_vector (1, 1), int8_scalar_value ()); }
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
457
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
458 int16NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
459 int16_array_value (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
460 { return int16NDArray (dim_vector (1, 1), int16_scalar_value ()); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
461
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
462 int32NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
463 int32_array_value (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
464 { return int32NDArray (dim_vector (1, 1), int32_scalar_value ()); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
465
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
466 int64NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
467 int64_array_value (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
468 { return int64NDArray (dim_vector (1, 1), int64_scalar_value ()); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
469
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
470 uint8NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
471 uint8_array_value (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
472 { return uint8NDArray (dim_vector (1, 1), uint8_scalar_value ()); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
473
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
474 uint16NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
475 uint16_array_value (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
476 { return uint16NDArray (dim_vector (1, 1), uint16_scalar_value ()); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
477
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
478 uint32NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
479 uint32_array_value (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
480 { return uint32NDArray (dim_vector (1, 1), uint32_scalar_value ()); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
481
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
482 uint64NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
483 uint64_array_value (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
484 { return uint64NDArray (dim_vector (1, 1), uint64_scalar_value ()); }
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
485
5731
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5533
diff changeset
486 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
487 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
488 if (fill)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
489 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
490 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
491 if (dv.numel ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
492 retval(0) = scalar;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
493 return retval;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
494 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
495 else
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
496 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
497 intNDArray<OCTAVE_INT_T> retval (dv);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
498 if (dv.numel ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
499 retval(0) = scalar;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
500 return retval;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
501 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
502 }
4982
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
503
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
504 double double_value (bool = false) const { return scalar.double_value (); }
4983
13aaef87cf18 [project @ 2004-09-10 13:51:29 by jwe]
jwe
parents: 4982
diff changeset
505
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
506 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
507
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
508 double scalar_value (bool = false) const { return scalar.double_value (); }
4982
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
509
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
510 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
511 { return scalar.float_value (); }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
512
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
513 Matrix
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
514 matrix_value (bool = false) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
515 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
516 Matrix retval (1, 1);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
517 retval(0,0) = scalar.double_value ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
518 return retval;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
519 }
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
520
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
521 FloatMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
522 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
523 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
524 FloatMatrix retval (1, 1);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
525 retval(0,0) = scalar.float_value ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
526 return retval;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
527 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
528
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
529 ComplexMatrix
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
530 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
531 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
532 ComplexMatrix retval (1, 1);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
533 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
534 return retval;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
535 }
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
536
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
537 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
538 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
539 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
540 FloatComplexMatrix retval (1, 1);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
541 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
542 return retval;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
543 }
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
544
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
545 NDArray
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
546 array_value (bool = false) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
547 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
548 NDArray retval (dim_vector (1, 1));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
549 retval(0) = scalar.double_value ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
550 return retval;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
551 }
4963
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
552
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
553 FloatNDArray
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
554 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
555 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
556 FloatNDArray retval (dim_vector (1, 1));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
557 retval(0) = scalar.float_value ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
558 return retval;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
559 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
560
4963
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
561 ComplexNDArray
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
562 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
563 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
564 ComplexNDArray retval (dim_vector (1, 1));
22859
adc66f043cfc avoid double -> float -> double type conversion
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
565 retval(0) = Complex (scalar.double_value ());
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
566 return retval;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
567 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
568
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
569 FloatComplexNDArray
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
570 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
571 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
572 FloatComplexNDArray retval (dim_vector (1, 1));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
573 retval(0) = FloatComplex (scalar.float_value ());
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
574 return retval;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
575 }
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
576
12645
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
577 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
578 {
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
579 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
580 warn_logical_conversion ();
12645
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
581
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
582 return scalar.bool_value ();
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
583 }
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
584
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
585 boolNDArray
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
586 bool_array_value (bool warn = false) const
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
587 {
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
588 boolNDArray retval (dim_vector (1, 1));
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
589
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
590 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
591 warn_logical_conversion ();
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
592
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
593 retval(0) = scalar.bool_value ();
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
594
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
595 return retval;
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
596 }
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
597
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
598 charNDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
599 char_array_value (bool = false) const
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
600 {
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
601 charNDArray retval (dim_vector (1, 1));
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
602 retval(0) = scalar.char_value ();
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
603 return retval;
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
604 }
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
605
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
606 void increment (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
607 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
608 scalar += OCTAVE_INT_T (1);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
609 }
5829
93785a1b0f97 [project @ 2006-05-23 18:34:10 by jwe]
jwe
parents: 5781
diff changeset
610
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
611 void decrement (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
612 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
613 scalar -= OCTAVE_INT_T (1);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
614 }
5829
93785a1b0f97 [project @ 2006-05-23 18:34:10 by jwe]
jwe
parents: 5781
diff changeset
615
18130
e473c4853afc enable non-integer ranges as indices by default and deprecate preference
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
616 idx_vector index_vector (bool /* require_integers */ = false) const { return idx_vector (scalar); }
4938
703d97b89507 [project @ 2004-08-09 20:21:59 by jwe]
jwe
parents: 4915
diff changeset
617
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
618 int write (octave::stream& os, int block_size,
23093
8aba6d170887 fix prototype of octave_base_int<T>::write (bug #50157)
John W. Eaton <jwe@octave.org>
parents: 23084
diff changeset
619 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: 21660
diff changeset
620 octave::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
621 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
622 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
623 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
624 }
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
625
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
626 // Unsafe. This function exists to support the MEX interface.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
627 // You should not use it anywhere else.
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
628 void * mex_get_data (void) const { return scalar.mex_get_data (); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
629
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
630 mxArray * as_mxArray (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
631 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
632 mxArray *retval = new mxArray (OCTAVE_INT_MX_CLASS, 1, 1, mxREAL);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
633
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
634 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
635 (retval->get_data ());
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
636
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
637 pr[0] = scalar.value ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
638
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
639 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
640 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
641
9812
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
642 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
643 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
644 switch (umap)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
645 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
646 case umap_abs:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
647 return scalar.abs ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
648 case umap_signum:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
649 return scalar.signum ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
650 case umap_ceil:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
651 case umap_conj:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
652 case umap_fix:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
653 case umap_floor:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
654 case umap_real:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
655 case umap_round:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
656 return scalar;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
657 case umap_imag:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
658 return OCTAVE_INT_T ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
659 case umap_isnan:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
660 case umap_isna:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
661 case umap_isinf:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
662 return false;
21013
7f4c6d594e3d Finish renaming mapper function finite to isfinite.
Rik <rik@octave.org>
parents: 19697
diff changeset
663 case umap_isfinite:
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
664 return true;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
665
18196
1b6db9303933 allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents: 18130
diff changeset
666 // 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
667 case umap_xtolower:
1b6db9303933 allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents: 18130
diff changeset
668 case umap_xtoupper:
1b6db9303933 allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents: 18130
diff changeset
669 return scalar;
1b6db9303933 allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents: 18130
diff changeset
670
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
671 default:
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 octave_scalar m (scalar_value ());
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
674 return m.map (umap);
9812
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
675 }
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
676 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
677 }
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
678
24224
ff81c6772664 avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents: 23580
diff changeset
679 bool save_hdf5 (octave_hdf5_id loc_id, const char *name, bool flag);
ff81c6772664 avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents: 23580
diff changeset
680
ff81c6772664 avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents: 23580
diff changeset
681 bool load_hdf5 (octave_hdf5_id loc_id, const char *name);
ff81c6772664 avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents: 23580
diff changeset
682
ff81c6772664 avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents: 23580
diff changeset
683 private:
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
684
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
685 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
686 };