annotate src/ov-intx.h @ 9685:e793865ede63

implement builtin_type
author Jaroslav Hajek <highegg@gmail.com>
date Fri, 02 Oct 2009 08:27:44 +0200
parents 1be3c73ed7b5
children b4fdfee405b5
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
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8437
diff changeset
3 Copyright (C) 2004, 2005, 2006, 2007, 2008 John W. Eaton
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
4
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
6
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
7 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
8 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
9 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
10 option) any later version.
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
11
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
12 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
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
14 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
15 for more details.
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
16
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
17 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
18 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
19 <http://www.gnu.org/licenses/>.
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
20
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 #include <cstdlib>
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
24
8950
d865363208d6 include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
25 #include <iosfwd>
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
26 #include <string>
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
27
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
28 #include "mx-base.h"
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
29 #include "oct-alloc.h"
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
30 #include "str-vec.h"
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
31
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
32 #include "error.h"
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
33 #include "oct-stream.h"
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
34 #include "ov-base.h"
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
35 #include "ov-base-int.h"
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
36 #include "ov-typeinfo.h"
4982
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
37 #include "gripes.h"
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
38
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
39 #include "ov-re-mat.h"
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
40 #include "ov-scalar.h"
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
41
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
42 class
6693
768d3ad80bbf [project @ 2007-06-06 05:18:54 by jwe]
jwe
parents: 6686
diff changeset
43 OCTINTERP_API
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
44 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
45 : public octave_base_int_matrix<intNDArray<OCTAVE_INT_T> >
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
46 {
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
47 public:
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 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
50 : octave_base_int_matrix<intNDArray<OCTAVE_INT_T> > () { }
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
51
8321
69b6127f6962 better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents: 8039
diff changeset
52 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
53 : octave_base_int_matrix<intNDArray<OCTAVE_INT_T> > (nda) { }
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
54
7064
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
55 OCTAVE_VALUE_INT_MATRIX_T (const ArrayN<OCTAVE_INT_T>& nda)
8321
69b6127f6962 better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents: 8039
diff changeset
56 : 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
57 (intNDArray<OCTAVE_INT_T> (nda)) { }
7064
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
58
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
59 ~OCTAVE_VALUE_INT_MATRIX_T (void) { }
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
60
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5731
diff changeset
61 octave_base_value *clone (void) const
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
62 { return new OCTAVE_VALUE_INT_MATRIX_T (*this); }
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
63
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5731
diff changeset
64 octave_base_value *empty_clone (void) const
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
65 { return new OCTAVE_VALUE_INT_MATRIX_T (); }
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
66
6069
67b1a61a85ce [project @ 2006-10-21 14:33:53 by jwe]
jwe
parents: 5943
diff changeset
67 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
68
6223
a6cc01dd09f9 [project @ 2007-01-03 20:59:28 by jwe]
jwe
parents: 6214
diff changeset
69 bool is_integer_type (void) const { return true; }
a6cc01dd09f9 [project @ 2007-01-03 20:59:28 by jwe]
jwe
parents: 6214
diff changeset
70
9685
e793865ede63 implement builtin_type
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
71 builtin_type_t builtin_type (void) const { return OCTAVE_INT_BTYP; }
e793865ede63 implement builtin_type
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
72
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
73 private:
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
74
7999
f7f2d867c523 style fixes
John W. Eaton <jwe@octave.org>
parents: 7997
diff changeset
75 template <class IM>
f7f2d867c523 style fixes
John W. Eaton <jwe@octave.org>
parents: 7997
diff changeset
76 IM convert_gripe () const
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
77 {
7999
f7f2d867c523 style fixes
John W. Eaton <jwe@octave.org>
parents: 7997
diff changeset
78 typedef typename IM::element_type dest_el_type;
8321
69b6127f6962 better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents: 8039
diff changeset
79 typedef intNDArray<OCTAVE_INT_T>::element_type src_el_type;
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
80 dest_el_type::clear_conv_flag ();
7999
f7f2d867c523 style fixes
John W. Eaton <jwe@octave.org>
parents: 7997
diff changeset
81 IM retval (matrix);
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
82 if (dest_el_type::get_trunc_flag ())
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
83 gripe_truncated_conversion (src_el_type::type_name (),
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
84 dest_el_type::type_name ());
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
85 dest_el_type::clear_conv_flag ();
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
86 return retval;
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
87 }
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
88
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
89 public:
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
90
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
91 int8NDArray
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
92 int8_array_value (void) const { return convert_gripe<int8NDArray> (); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
93
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
94 int16NDArray
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
95 int16_array_value (void) const { return convert_gripe<int16NDArray> (); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
96
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
97 int32NDArray
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
98 int32_array_value (void) const { return convert_gripe<int32NDArray> (); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
99
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
100 int64NDArray
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
101 int64_array_value (void) const { return convert_gripe<int64NDArray> (); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
102
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
103 uint8NDArray
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
104 uint8_array_value (void) const { return convert_gripe<uint8NDArray> (); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
105
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
106 uint16NDArray
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
107 uint16_array_value (void) const { return convert_gripe<uint16NDArray> (); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
108
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
109 uint32NDArray
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
110 uint32_array_value (void) const { return convert_gripe<uint32NDArray> (); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
111
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
112 uint64NDArray
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
113 uint64_array_value (void) const { return convert_gripe<uint64NDArray> (); }
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
114
4982
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
115 double
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
116 double_value (bool = false) const
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
117 {
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
118 double retval = lo_ieee_nan_value ();
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
119
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
120 if (numel () > 0)
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
121 {
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
122 gripe_implicit_conversion ("Octave:array-as-scalar",
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
123 type_name (), "real scalar");
4982
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
124
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
125 retval = matrix(0).double_value ();
4982
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
126 }
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
127 else
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
128 gripe_invalid_conversion (type_name (), "real scalar");
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
129
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
130 return retval;
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
131
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
132 }
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
133
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
134 float
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
135 float_value (bool = false) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
136 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
137 float retval = lo_ieee_float_nan_value ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
138
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
139 if (numel () > 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
140 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
141 gripe_implicit_conversion ("Octave:array-as-scalar",
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
142 type_name (), "real scalar");
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
143
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
144 retval = matrix(0).float_value ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
145 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
146 else
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
147 gripe_invalid_conversion (type_name (), "real scalar");
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
148
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
149 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
150
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
151 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
152
4983
13aaef87cf18 [project @ 2004-09-10 13:51:29 by jwe]
jwe
parents: 4982
diff changeset
153 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
154
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
155 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
156
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
157 Matrix
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
158 matrix_value (bool = false) const
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 Matrix retval;
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
161 dim_vector dv = dims ();
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
162 if (dv.length () > 2)
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
163 error ("invalid conversion of %s to Matrix", type_name().c_str ());
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
164 else
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
165 {
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
166 retval = Matrix (dv(0), dv(1));
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
167 double *vec = retval.fortran_vec ();
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
168 octave_idx_type nel = matrix.numel ();
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
169 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
170 vec[i] = matrix(i).double_value ();
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
171 }
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
172 return retval;
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
173 }
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
174
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
175 FloatMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
176 float_matrix_value (bool = false) const
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 FloatMatrix retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
179 dim_vector dv = dims ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
180 if (dv.length () > 2)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
181 error ("invalid conversion of %s to FloatMatrix", type_name().c_str ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
182 else
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
183 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
184 retval = FloatMatrix (dv(0), dv(1));
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
185 float *vec = retval.fortran_vec ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
186 octave_idx_type nel = matrix.numel ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
187 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
188 vec[i] = matrix(i).float_value ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
189 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
190 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
191 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
192
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
193 ComplexMatrix
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
194 complex_matrix_value (bool = false) const
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 ComplexMatrix retval;
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
197 dim_vector dv = dims();
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
198 if (dv.length () > 2)
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
199 error ("invalid conversion of %s to Matrix", type_name().c_str ());
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
200 else
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
201 {
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
202 retval = ComplexMatrix (dv(0), dv(1));
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
203 Complex *vec = retval.fortran_vec ();
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
204 octave_idx_type nel = matrix.numel ();
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
205 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
206 vec[i] = Complex (matrix(i).double_value ());
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
207 }
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
208 return retval;
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
209 }
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
210
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
211 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
212 float_complex_matrix_value (bool = false) const
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 FloatComplexMatrix retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
215 dim_vector dv = dims();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
216 if (dv.length () > 2)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
217 error ("invalid conversion of %s to FloatMatrix", type_name().c_str ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
218 else
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
219 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
220 retval = FloatComplexMatrix (dv(0), dv(1));
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
221 FloatComplex *vec = retval.fortran_vec ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
222 octave_idx_type nel = matrix.numel ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
223 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
224 vec[i] = FloatComplex (matrix(i).float_value ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
225 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
226 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
227 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
228
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
229 NDArray
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
230 array_value (bool = false) const
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
231 {
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
232 NDArray retval (matrix.dims ());
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
233 double *vec = retval.fortran_vec ();
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
234 octave_idx_type nel = matrix.numel ();
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
235 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
236 vec[i] = matrix(i).double_value ();
4963
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
237 return retval;
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
238 }
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
239
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
240 FloatNDArray
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
241 float_array_value (bool = false) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
242 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
243 FloatNDArray retval (matrix.dims ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
244 float *vec = retval.fortran_vec ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
245 octave_idx_type nel = matrix.numel ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
246 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
247 vec[i] = matrix(i).float_value ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
248 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
249 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
250
4963
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
251 ComplexNDArray
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
252 complex_array_value (bool = false) const
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
253 {
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
254 ComplexNDArray retval (matrix.dims ());
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
255 Complex *vec = retval.fortran_vec ();
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
256 octave_idx_type nel = matrix.numel ();
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
257 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
258 vec[i] = Complex (matrix(i).double_value ());
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
259 return retval;
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
260 }
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
261
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
262 FloatComplexNDArray
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
263 float_complex_array_value (bool = false) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
264 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
265 FloatComplexNDArray retval (matrix.dims ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
266 FloatComplex *vec = retval.fortran_vec ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
267 octave_idx_type nel = matrix.numel ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
268 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
269 vec[i] = FloatComplex (matrix(i).float_value ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
270 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
271 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
272
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
273 boolNDArray
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
274 bool_array_value (bool warn = false) const
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
275 {
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
276 boolNDArray retval (dims ());
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
277
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
278 octave_idx_type nel = numel ();
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
279
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
280 if (warn && matrix.any_element_not_one_or_zero ())
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
281 gripe_logical_conversion ();
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
282
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
283 bool *vec = retval.fortran_vec ();
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
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).bool_value ();
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
286
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
287 return retval;
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
288 }
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
289
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
290 charNDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
291 char_array_value (bool = false) const
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
292 {
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
293 charNDArray retval (dims ());
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
294
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
295 octave_idx_type nel = numel ();
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
296
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
297 char *vec = retval.fortran_vec ();
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
298 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
299 vec[i] = matrix(i).char_value ();
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
300
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
301 return retval;
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
302 }
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
303
9606
a04352386a6b clear index cache on ++,-- operators
Jaroslav Hajek <highegg@gmail.com>
parents: 9358
diff changeset
304 // Use matrix_ref here to clear index cache.
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
305 void increment (void)
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
306 {
9606
a04352386a6b clear index cache on ++,-- operators
Jaroslav Hajek <highegg@gmail.com>
parents: 9358
diff changeset
307 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
308 if (OCTAVE_INT_T::get_math_trunc_flag ())
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
309 gripe_unop_integer_math_truncated ("++", type_name (). c_str ());
5829
93785a1b0f97 [project @ 2006-05-23 18:34:10 by jwe]
jwe
parents: 5781
diff changeset
310
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
311 OCTAVE_INT_T::clear_conv_flag ();
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
312 }
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
313
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
314 void decrement (void)
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
315 {
9606
a04352386a6b clear index cache on ++,-- operators
Jaroslav Hajek <highegg@gmail.com>
parents: 9358
diff changeset
316 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
317 if (OCTAVE_INT_T::get_math_trunc_flag ())
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
318 gripe_unop_integer_math_truncated ("--", type_name (). c_str ());
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
319 OCTAVE_INT_T::clear_conv_flag ();
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
320 }
5829
93785a1b0f97 [project @ 2006-05-23 18:34:10 by jwe]
jwe
parents: 5781
diff changeset
321
9607
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9606
diff changeset
322 void changesign (void)
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9606
diff changeset
323 {
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9606
diff changeset
324 matrix_ref ().changesign ();
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9606
diff changeset
325 if (OCTAVE_INT_T::get_math_trunc_flag ())
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9606
diff changeset
326 gripe_unop_integer_math_truncated ("-", type_name (). c_str ());
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9606
diff changeset
327 OCTAVE_INT_T::clear_conv_flag ();
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9606
diff changeset
328 }
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9606
diff changeset
329
9350
16a5f9e1fdb3 cache idx_vector result in matrices once used for indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8950
diff changeset
330 idx_vector index_vector (void) const
16a5f9e1fdb3 cache idx_vector result in matrices once used for indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8950
diff changeset
331 { 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
332
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
333 int write (octave_stream& os, int block_size,
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
334 oct_data_conv::data_type output_type, int skip,
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
335 oct_mach_info::float_format flt_fmt) const
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
336 { 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
337
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
338 // 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
339 // 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
340 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
341
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
342 mxArray *as_mxArray (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
343 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
344 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
345
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
346 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
347
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6223
diff changeset
348 mwSize nel = numel ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
349
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
350 const OCTAVE_INT_T *p = matrix.data ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
351
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6223
diff changeset
352 for (mwIndex i = 0; i < nel; i++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
353 pr[i] = p[i].value ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
354
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
355 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
356 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
357
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
358 #define MAT_MAPPER(FCN) \
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
359 octave_value FCN (void) const { return matrix.FCN (); }
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
360
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
361 MAT_MAPPER (abs)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
362 MAT_MAPPER (signum)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
363
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
364 #undef MAT_MAPPER
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
365
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
366 octave_value imag (void) const
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
367 {
8321
69b6127f6962 better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents: 8039
diff changeset
368 return intNDArray<OCTAVE_INT_T> (matrix.dims (),
69b6127f6962 better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents: 8039
diff changeset
369 static_cast<OCTAVE_INT_T>(0));
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
370 }
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
371
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
372 #define NO_OP_MAPPER(FCN) \
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
373 octave_value FCN (void) const { return octave_value (matrix); }
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
374
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
375 NO_OP_MAPPER (ceil)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
376 NO_OP_MAPPER (conj)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
377 NO_OP_MAPPER (fix)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
378 NO_OP_MAPPER (floor)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
379 NO_OP_MAPPER (real)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
380 NO_OP_MAPPER (round)
7636
99c410f7f0b0 implement mapper function for banker's rounding
Jaroslav Hajek <highegg@gmail.com>
parents: 7503
diff changeset
381 NO_OP_MAPPER (roundb)
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
382
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
383 #undef NO_OP_MAPPER
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
384
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
385 #define BOOL_MAPPER(FCN, VAL) \
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
386 octave_value FCN (void) const { return boolNDArray (matrix.dims (), VAL); }
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
387
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
388 BOOL_MAPPER (finite, true)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
389 BOOL_MAPPER (isinf, false)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
390 BOOL_MAPPER (isna, false)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
391 BOOL_MAPPER (isnan, false)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
392
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
393 #undef BOOL_MAPPER
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
394
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
395 private:
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
396
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
397 DECLARE_OCTAVE_ALLOCATOR
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
398
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
399 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
400 };
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
401
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
402 class
6693
768d3ad80bbf [project @ 2007-06-06 05:18:54 by jwe]
jwe
parents: 6686
diff changeset
403 OCTINTERP_API
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
404 OCTAVE_VALUE_INT_SCALAR_T
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
405 : public octave_base_int_scalar<OCTAVE_INT_T>
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
406 {
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
407 public:
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
408
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
409 OCTAVE_VALUE_INT_SCALAR_T (void)
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
410 : octave_base_int_scalar<OCTAVE_INT_T> () { }
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
411
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
412 OCTAVE_VALUE_INT_SCALAR_T (const OCTAVE_INT_T& nda)
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
413 : octave_base_int_scalar<OCTAVE_INT_T> (nda) { }
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
414
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
415 ~OCTAVE_VALUE_INT_SCALAR_T (void) { }
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
416
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5731
diff changeset
417 octave_base_value *clone (void) const
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
418 { return new OCTAVE_VALUE_INT_SCALAR_T (*this); }
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
419
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5731
diff changeset
420 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
421 { return new OCTAVE_VALUE_INT_MATRIX_T (); }
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
422
5885
bd3041e30d97 [project @ 2006-07-14 20:29:35 by jwe]
jwe
parents: 5829
diff changeset
423 octave_value do_index_op (const octave_value_list& idx,
bd3041e30d97 [project @ 2006-07-14 20:29:35 by jwe]
jwe
parents: 5829
diff changeset
424 bool resize_ok = false)
4983
13aaef87cf18 [project @ 2004-09-10 13:51:29 by jwe]
jwe
parents: 4982
diff changeset
425 {
8437
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
426 // FIXME -- this doesn't solve the problem of
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
427 //
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
428 // a = 1; a([1,1], [1,1], [1,1])
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
429 //
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
430 // and similar constructions. Hmm...
4964
269c3d6c0569 [project @ 2004-09-04 01:16:28 by jwe]
jwe
parents: 4963
diff changeset
431
8437
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
432 // FIXME -- using this constructor avoids narrowing the
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
433 // 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
434 // to this problem.
4964
269c3d6c0569 [project @ 2004-09-04 01:16:28 by jwe]
jwe
parents: 4963
diff changeset
435
8437
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
436 octave_value tmp
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
437 (new OCTAVE_VALUE_INT_MATRIX_T
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
438 (OCTAVE_VALUE_INT_NDARRAY_EXTRACTOR_FUNCTION ()));
4964
269c3d6c0569 [project @ 2004-09-04 01:16:28 by jwe]
jwe
parents: 4963
diff changeset
439
8437
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8389
diff changeset
440 return tmp.do_index_op (idx, resize_ok);
4983
13aaef87cf18 [project @ 2004-09-10 13:51:29 by jwe]
jwe
parents: 4982
diff changeset
441 }
4964
269c3d6c0569 [project @ 2004-09-04 01:16:28 by jwe]
jwe
parents: 4963
diff changeset
442
6069
67b1a61a85ce [project @ 2006-10-21 14:33:53 by jwe]
jwe
parents: 5943
diff changeset
443 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
444
6223
a6cc01dd09f9 [project @ 2007-01-03 20:59:28 by jwe]
jwe
parents: 6214
diff changeset
445 bool is_integer_type (void) const { return true; }
a6cc01dd09f9 [project @ 2007-01-03 20:59:28 by jwe]
jwe
parents: 6214
diff changeset
446
9685
e793865ede63 implement builtin_type
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
447 builtin_type_t builtin_type (void) const { return OCTAVE_INT_BTYP; }
e793865ede63 implement builtin_type
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
448
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
449 private:
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
450
7999
f7f2d867c523 style fixes
John W. Eaton <jwe@octave.org>
parents: 7997
diff changeset
451 template <class IS>
f7f2d867c523 style fixes
John W. Eaton <jwe@octave.org>
parents: 7997
diff changeset
452 IS convert_gripe () const
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
453 {
7999
f7f2d867c523 style fixes
John W. Eaton <jwe@octave.org>
parents: 7997
diff changeset
454 typedef IS dest_el_type;
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
455 typedef OCTAVE_INT_T src_el_type;
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
456 dest_el_type::clear_conv_flag ();
7999
f7f2d867c523 style fixes
John W. Eaton <jwe@octave.org>
parents: 7997
diff changeset
457 IS retval (scalar);
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
458
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
459 if (dest_el_type::get_trunc_flag ())
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
460 gripe_truncated_conversion (src_el_type::type_name (),
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
461 dest_el_type::type_name ());
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
462 dest_el_type::clear_conv_flag ();
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
463 return retval;
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
464 }
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
465
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
466 public:
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
467
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
468 octave_int8
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
469 int8_scalar_value (void) const { return convert_gripe<octave_int8> (); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
470
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
471 octave_int16
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
472 int16_scalar_value (void) const { return convert_gripe<octave_int16> (); }
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 octave_int32
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
475 int32_scalar_value (void) const { return convert_gripe<octave_int32> (); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
476
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
477 octave_int64
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
478 int64_scalar_value (void) const { return convert_gripe<octave_int64> (); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
479
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
480 octave_uint8
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
481 uint8_scalar_value (void) const { return convert_gripe<octave_uint8> (); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
482
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
483 octave_uint16
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
484 uint16_scalar_value (void) const { return convert_gripe<octave_uint16> (); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
485
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
486 octave_uint32
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
487 uint32_scalar_value (void) const { return convert_gripe<octave_uint32> (); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
488
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
489 octave_uint64
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
490 uint64_scalar_value (void) const { return convert_gripe<octave_uint64> (); }
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
491
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
492 int8NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
493 int8_array_value (void) const
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
494 { return int8NDArray (dim_vector (1, 1), int8_scalar_value ()); }
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
495
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
496 int16NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
497 int16_array_value (void) const
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
498 { 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
499
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
500 int32NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
501 int32_array_value (void) const
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
502 { 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
503
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
504 int64NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
505 int64_array_value (void) const
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
506 { 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
507
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
508 uint8NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
509 uint8_array_value (void) const
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
510 { 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
511
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
512 uint16NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
513 uint16_array_value (void) const
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
514 { 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
515
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
516 uint32NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
517 uint32_array_value (void) const
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
518 { 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
519
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
520 uint64NDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
521 uint64_array_value (void) const
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
522 { return uint64NDArray (dim_vector (1, 1), uint64_scalar_value ()); }
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
523
5731
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5533
diff changeset
524 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
525 {
5731
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5533
diff changeset
526 if (fill)
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5533
diff changeset
527 {
8321
69b6127f6962 better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents: 8039
diff changeset
528 intNDArray<OCTAVE_INT_T> retval (dv, 0);
5731
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5533
diff changeset
529 if (dv.numel())
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5533
diff changeset
530 retval(0) = scalar;
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5533
diff changeset
531 return retval;
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5533
diff changeset
532 }
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5533
diff changeset
533 else
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5533
diff changeset
534 {
8321
69b6127f6962 better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents: 8039
diff changeset
535 intNDArray<OCTAVE_INT_T> retval (dv);
5731
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5533
diff changeset
536 if (dv.numel())
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5533
diff changeset
537 retval(0) = scalar;
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5533
diff changeset
538 return retval;
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5533
diff changeset
539 }
4982
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
540 }
c0866f89c43d [project @ 2004-09-10 13:48:18 by jwe]
jwe
parents: 4964
diff changeset
541
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
542 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
543
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
544 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
545
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
546 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
547
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
548 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
549
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
550 Matrix
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
551 matrix_value (bool = false) const
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
552 {
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
553 Matrix retval (1, 1);
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
554 retval(0,0) = scalar.double_value ();
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
555 return retval;
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
556 }
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
557
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
558 FloatMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
559 float_matrix_value (bool = false) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
560 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
561 FloatMatrix retval (1, 1);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
562 retval(0,0) = scalar.float_value ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
563 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
564 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
565
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
566 ComplexMatrix
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
567 complex_matrix_value (bool = false) const
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
568 {
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
569 ComplexMatrix retval (1, 1);
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
570 retval(0,0) = Complex (scalar.double_value ());
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
571 return retval;
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
572 }
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
573
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
574 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
575 float_complex_matrix_value (bool = false) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
576 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
577 FloatComplexMatrix retval (1, 1);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
578 retval(0,0) = FloatComplex (scalar.float_value ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
579 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
580 }
6214
4685a6a76229 [project @ 2006-12-08 22:15:03 by jwe]
jwe
parents: 6069
diff changeset
581
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
582 NDArray
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
583 array_value (bool = false) const
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
584 {
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
585 NDArray retval (dim_vector (1, 1));
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
586 retval(0) = scalar.double_value ();
4963
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
587 return retval;
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
588 }
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
589
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
590 FloatNDArray
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
591 float_array_value (bool = false) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
592 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
593 FloatNDArray retval (dim_vector (1, 1));
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
594 retval(0) = scalar.float_value ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
595 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
596 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
597
4963
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
598 ComplexNDArray
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
599 complex_array_value (bool = false) const
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4944
diff changeset
600 {
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
601 ComplexNDArray retval (dim_vector (1, 1));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
602 retval(0) = FloatComplex (scalar.double_value ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
603 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
604 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
605
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
606 FloatComplexNDArray
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
607 float_complex_array_value (bool = false) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
608 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
609 FloatComplexNDArray retval (dim_vector (1, 1));
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7636
diff changeset
610 retval(0) = FloatComplex (scalar.float_value ());
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
611 return retval;
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
612 }
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4910
diff changeset
613
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
614 boolNDArray
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
615 bool_array_value (bool warn = false) const
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
616 {
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
617 boolNDArray retval (dim_vector (1, 1));
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
618
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
619 if (warn && scalar != 0.0 && scalar != 1.0)
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
620 gripe_logical_conversion ();
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
621
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
622 retval(0) = scalar.bool_value ();
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5900
diff changeset
623
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
624 return retval;
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
625 }
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5895
diff changeset
626
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
627 charNDArray
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
628 char_array_value (bool = false) const
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
629 {
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
630 charNDArray retval (dim_vector (1, 1));
7198
4555c116b420 [project @ 2007-11-27 03:06:10 by jwe]
jwe
parents: 7064
diff changeset
631 retval(0) = scalar.char_value ();
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
632 return retval;
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
633 }
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
634
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
635 void increment (void)
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
636 {
8321
69b6127f6962 better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents: 8039
diff changeset
637 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
638 if (OCTAVE_INT_T::get_math_trunc_flag ())
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
639 gripe_unop_integer_math_truncated ("++", type_name (). c_str ());
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
640 OCTAVE_INT_T::clear_conv_flag ();
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
641 }
5829
93785a1b0f97 [project @ 2006-05-23 18:34:10 by jwe]
jwe
parents: 5781
diff changeset
642
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
643 void decrement (void)
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
644 {
8321
69b6127f6962 better use of templates in ov-intx.h
John W. Eaton <jwe@octave.org>
parents: 8039
diff changeset
645 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
646 if (OCTAVE_INT_T::get_math_trunc_flag ())
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
647 gripe_unop_integer_math_truncated ("--", type_name (). c_str ());
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
648 OCTAVE_INT_T::clear_conv_flag ();
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
649 }
5829
93785a1b0f97 [project @ 2006-05-23 18:34:10 by jwe]
jwe
parents: 5781
diff changeset
650
4938
703d97b89507 [project @ 2004-08-09 20:21:59 by jwe]
jwe
parents: 4915
diff changeset
651 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
652
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
653 int write (octave_stream& os, int block_size,
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5030
diff changeset
654 oct_data_conv::data_type output_type, octave_idx_type skip,
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
655 oct_mach_info::float_format flt_fmt) const
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
656 {
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
657 return os.write (OCTAVE_VALUE_INT_NDARRAY_EXTRACTOR_FUNCTION (),
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
658 block_size, output_type, skip, flt_fmt);
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
659 }
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4938
diff changeset
660
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
661 // Unsafe. This function exists to support the MEX interface.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
662 // You should not use it anywhere else.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
663 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
664
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
665 mxArray *as_mxArray (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
666 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
667 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
668
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
669 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
670
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
671 pr[0] = scalar.value ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
672
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
673 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
674 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
675
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
676 #define SCALAR_MAPPER(FCN) \
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
677 octave_value FCN (void) const { return scalar.FCN (); }
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
678
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
679 SCALAR_MAPPER (abs)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
680 SCALAR_MAPPER (signum)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
681
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
682 #undef SCALAR_MAPPER
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
683
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
684 octave_value imag (void) const { return static_cast<OCTAVE_INT_T>(0); }
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
685
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
686 #define NO_OP_MAPPER(FCN) \
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
687 octave_value FCN (void) const { return octave_value (scalar); }
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
688
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
689 NO_OP_MAPPER (ceil)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
690 NO_OP_MAPPER (conj)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
691 NO_OP_MAPPER (fix)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
692 NO_OP_MAPPER (floor)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
693 NO_OP_MAPPER (real)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
694 NO_OP_MAPPER (round)
7636
99c410f7f0b0 implement mapper function for banker's rounding
Jaroslav Hajek <highegg@gmail.com>
parents: 7503
diff changeset
695 NO_OP_MAPPER (roundb)
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
696
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
697 #undef NO_OP_MAPPER
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
698
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
699 #define BOOL_MAPPER(FCN, VAL) octave_value FCN (void) const { return VAL; }
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
700
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
701 BOOL_MAPPER (finite, true)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
702 BOOL_MAPPER (isinf, false)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
703 BOOL_MAPPER (isna, false)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
704 BOOL_MAPPER (isnan, false)
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
705
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
706 #undef BOOL_MAPPER
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7201
diff changeset
707
4904
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
708 private:
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
709
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
710 DECLARE_OCTAVE_ALLOCATOR
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
711
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
712 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
713 };
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
714
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
715 /*
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
716 ;;; Local Variables: ***
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
717 ;;; mode: C++ ***
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
718 ;;; End: ***
71229573b6bf [project @ 2004-06-14 19:31:52 by jwe]
jwe
parents:
diff changeset
719 */