annotate src/octave-value/ov-intx.h @ 15149:62a35ae7d6a2

use forward decls for mxArray in ov.h and ov-base.h * ov.h, ov-base.h: Use forward decls for mxArray class instead of including mxarray.h. * ov-base-diag.cc, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-bool.cc, ov-cell.cc, ov-ch-mat.cc, ov-class.cc, ov-complex.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-float.cc, ov-flt-complex.cc, ov-flt-cx-mat.cc, ov-flt-re-mat.cc, ov-intx.h, ov-perm.cc, ov-range.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.cc, ov-struct.cc, ov-bool-sparse.cc, ov-perm.cc: Include mxarray.h. #include "mach-info.h" * ov-bool-sparse.cc, ov-perm.cc: Include dim-vector.h
author John W. Eaton <jwe@octave.org>
date Fri, 10 Aug 2012 17:59:35 -0400
parents 46b19589b593
children
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
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 12645
diff changeset
3 Copyright (C) 2004-2012 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
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6693
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6693
diff changeset
11 option) any later version.
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
12
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
16 for more details.
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
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
24 #include <cstdlib>
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
25
8950
d865363208d6 include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
26 #include <iosfwd>
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
27 #include <string>
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
28
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
29 #include "mx-base.h"
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
30 #include "oct-alloc.h"
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
31 #include "str-vec.h"
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
32
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
33 #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
34 #include "mxarray.h"
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
35 #include "oct-stream.h"
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
36 #include "ov-base.h"
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
37 #include "ov-base-int.h"
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
38 #include "ov-typeinfo.h"
4982
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
39 #include "gripes.h"
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
40
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
41 #include "ov-re-mat.h"
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
42 #include "ov-scalar.h"
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
43
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
44 class
6693
768d3ad80bbf [project @ 2007-06-06 05:18:54 by jwe]
jwe
parents: 6686
diff changeset
45 OCTINTERP_API
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
46 OCTAVE_VALUE_INT_MATRIX_T
8321
69b6127f6962 better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents: 8039
diff changeset
47 : public octave_base_int_matrix<intNDArray<OCTAVE_INT_T> >
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
48 {
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
49 public:
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
50
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
51 OCTAVE_VALUE_INT_MATRIX_T (void)
8321
69b6127f6962 better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents: 8039
diff changeset
52 : octave_base_int_matrix<intNDArray<OCTAVE_INT_T> > () { }
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
53
8321
69b6127f6962 better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents: 8039
diff changeset
54 OCTAVE_VALUE_INT_MATRIX_T (const intNDArray<OCTAVE_INT_T>& nda)
69b6127f6962 better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents: 8039
diff changeset
55 : octave_base_int_matrix<intNDArray<OCTAVE_INT_T> > (nda) { }
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
56
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9685
diff changeset
57 OCTAVE_VALUE_INT_MATRIX_T (const Array<OCTAVE_INT_T>& nda)
8321
69b6127f6962 better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents: 8039
diff changeset
58 : octave_base_int_matrix<intNDArray<OCTAVE_INT_T> >
69b6127f6962 better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents: 8039
diff changeset
59 (intNDArray<OCTAVE_INT_T> (nda)) { }
7064
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
60
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
61 ~OCTAVE_VALUE_INT_MATRIX_T (void) { }
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
62
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5731
diff changeset
63 octave_base_value *clone (void) const
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
64 { return new OCTAVE_VALUE_INT_MATRIX_T (*this); }
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
65
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5731
diff changeset
66 octave_base_value *empty_clone (void) const
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
67 { return new OCTAVE_VALUE_INT_MATRIX_T (); }
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
68
6069
67b1a61a85ce [project @ 2006-10-21 14:33:53 by jwe]
jwe
parents: 5943
diff changeset
69 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
70
6223
a6cc01dd09f9 [project @ 2007-01-03 20:59:28 by jwe]
jwe
parents: 6214
diff changeset
71 bool is_integer_type (void) const { return true; }
a6cc01dd09f9 [project @ 2007-01-03 20:59:28 by jwe]
jwe
parents: 6214
diff changeset
72
9685
e793865ede63 implement builtin_type
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
73 builtin_type_t builtin_type (void) const { return OCTAVE_INT_BTYP; }
e793865ede63 implement builtin_type
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
74
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
75 public:
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
76
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
77 int8NDArray
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
78 int8_array_value (void) const { return int8NDArray (matrix); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
79
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
80 int16NDArray
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
81 int16_array_value (void) const { return int16NDArray (matrix); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
82
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
83 int32NDArray
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
84 int32_array_value (void) const { return int32NDArray (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 int64NDArray
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
87 int64_array_value (void) const { return int64NDArray (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 uint8NDArray
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
90 uint8_array_value (void) const { return uint8NDArray (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 uint16NDArray
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
93 uint16_array_value (void) const { return uint16NDArray (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 uint32NDArray
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
96 uint32_array_value (void) const { return uint32NDArray (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 uint64NDArray
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
99 uint64_array_value (void) const { return uint64NDArray (matrix); }
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
100
4982
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
101 double
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
102 double_value (bool = false) const
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
103 {
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
104 double retval = lo_ieee_nan_value ();
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
105
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
106 if (numel () > 0)
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
107 {
14469
29aabe9b37a2 Rename array-as-vector, array-as-scalar warning IDs to match documentation (bug #35838)
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
108 gripe_implicit_conversion ("Octave:array-to-scalar",
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
109 type_name (), "real scalar");
4982
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
110
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
111 retval = matrix(0).double_value ();
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
112 }
4982
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
113 else
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
114 gripe_invalid_conversion (type_name (), "real scalar");
4982
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
115
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
116 return retval;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
117
4982
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
118 }
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
119
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
120 float
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
121 float_value (bool = false) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
122 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
123 float retval = lo_ieee_float_nan_value ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
124
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
125 if (numel () > 0)
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
126 {
14469
29aabe9b37a2 Rename array-as-vector, array-as-scalar warning IDs to match documentation (bug #35838)
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
127 gripe_implicit_conversion ("Octave:array-to-scalar",
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
128 type_name (), "real scalar");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
129
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
130 retval = matrix(0).float_value ();
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
131 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
132 else
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
133 gripe_invalid_conversion (type_name (), "real scalar");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
134
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
135 return retval;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
136
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
137 }
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
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
145 {
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
146 Matrix retval;
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
147 dim_vector dv = dims ();
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
148 if (dv.length () > 2)
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14469
diff changeset
149 error ("invalid conversion of %s to Matrix", type_name ().c_str ());
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
150 else
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
151 {
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
152 retval = Matrix (dv(0), dv(1));
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
153 double *vec = retval.fortran_vec ();
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
154 octave_idx_type nel = matrix.numel ();
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
155 for (octave_idx_type i = 0; i < nel; i++)
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
156 vec[i] = matrix(i).double_value ();
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
157 }
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
158 return retval;
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
159 }
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
160
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
161 FloatMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
162 float_matrix_value (bool = false) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
163 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
164 FloatMatrix retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
165 dim_vector dv = dims ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
166 if (dv.length () > 2)
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14469
diff changeset
167 error ("invalid conversion of %s to FloatMatrix", type_name ().c_str ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
168 else
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
169 {
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
170 retval = FloatMatrix (dv(0), dv(1));
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
171 float *vec = retval.fortran_vec ();
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
172 octave_idx_type nel = matrix.numel ();
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
173 for (octave_idx_type i = 0; i < nel; i++)
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
174 vec[i] = matrix(i).float_value ();
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
175 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
176 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
177 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
178
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
179 ComplexMatrix
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
180 complex_matrix_value (bool = false) const
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
181 {
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
182 ComplexMatrix retval;
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14469
diff changeset
183 dim_vector dv = dims ();
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
184 if (dv.length () > 2)
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14469
diff changeset
185 error ("invalid conversion of %s to Matrix", type_name ().c_str ());
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
186 else
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
187 {
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
188 retval = ComplexMatrix (dv(0), dv(1));
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
189 Complex *vec = retval.fortran_vec ();
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
190 octave_idx_type nel = matrix.numel ();
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
191 for (octave_idx_type i = 0; i < nel; i++)
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
192 vec[i] = Complex (matrix(i).double_value ());
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
193 }
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
194 return retval;
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
195 }
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
196
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
197 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
198 float_complex_matrix_value (bool = false) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
199 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
200 FloatComplexMatrix retval;
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14469
diff changeset
201 dim_vector dv = dims ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
202 if (dv.length () > 2)
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14469
diff changeset
203 error ("invalid conversion of %s to FloatMatrix", type_name ().c_str ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
204 else
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
205 {
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
206 retval = FloatComplexMatrix (dv(0), dv(1));
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
207 FloatComplex *vec = retval.fortran_vec ();
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
208 octave_idx_type nel = matrix.numel ();
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
209 for (octave_idx_type i = 0; i < nel; i++)
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
210 vec[i] = FloatComplex (matrix(i).float_value ());
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
211 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
212 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
213 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
214
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
215 NDArray
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
216 array_value (bool = false) const
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
217 {
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
218 NDArray retval (matrix.dims ());
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
219 double *vec = retval.fortran_vec ();
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
220 octave_idx_type nel = matrix.numel ();
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
221 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
222 vec[i] = matrix(i).double_value ();
4963
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
223 return retval;
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
224 }
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
225
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
226 FloatNDArray
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
227 float_array_value (bool = false) const
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
228 {
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
229 FloatNDArray retval (matrix.dims ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
230 float *vec = retval.fortran_vec ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
231 octave_idx_type nel = matrix.numel ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
232 for (octave_idx_type i = 0; i < nel; i++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
233 vec[i] = matrix(i).float_value ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
234 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
235 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
236
4963
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
237 ComplexNDArray
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
238 complex_array_value (bool = false) const
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
239 {
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
240 ComplexNDArray retval (matrix.dims ());
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
241 Complex *vec = retval.fortran_vec ();
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
242 octave_idx_type nel = matrix.numel ();
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
243 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
244 vec[i] = Complex (matrix(i).double_value ());
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
245 return retval;
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
246 }
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
247
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
248 FloatComplexNDArray
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
249 float_complex_array_value (bool = false) const
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
250 {
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
251 FloatComplexNDArray retval (matrix.dims ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
252 FloatComplex *vec = retval.fortran_vec ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
253 octave_idx_type nel = matrix.numel ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
254 for (octave_idx_type i = 0; i < nel; i++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
255 vec[i] = FloatComplex (matrix(i).float_value ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
256 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
257 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
258
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
259 boolNDArray
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
260 bool_array_value (bool warn = false) const
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
261 {
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
262 boolNDArray retval (dims ());
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
263
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
264 octave_idx_type nel = numel ();
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
265
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
266 if (warn && matrix.any_element_not_one_or_zero ())
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
267 gripe_logical_conversion ();
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
268
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
269 bool *vec = retval.fortran_vec ();
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
270 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
271 vec[i] = matrix(i).bool_value ();
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
272
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
273 return retval;
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
274 }
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
275
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
276 charNDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
277 char_array_value (bool = false) const
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
278 {
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
279 charNDArray retval (dims ());
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
280
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
281 octave_idx_type nel = numel ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
282
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
283 char *vec = retval.fortran_vec ();
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
284 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
285 vec[i] = matrix(i).char_value ();
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
286
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
287 return retval;
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
288 }
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
289
9606
a04352386a6b clear index cache on ++,-- operators
Jaroslav Hajek <highegg@gmail.com>
parents: 9358
diff changeset
290 // 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
291 void increment (void)
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
292 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14469
diff changeset
293 matrix_ref () += OCTAVE_INT_T (1);
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
294 }
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
295
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
296 void decrement (void)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
297 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14469
diff changeset
298 matrix_ref () -= OCTAVE_INT_T (1);
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
299 }
5829
93785a1b0f97 [project @ 2006-05-23 18:34:10 by jwe]
jwe
parents: 5781
diff changeset
300
9607
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9606
diff changeset
301 void changesign (void)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
302 {
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
303 matrix_ref ().changesign ();
9607
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9606
diff changeset
304 }
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9606
diff changeset
305
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
306 idx_vector index_vector (void) const
9350
16a5f9e1fdb3 cache idx_vector result in matrices once used for indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8950
diff changeset
307 { return idx_cache ? *idx_cache : set_idx_cache (idx_vector (matrix)); }
4938
703d97b89507 [project @ 2004-08-09 20:21:59 by jwe]
jwe
parents: 4915
diff changeset
308
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
309 int write (octave_stream& os, int block_size,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
310 oct_data_conv::data_type output_type, int skip,
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
311 oct_mach_info::float_format flt_fmt) const
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
312 { return os.write (matrix, block_size, output_type, skip, flt_fmt); }
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
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.
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
316 void *mex_get_data (void) const { return matrix.mex_get_data (); }
d4b1314a7c31 mex.cc (mxArray_octave_value::get_data): avoid enumerating types that can be handled as foreign
John W. Eaton <jwe@octave.org>
parents: 9350
diff changeset
317
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
318 mxArray *as_mxArray (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
319 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
320 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
321
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
322 OCTAVE_INT_T::val_type *pr = static_cast<OCTAVE_INT_T::val_type *> (retval->get_data ());
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
323
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6223
diff changeset
324 mwSize nel = numel ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
325
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
326 const OCTAVE_INT_T *p = matrix.data ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
327
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6223
diff changeset
328 for (mwIndex i = 0; i < nel; i++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
329 pr[i] = p[i].value ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
330
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
331 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
332 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
333
9812
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
334 octave_value map (unary_mapper_t umap) const
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
335 {
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
336 switch (umap)
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
337 {
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
338 case umap_abs:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
339 return matrix.abs ();
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
340 case umap_signum:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
341 return matrix.signum ();
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
342 case umap_ceil:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
343 case umap_conj:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
344 case umap_fix:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
345 case umap_floor:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
346 case umap_real:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
347 case umap_round:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
348 return matrix;
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
349 case umap_imag:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
350 return intNDArray<OCTAVE_INT_T> (matrix.dims (), OCTAVE_INT_T ());
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
351 case umap_isnan:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
352 case umap_isna:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
353 case umap_isinf:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
354 return boolNDArray (matrix.dims (), false);
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
355 case umap_finite:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
356 return boolNDArray (matrix.dims (), true);
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
357
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
358 default:
9812
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
359 {
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
360 octave_matrix m (array_value ());
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
361 return m.map (umap);
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
362 }
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
363 }
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
364 }
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
365
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
366 private:
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
367
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
368 DECLARE_OCTAVE_ALLOCATOR
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
369
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
370 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
371 };
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
372
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
373 class
6693
768d3ad80bbf [project @ 2007-06-06 05:18:54 by jwe]
jwe
parents: 6686
diff changeset
374 OCTINTERP_API
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
375 OCTAVE_VALUE_INT_SCALAR_T
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
376 : public octave_base_int_scalar<OCTAVE_INT_T>
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 public:
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 OCTAVE_VALUE_INT_SCALAR_T (void)
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
381 : octave_base_int_scalar<OCTAVE_INT_T> () { }
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
382
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
383 OCTAVE_VALUE_INT_SCALAR_T (const OCTAVE_INT_T& nda)
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
384 : octave_base_int_scalar<OCTAVE_INT_T> (nda) { }
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 ~OCTAVE_VALUE_INT_SCALAR_T (void) { }
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
387
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5731
diff changeset
388 octave_base_value *clone (void) const
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
389 { return new OCTAVE_VALUE_INT_SCALAR_T (*this); }
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
390
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5731
diff changeset
391 octave_base_value *empty_clone (void) const
8389
ff5892c8ddd0 fix integer assignment to non-existing variables
Jaroslav Hajek <highegg@gmail.com>
parents: 8321
diff changeset
392 { return new OCTAVE_VALUE_INT_MATRIX_T (); }
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
393
5885
bd3041e30d97 [project @ 2006-07-14 20:29:35 by jwe]
jwe
parents: 5829
diff changeset
394 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
395 bool resize_ok = false)
4983
13aaef87cf18 [project @ 2004-09-10 13:51:29 by jwe]
jwe
parents: 4982
diff changeset
396 {
8437
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
397 // FIXME -- this doesn't solve the problem of
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
398 //
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
399 // a = 1; a([1,1], [1,1], [1,1])
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
400 //
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
401 // and similar constructions. Hmm...
4964
269c3d6c0569 [project @ 2004-09-04 01:16:28 by jwe]
jwe
parents: 4963
diff changeset
402
8437
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
403 // FIXME -- using this constructor avoids narrowing the
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
404 // 1x1 matrix back to a scalar value. Need a better solution
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
405 // to this problem.
4964
269c3d6c0569 [project @ 2004-09-04 01:16:28 by jwe]
jwe
parents: 4963
diff changeset
406
8437
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
407 octave_value tmp
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
408 (new OCTAVE_VALUE_INT_MATRIX_T
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
409 (OCTAVE_VALUE_INT_NDARRAY_EXTRACTOR_FUNCTION ()));
4964
269c3d6c0569 [project @ 2004-09-04 01:16:28 by jwe]
jwe
parents: 4963
diff changeset
410
8437
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
411 return tmp.do_index_op (idx, resize_ok);
4983
13aaef87cf18 [project @ 2004-09-10 13:51:29 by jwe]
jwe
parents: 4982
diff changeset
412 }
4964
269c3d6c0569 [project @ 2004-09-04 01:16:28 by jwe]
jwe
parents: 4963
diff changeset
413
6069
67b1a61a85ce [project @ 2006-10-21 14:33:53 by jwe]
jwe
parents: 5943
diff changeset
414 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
415
6223
a6cc01dd09f9 [project @ 2007-01-03 20:59:28 by jwe]
jwe
parents: 6214
diff changeset
416 bool is_integer_type (void) const { return true; }
a6cc01dd09f9 [project @ 2007-01-03 20:59:28 by jwe]
jwe
parents: 6214
diff changeset
417
9685
e793865ede63 implement builtin_type
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
418 builtin_type_t builtin_type (void) const { return OCTAVE_INT_BTYP; }
e793865ede63 implement builtin_type
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
419
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
420 public:
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
421
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
422 octave_int8
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
423 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
424
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
425 octave_int16
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
426 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
427
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
428 octave_int32
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
429 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
430
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
431 octave_int64
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
432 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
433
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
434 octave_uint8
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
435 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
436
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
437 octave_uint16
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
438 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
439
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
440 octave_uint32
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
441 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
442
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
443 octave_uint64
10405
cc69a17ec801 remove integer math warnings
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
444 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
445
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
446 int8NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
447 int8_array_value (void) const
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
448 { return int8NDArray (dim_vector (1, 1), int8_scalar_value ()); }
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
449
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
450 int16NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
451 int16_array_value (void) const
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
452 { 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
453
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
454 int32NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
455 int32_array_value (void) const
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
456 { 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
457
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
458 int64NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
459 int64_array_value (void) const
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
460 { 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
461
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
462 uint8NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
463 uint8_array_value (void) const
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
464 { 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
465
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
466 uint16NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
467 uint16_array_value (void) const
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
468 { 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
469
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
470 uint32NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
471 uint32_array_value (void) const
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
472 { 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
473
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
474 uint64NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
475 uint64_array_value (void) const
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
476 { return uint64NDArray (dim_vector (1, 1), uint64_scalar_value ()); }
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
477
5731
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5533
diff changeset
478 octave_value resize (const dim_vector& dv, bool fill = false) const
4982
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
479 {
5731
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5533
diff changeset
480 if (fill)
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
481 {
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
482 intNDArray<OCTAVE_INT_T> retval (dv, 0);
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14469
diff changeset
483 if (dv.numel ())
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
484 retval(0) = scalar;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
485 return retval;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
486 }
5731
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5533
diff changeset
487 else
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
488 {
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
489 intNDArray<OCTAVE_INT_T> retval (dv);
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14469
diff changeset
490 if (dv.numel ())
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
491 retval(0) = scalar;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
492 return retval;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
493 }
4982
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
494 }
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
495
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
496 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
497
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
498 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
499
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
500 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
501
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
502 float float_scalar_value (bool = false) const { return scalar.float_value (); }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
503
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
504 Matrix
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
505 matrix_value (bool = false) const
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
506 {
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
507 Matrix retval (1, 1);
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
508 retval(0,0) = scalar.double_value ();
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
509 return retval;
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
510 }
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
511
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
512 FloatMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
513 float_matrix_value (bool = false) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
514 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
515 FloatMatrix retval (1, 1);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
516 retval(0,0) = scalar.float_value ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
517 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
518 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
519
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
520 ComplexMatrix
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
521 complex_matrix_value (bool = false) const
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
522 {
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
523 ComplexMatrix retval (1, 1);
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
524 retval(0,0) = Complex (scalar.double_value ());
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
525 return retval;
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
526 }
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
527
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
528 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
529 float_complex_matrix_value (bool = false) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
530 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
531 FloatComplexMatrix retval (1, 1);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
532 retval(0,0) = FloatComplex (scalar.float_value ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
533 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
534 }
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
535
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
536 NDArray
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
537 array_value (bool = false) const
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
538 {
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
539 NDArray retval (dim_vector (1, 1));
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
540 retval(0) = scalar.double_value ();
4963
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
541 return retval;
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
542 }
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
543
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
544 FloatNDArray
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
545 float_array_value (bool = false) const
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
546 {
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
547 FloatNDArray retval (dim_vector (1, 1));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
548 retval(0) = scalar.float_value ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
549 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
550 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
551
4963
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
552 ComplexNDArray
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
553 complex_array_value (bool = false) const
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
554 {
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
555 ComplexNDArray retval (dim_vector (1, 1));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
556 retval(0) = FloatComplex (scalar.double_value ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
557 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
558 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
559
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
560 FloatComplexNDArray
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
561 float_complex_array_value (bool = false) const
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
562 {
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
563 FloatComplexNDArray retval (dim_vector (1, 1));
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
564 retval(0) = FloatComplex (scalar.float_value ());
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
565 return retval;
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
566 }
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
567
12645
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
568 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
569 {
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
570 if (warn && scalar != 0.0 && scalar != 1.0)
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
571 gripe_logical_conversion ();
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
572
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
573 return scalar.bool_value ();
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
574 }
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
575
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
576 boolNDArray
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
577 bool_array_value (bool warn = false) const
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
578 {
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
579 boolNDArray retval (dim_vector (1, 1));
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
580
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
581 if (warn && scalar != 0.0 && scalar != 1.0)
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
582 gripe_logical_conversion ();
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
583
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
584 retval(0) = scalar.bool_value ();
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
585
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
586 return retval;
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
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
589 charNDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
590 char_array_value (bool = false) const
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
591 {
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
592 charNDArray retval (dim_vector (1, 1));
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
593 retval(0) = scalar.char_value ();
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
594 return retval;
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
595 }
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
596
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
597 void increment (void)
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
598 {
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
599 scalar += OCTAVE_INT_T (1);
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
600 }
5829
93785a1b0f97 [project @ 2006-05-23 18:34:10 by jwe]
jwe
parents: 5781
diff changeset
601
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
602 void decrement (void)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
603 {
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
604 scalar -= OCTAVE_INT_T (1);
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
605 }
5829
93785a1b0f97 [project @ 2006-05-23 18:34:10 by jwe]
jwe
parents: 5781
diff changeset
606
4938
703d97b89507 [project @ 2004-08-09 20:21:59 by jwe]
jwe
parents: 4915
diff changeset
607 idx_vector index_vector (void) const { return idx_vector (scalar); }
703d97b89507 [project @ 2004-08-09 20:21:59 by jwe]
jwe
parents: 4915
diff changeset
608
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
609 int write (octave_stream& os, int block_size,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
610 oct_data_conv::data_type output_type, octave_idx_type skip,
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
611 oct_mach_info::float_format flt_fmt) const
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
612 {
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
613 return os.write (OCTAVE_VALUE_INT_NDARRAY_EXTRACTOR_FUNCTION (),
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
614 block_size, output_type, skip, flt_fmt);
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
615 }
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
616
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
617 // Unsafe. This function exists to support the MEX interface.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
618 // You should not use it anywhere else.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
619 void *mex_get_data (void) const { return scalar.mex_get_data (); }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
620
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
621 mxArray *as_mxArray (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
622 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
623 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
624
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
625 OCTAVE_INT_T::val_type *pr = static_cast<OCTAVE_INT_T::val_type *> (retval->get_data ());
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
626
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
627 pr[0] = scalar.value ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
628
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
629 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
630 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
631
9812
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
632 octave_value map (unary_mapper_t umap) const
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
633 {
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
634 switch (umap)
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
635 {
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
636 case umap_abs:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
637 return scalar.abs ();
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
638 case umap_signum:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
639 return scalar.signum ();
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
640 case umap_ceil:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
641 case umap_conj:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
642 case umap_fix:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
643 case umap_floor:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
644 case umap_real:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
645 case umap_round:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
646 return scalar;
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
647 case umap_imag:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
648 return OCTAVE_INT_T ();
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
649 case umap_isnan:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
650 case umap_isna:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
651 case umap_isinf:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
652 return false;
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
653 case umap_finite:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
654 return true;
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
655
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
656 default:
9812
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
657 {
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
658 octave_scalar m (scalar_value ());
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
659 return m.map (umap);
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
660 }
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
661 }
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
662 }
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
663
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
664 private:
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
665
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
666 DECLARE_OCTAVE_ALLOCATOR
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
667
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
668 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
669 };