Mercurial > octave
annotate libinterp/octave-value/ov-intx.h @ 28126:4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
* mexproto.h, mex.cc, mxarray.h (mxMakeArrayReal, mxMakeArrayComplex,
mxGetDoubles, mxGetSingles, mxGetInt8s, mxGetInt16s, mxGetInt32s,
mxGetInt64s, mxGetUint8s, mxGetUint16s, mxGetUint32s, mxGetUint64s,
mxGetComplexDoubles, mxGetComplexSingles, mxSetDoubles, mxSetSingles,
mxSetInt8s, mxSetInt16s, mxSetInt32s, mxSetInt64s, mxSetUint8s,
mxSetUint16s, mxSetUint32s, mxSetUint64s, mxSetComplexDoubles,
mxSetComplexSingles): New functions. Provide corresponding member
functions in mxArray class hierarchy to handle the actual operations.
(mxGetComplexInt8s, mxGetComplexInt16s, mxGetComplexInt32s,
mxGetComplexInt64s, mxGetComplexUint8s, mxGetComplexUint16s,
mxGetComplexUint32s, mxGetComplexUint64s, mxSetComplexInt8s,
mxSetComplexInt16s, mxSetComplexInt32s, mxSetComplexInt64s,
mxSetComplexUint8s, mxSetComplexUint16s, mxSetComplexUint32s,
mxSetComplexUint64s): Add prototypes and functions, but leave
commented out since we don't have complex integer data.
(class mxArray_number, class mxArray_sparse):
Handle interleaved complex data. In mxArray_octave_value and
mxArray_matlab constructors, handle interleaved flag in constructor to
determine data layout to use when creating mxArray_number or
mxArray_sparse objects.
(mex::make_value): Check flag in mex function to determine whether to
create arrays with interleaved complex.
* ov.h, ov.cc, ov-base.h, ov-base.cc, ov-base-diag.h, ov-base-diag.cc,
ov-bool-mat.h, ov-bool-mat.cc, ov-bool-sparse.h, ov-bool-sparse.cc,
ov-bool.h, ov-bool.cc, ov-cell.h, ov-cell.cc, ov-ch-mat.h,
ov-ch-mat.cc, ov-class.h, ov-class.cc, ov-complex.h, ov-complex.cc,
ov-cx-mat.h, ov-cx-mat.cc, ov-cx-sparse.h, ov-cx-sparse.cc,
ov-float.h, ov-float.cc, ov-flt-complex.h, ov-flt-complex.cc,
ov-flt-cx-mat.h, ov-flt-cx-mat.cc, ov-flt-re-mat.h, ov-flt-re-mat.cc,
ov-intx.h, ov-lazy-idx.h, ov-perm.h, ov-perm.cc, ov-range.h,
ov-range.cc, ov-re-mat.h, ov-re-mat.cc, ov-re-sparse.h,
ov-re-sparse.cc, ov-scalar.h, ov-scalar.cc, ov-struct.h, ov-struct.cc:
In all as_mxArray methods, handle new interleaved input to optionally
create objects that will use interleaved complex data.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 18 Feb 2020 13:16:41 -0500 |
parents | bd51beb6205e |
children | 70cdf8de553d |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
3 // Copyright (C) 2004-2020 The Octave Project Developers |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
4904 | 25 |
21213
f7d1050b9b53
maint: Clean up various usages of #ifdef.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
26 // 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
|
27 // The build will break (2/6/2016). |
f7d1050b9b53
maint: Clean up various usages of #ifdef.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
28 // #if ! defined (octave_ov_intx_h) |
f7d1050b9b53
maint: Clean up various usages of #ifdef.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
29 // #define octave_ov_intx_h 1 |
f7d1050b9b53
maint: Clean up various usages of #ifdef.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
30 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21213
diff
changeset
|
31 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21213
diff
changeset
|
32 |
4904 | 33 #include <cstdlib> |
34 | |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
35 #include <iosfwd> |
4904 | 36 #include <string> |
37 | |
38 #include "mx-base.h" | |
39 #include "str-vec.h" | |
40 | |
41 #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
|
42 #include "mxarray.h" |
4944 | 43 #include "oct-stream.h" |
4904 | 44 #include "ov-base.h" |
45 #include "ov-base-int.h" | |
46 #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
|
47 #include "errwarn.h" |
4904 | 48 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7201
diff
changeset
|
49 #include "ov-re-mat.h" |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7201
diff
changeset
|
50 #include "ov-scalar.h" |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7201
diff
changeset
|
51 |
4904 | 52 class |
6693 | 53 OCTINTERP_API |
4904 | 54 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
|
55 : public octave_base_int_matrix<intNDArray<OCTAVE_INT_T>> |
4904 | 56 { |
57 public: | |
58 | |
59 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
|
60 : octave_base_int_matrix<intNDArray<OCTAVE_INT_T>> () { } |
4904 | 61 |
8321
69b6127f6962
better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents:
8039
diff
changeset
|
62 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
|
63 : octave_base_int_matrix<intNDArray<OCTAVE_INT_T>> (nda) { } |
4904 | 64 |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9685
diff
changeset
|
65 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
|
66 : 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
|
67 (intNDArray<OCTAVE_INT_T> (nda)) { } |
7064 | 68 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22859
diff
changeset
|
69 ~OCTAVE_VALUE_INT_MATRIX_T (void) = default; |
4904 | 70 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
71 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
|
72 { return new OCTAVE_VALUE_INT_MATRIX_T (*this); } |
4904 | 73 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
74 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
|
75 { return new OCTAVE_VALUE_INT_MATRIX_T (); } |
4904 | 76 |
6069 | 77 bool OCTAVE_TYPE_PREDICATE_FUNCTION (void) const { return true; } |
5895 | 78 |
23580
2230f9e10fb3
maint: Deprecate is_integer_type and replace with isinteger.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
79 bool isinteger (void) const { return true; } |
6223 | 80 |
9685 | 81 builtin_type_t builtin_type (void) const { return OCTAVE_INT_BTYP; } |
82 | |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
83 public: |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
84 |
5533 | 85 int8NDArray |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
86 int8_array_value (void) const { return int8NDArray (matrix); } |
5533 | 87 |
88 int16NDArray | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
89 int16_array_value (void) const { return int16NDArray (matrix); } |
5533 | 90 |
91 int32NDArray | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
92 int32_array_value (void) const { return int32NDArray (matrix); } |
5533 | 93 |
94 int64NDArray | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
95 int64_array_value (void) const { return int64NDArray (matrix); } |
5533 | 96 |
97 uint8NDArray | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
98 uint8_array_value (void) const { return uint8NDArray (matrix); } |
5533 | 99 |
100 uint16NDArray | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
101 uint16_array_value (void) const { return uint16NDArray (matrix); } |
5533 | 102 |
103 uint32NDArray | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
104 uint32_array_value (void) const { return uint32NDArray (matrix); } |
5533 | 105 |
106 uint64NDArray | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
107 uint64_array_value (void) const { return uint64NDArray (matrix); } |
4904 | 108 |
4982 | 109 double |
110 double_value (bool = false) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
111 { |
26382
2408f3b6a6db
ov-intx.h: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
112 double retval; |
4982 | 113 |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23534
diff
changeset
|
114 if (isempty ()) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21055
diff
changeset
|
115 err_invalid_conversion (type_name (), "real scalar"); |
4982 | 116 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
117 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
|
118 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
|
119 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
120 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
|
121 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
122 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
123 } |
4982 | 124 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
125 float |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
126 float_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
127 { |
26382
2408f3b6a6db
ov-intx.h: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
128 float retval; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
129 |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23534
diff
changeset
|
130 if (isempty ()) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21055
diff
changeset
|
131 err_invalid_conversion (type_name (), "real scalar"); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
132 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
133 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
|
134 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
|
135 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
136 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
|
137 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
138 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
139 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
140 |
4983 | 141 double scalar_value (bool = false) const { return double_value (); } |
4982 | 142 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
143 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
|
144 |
6214 | 145 Matrix |
146 matrix_value (bool = false) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
147 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
148 Matrix retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
149 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
|
150 if (dv.ndims () > 2) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
151 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
|
152 |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
153 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
|
154 double *vec = retval.fortran_vec (); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
155 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
|
156 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
|
157 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
|
158 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
159 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
160 } |
6214 | 161 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
162 FloatMatrix |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
163 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
|
164 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
165 FloatMatrix retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
166 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
|
167 if (dv.ndims () > 2) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
168 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
|
169 |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
170 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
|
171 float *vec = retval.fortran_vec (); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
172 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
|
173 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
|
174 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
|
175 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
176 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
177 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
178 |
6214 | 179 ComplexMatrix |
180 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
|
181 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
182 ComplexMatrix retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
183 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
|
184 if (dv.ndims () > 2) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
185 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
|
186 |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
187 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
|
188 Complex *vec = retval.fortran_vec (); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
189 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
|
190 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
|
191 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
|
192 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
193 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
194 } |
6214 | 195 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
196 FloatComplexMatrix |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
197 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
|
198 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
199 FloatComplexMatrix retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
200 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
|
201 if (dv.ndims () > 2) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
202 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
|
203 |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
204 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
|
205 FloatComplex *vec = retval.fortran_vec (); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21013
diff
changeset
|
206 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
|
207 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
|
208 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
|
209 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
210 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
211 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
212 |
4915 | 213 NDArray |
214 array_value (bool = false) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
215 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
216 NDArray retval (matrix.dims ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
217 double *vec = retval.fortran_vec (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
218 octave_idx_type nel = matrix.numel (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
219 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
|
220 vec[i] = matrix(i).double_value (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
221 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
222 } |
4963 | 223 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
224 FloatNDArray |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
225 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
|
226 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
227 FloatNDArray retval (matrix.dims ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
228 float *vec = retval.fortran_vec (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
229 octave_idx_type nel = matrix.numel (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
230 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
|
231 vec[i] = matrix(i).float_value (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
232 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
233 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
234 |
4963 | 235 ComplexNDArray |
236 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
|
237 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
238 ComplexNDArray retval (matrix.dims ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
239 Complex *vec = retval.fortran_vec (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
240 octave_idx_type nel = matrix.numel (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
241 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
|
242 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
|
243 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
244 } |
4915 | 245 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
246 FloatComplexNDArray |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
247 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
|
248 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
249 FloatComplexNDArray retval (matrix.dims ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
250 FloatComplex *vec = retval.fortran_vec (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
251 octave_idx_type nel = matrix.numel (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
252 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
|
253 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
|
254 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
255 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
256 |
5898 | 257 boolNDArray |
5943 | 258 bool_array_value (bool warn = false) const |
5898 | 259 { |
260 boolNDArray retval (dims ()); | |
261 | |
262 octave_idx_type nel = numel (); | |
5943 | 263 |
264 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
|
265 warn_logical_conversion (); |
5943 | 266 |
6214 | 267 bool *vec = retval.fortran_vec (); |
5898 | 268 for (octave_idx_type i = 0; i < nel; i++) |
7198 | 269 vec[i] = matrix(i).bool_value (); |
5898 | 270 |
271 return retval; | |
272 } | |
273 | |
5533 | 274 charNDArray |
275 char_array_value (bool = false) const | |
276 { | |
277 charNDArray retval (dims ()); | |
278 | |
279 octave_idx_type nel = numel (); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
280 |
6214 | 281 char *vec = retval.fortran_vec (); |
5533 | 282 for (octave_idx_type i = 0; i < nel; i++) |
7198 | 283 vec[i] = matrix(i).char_value (); |
5533 | 284 |
285 return retval; | |
286 } | |
287 | |
9606
a04352386a6b
clear index cache on ++,-- operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9358
diff
changeset
|
288 // 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
|
289 void increment (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
290 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
291 matrix_ref () += OCTAVE_INT_T (1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
292 } |
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
|
293 |
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
|
294 void decrement (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
295 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
296 matrix_ref () -= OCTAVE_INT_T (1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
297 } |
5829 | 298 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9606
diff
changeset
|
299 void changesign (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
300 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
301 matrix_ref ().changesign (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
302 } |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9606
diff
changeset
|
303 |
18130
e473c4853afc
enable non-integer ranges as indices by default and deprecate preference
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
304 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
|
305 { |
e473c4853afc
enable non-integer ranges as indices by default and deprecate preference
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
306 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
|
307 } |
4938 | 308 |
23059
b98ebcd7f11c
move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
309 int write (octave::stream& os, int block_size, |
10313 | 310 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
|
311 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
|
312 { return os.write (matrix, block_size, output_type, skip, flt_fmt); } |
4944 | 313 |
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
|
314 // 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
|
315 // 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
|
316 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
|
317 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
318 mxArray * as_mxArray (bool interleaved) const |
5900 | 319 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
320 mxArray *retval = new mxArray (interleaved, OCTAVE_INT_MX_CLASS, dims (), |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
321 mxREAL); |
5900 | 322 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
323 OCTAVE_INT_T::val_type *pd |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
324 = static_cast<OCTAVE_INT_T::val_type *> (retval->get_data ()); |
5900 | 325 |
6686 | 326 mwSize nel = numel (); |
5900 | 327 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
328 const OCTAVE_INT_T *pdata = matrix.data (); |
5900 | 329 |
6686 | 330 for (mwIndex i = 0; i < nel; i++) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
331 pd[i] = pdata[i].value (); |
5900 | 332 |
333 return retval; | |
334 } | |
335 | |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
336 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
|
337 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
338 switch (umap) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
339 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
340 case umap_abs: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
341 return matrix.abs (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
342 case umap_signum: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
343 return matrix.signum (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
344 case umap_ceil: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
345 case umap_conj: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
346 case umap_fix: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
347 case umap_floor: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
348 case umap_real: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
349 case umap_round: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
350 return matrix; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
351 case umap_imag: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
352 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
|
353 case umap_isnan: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
354 case umap_isna: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
355 case umap_isinf: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
356 return boolNDArray (matrix.dims (), false); |
21013
7f4c6d594e3d
Finish renaming mapper function finite to isfinite.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
357 case umap_isfinite: |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
358 return boolNDArray (matrix.dims (), true); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
359 |
18196
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
360 // 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
|
361 case umap_xtolower: |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
362 case umap_xtoupper: |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
363 return matrix; |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
364 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
365 default: |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
366 { |
18196
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
367 // 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
|
368 // double here. |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
369 octave_matrix m (array_value ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
370 return m.map (umap); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
371 } |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
372 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
373 } |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7201
diff
changeset
|
374 |
24225
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
375 bool save_hdf5 (octave_hdf5_id loc_id, const char *name, bool flag) |
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
376 { |
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
377 return save_hdf5_internal (loc_id, hdf5_save_type, name, flag); |
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
378 } |
24224
ff81c6772664
avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents:
23580
diff
changeset
|
379 |
24225
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
380 bool load_hdf5 (octave_hdf5_id loc_id, const char *name) |
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
381 { |
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
382 return load_hdf5_internal (loc_id, hdf5_save_type, name); |
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
383 } |
24224
ff81c6772664
avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents:
23580
diff
changeset
|
384 |
4904 | 385 private: |
386 | |
24225
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
387 static octave_hdf5_id hdf5_save_type; |
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
388 |
4904 | 389 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
390 }; | |
391 | |
392 class | |
6693 | 393 OCTINTERP_API |
4904 | 394 OCTAVE_VALUE_INT_SCALAR_T |
395 : public octave_base_int_scalar<OCTAVE_INT_T> | |
396 { | |
397 public: | |
398 | |
399 OCTAVE_VALUE_INT_SCALAR_T (void) | |
400 : octave_base_int_scalar<OCTAVE_INT_T> () { } | |
401 | |
402 OCTAVE_VALUE_INT_SCALAR_T (const OCTAVE_INT_T& nda) | |
403 : octave_base_int_scalar<OCTAVE_INT_T> (nda) { } | |
404 | |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22859
diff
changeset
|
405 ~OCTAVE_VALUE_INT_SCALAR_T (void) = default; |
4904 | 406 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
407 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
|
408 { return new OCTAVE_VALUE_INT_SCALAR_T (*this); } |
4904 | 409 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
410 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
|
411 { return new OCTAVE_VALUE_INT_MATRIX_T (); } |
4904 | 412 |
5885 | 413 octave_value do_index_op (const octave_value_list& idx, |
10313 | 414 bool resize_ok = false) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
415 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
416 // 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
|
417 // |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
418 // 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
|
419 // |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
420 // and similar constructions. Hmm... |
4964 | 421 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
422 // 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
|
423 // 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
|
424 // to this problem. |
4964 | 425 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
426 octave_value tmp |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
427 (new OCTAVE_VALUE_INT_MATRIX_T |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
428 (OCTAVE_VALUE_INT_NDARRAY_EXTRACTOR_FUNCTION ())); |
4964 | 429 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
430 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
|
431 } |
4964 | 432 |
6069 | 433 bool OCTAVE_TYPE_PREDICATE_FUNCTION (void) const { return true; } |
5895 | 434 |
23580
2230f9e10fb3
maint: Deprecate is_integer_type and replace with isinteger.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
435 bool isinteger (void) const { return true; } |
6223 | 436 |
9685 | 437 builtin_type_t builtin_type (void) const { return OCTAVE_INT_BTYP; } |
438 | |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
439 public: |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
440 |
5533 | 441 octave_int8 |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
442 int8_scalar_value (void) const { return octave_int8 (scalar); } |
5533 | 443 |
444 octave_int16 | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
445 int16_scalar_value (void) const { return octave_int16 (scalar); } |
5533 | 446 |
447 octave_int32 | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
448 int32_scalar_value (void) const { return octave_int32 (scalar); } |
5533 | 449 |
450 octave_int64 | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
451 int64_scalar_value (void) const { return octave_int64 (scalar); } |
5533 | 452 |
453 octave_uint8 | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
454 uint8_scalar_value (void) const { return octave_uint8 (scalar); } |
5533 | 455 |
456 octave_uint16 | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
457 uint16_scalar_value (void) const { return octave_uint16 (scalar); } |
5533 | 458 |
459 octave_uint32 | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
460 uint32_scalar_value (void) const { return octave_uint32 (scalar); } |
5533 | 461 |
462 octave_uint64 | |
10405
cc69a17ec801
remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
463 uint64_scalar_value (void) const { return octave_uint64 (scalar); } |
5533 | 464 |
465 int8NDArray | |
466 int8_array_value (void) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
467 { return int8NDArray (dim_vector (1, 1), int8_scalar_value ()); } |
4904 | 468 |
5533 | 469 int16NDArray |
470 int16_array_value (void) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
471 { return int16NDArray (dim_vector (1, 1), int16_scalar_value ()); } |
5533 | 472 |
473 int32NDArray | |
474 int32_array_value (void) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
475 { return int32NDArray (dim_vector (1, 1), int32_scalar_value ()); } |
5533 | 476 |
477 int64NDArray | |
478 int64_array_value (void) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
479 { return int64NDArray (dim_vector (1, 1), int64_scalar_value ()); } |
5533 | 480 |
481 uint8NDArray | |
482 uint8_array_value (void) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
483 { return uint8NDArray (dim_vector (1, 1), uint8_scalar_value ()); } |
5533 | 484 |
485 uint16NDArray | |
486 uint16_array_value (void) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
487 { return uint16NDArray (dim_vector (1, 1), uint16_scalar_value ()); } |
5533 | 488 |
489 uint32NDArray | |
490 uint32_array_value (void) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
491 { return uint32NDArray (dim_vector (1, 1), uint32_scalar_value ()); } |
5533 | 492 |
493 uint64NDArray | |
494 uint64_array_value (void) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
495 { return uint64NDArray (dim_vector (1, 1), uint64_scalar_value ()); } |
4904 | 496 |
5731 | 497 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
|
498 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
499 if (fill) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
500 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
501 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
|
502 if (dv.numel ()) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
503 retval(0) = scalar; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
504 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
505 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
506 else |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
507 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
508 intNDArray<OCTAVE_INT_T> retval (dv); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
509 if (dv.numel ()) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
510 retval(0) = scalar; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
511 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
512 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
513 } |
4982 | 514 |
7198 | 515 double double_value (bool = false) const { return scalar.double_value (); } |
4983 | 516 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
517 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
|
518 |
7198 | 519 double scalar_value (bool = false) const { return scalar.double_value (); } |
4982 | 520 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
521 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
|
522 { return scalar.float_value (); } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
523 |
6214 | 524 Matrix |
525 matrix_value (bool = false) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
526 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
527 Matrix retval (1, 1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
528 retval(0,0) = scalar.double_value (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
529 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
530 } |
6214 | 531 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
532 FloatMatrix |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
533 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
|
534 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
535 FloatMatrix retval (1, 1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
536 retval(0,0) = scalar.float_value (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
537 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
538 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
539 |
6214 | 540 ComplexMatrix |
541 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
|
542 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
543 ComplexMatrix retval (1, 1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
544 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
|
545 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
546 } |
6214 | 547 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
548 FloatComplexMatrix |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
549 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
|
550 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
551 FloatComplexMatrix retval (1, 1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
552 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
|
553 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
554 } |
6214 | 555 |
4915 | 556 NDArray |
557 array_value (bool = false) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
558 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
559 NDArray retval (dim_vector (1, 1)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
560 retval(0) = scalar.double_value (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
561 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
562 } |
4963 | 563 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
564 FloatNDArray |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
565 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
|
566 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
567 FloatNDArray retval (dim_vector (1, 1)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
568 retval(0) = scalar.float_value (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
569 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
570 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
571 |
4963 | 572 ComplexNDArray |
573 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
|
574 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
575 ComplexNDArray retval (dim_vector (1, 1)); |
22859
adc66f043cfc
avoid double -> float -> double type conversion
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
576 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
|
577 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
578 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
579 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
580 FloatComplexNDArray |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7636
diff
changeset
|
581 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
|
582 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
583 FloatComplexNDArray retval (dim_vector (1, 1)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
584 retval(0) = FloatComplex (scalar.float_value ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
585 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
586 } |
4915 | 587 |
12645
d3ccd2e37de6
Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
588 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
|
589 { |
d3ccd2e37de6
Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents:
11586
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 (); |
12645
d3ccd2e37de6
Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
592 |
d3ccd2e37de6
Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
593 return scalar.bool_value (); |
d3ccd2e37de6
Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
594 } |
d3ccd2e37de6
Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
595 |
5898 | 596 boolNDArray |
5943 | 597 bool_array_value (bool warn = false) const |
5898 | 598 { |
599 boolNDArray retval (dim_vector (1, 1)); | |
5943 | 600 |
601 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
|
602 warn_logical_conversion (); |
5943 | 603 |
7198 | 604 retval(0) = scalar.bool_value (); |
5943 | 605 |
5898 | 606 return retval; |
607 } | |
608 | |
5533 | 609 charNDArray |
610 char_array_value (bool = false) const | |
611 { | |
612 charNDArray retval (dim_vector (1, 1)); | |
7198 | 613 retval(0) = scalar.char_value (); |
5533 | 614 return retval; |
615 } | |
616 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
617 void increment (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
618 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
619 scalar += OCTAVE_INT_T (1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
620 } |
5829 | 621 |
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
|
622 void decrement (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
623 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
624 scalar -= OCTAVE_INT_T (1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
625 } |
5829 | 626 |
18130
e473c4853afc
enable non-integer ranges as indices by default and deprecate preference
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
627 idx_vector index_vector (bool /* require_integers */ = false) const { return idx_vector (scalar); } |
4938 | 628 |
23059
b98ebcd7f11c
move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
629 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
|
630 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
|
631 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
|
632 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
633 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
|
634 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
|
635 } |
4944 | 636 |
5900 | 637 // Unsafe. This function exists to support the MEX interface. |
638 // 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
|
639 void * mex_get_data (void) const { return scalar.mex_get_data (); } |
5900 | 640 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
641 mxArray * as_mxArray (bool interleaved) const |
5900 | 642 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
643 mxArray *retval = new mxArray (interleaved, OCTAVE_INT_MX_CLASS, 1, 1, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
644 mxREAL); |
5900 | 645 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
646 OCTAVE_INT_T::val_type *pd |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
647 = static_cast<OCTAVE_INT_T::val_type *> (retval->get_data ()); |
5900 | 648 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
649 pd[0] = scalar.value (); |
5900 | 650 |
651 return retval; | |
652 } | |
653 | |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
654 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
|
655 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
656 switch (umap) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
657 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
658 case umap_abs: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
659 return scalar.abs (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
660 case umap_signum: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
661 return scalar.signum (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
662 case umap_ceil: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
663 case umap_conj: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
664 case umap_fix: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
665 case umap_floor: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
666 case umap_real: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
667 case umap_round: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
668 return scalar; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
669 case umap_imag: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
670 return OCTAVE_INT_T (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
671 case umap_isnan: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
672 case umap_isna: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
673 case umap_isinf: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
674 return false; |
21013
7f4c6d594e3d
Finish renaming mapper function finite to isfinite.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
675 case umap_isfinite: |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
676 return true; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
677 |
18196
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
678 // 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
|
679 case umap_xtolower: |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
680 case umap_xtoupper: |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
681 return scalar; |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
18130
diff
changeset
|
682 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
683 default: |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
684 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
685 octave_scalar m (scalar_value ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
686 return m.map (umap); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
687 } |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
688 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
689 } |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7201
diff
changeset
|
690 |
24225
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
691 bool save_hdf5 (octave_hdf5_id loc_id, const char *name, bool flag) |
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
692 { |
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
693 return save_hdf5_internal (loc_id, hdf5_save_type, name, flag); |
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
694 } |
24224
ff81c6772664
avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents:
23580
diff
changeset
|
695 |
24225
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
696 bool load_hdf5 (octave_hdf5_id loc_id, const char *name) |
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
697 { |
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
698 return load_hdf5_internal (loc_id, hdf5_save_type, name); |
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
699 } |
24224
ff81c6772664
avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents:
23580
diff
changeset
|
700 |
24225
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
701 private: |
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
702 |
b8cb5a05955e
improve on lto fix made in changeset ff81c6772664
John W. Eaton <jwe@octave.org>
parents:
24224
diff
changeset
|
703 static octave_hdf5_id hdf5_save_type; |
4904 | 704 |
705 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA | |
706 }; |